Diffusion Scap 57d6fadd7b92

scap say: python2/3 compatible

Authored by thcipriani on Jan 24 2019, 1:31 PM.


scap say: python2/3 compatible

One strategy for supporting python2 and python3 from a single codebase
is The Unicode Sandwich. The idea is to treat all IO as bytes and all
strings internally as unicode. This idea is opposed to the so-called
'native string' strategy wherein everything has to be able to handle
python3 unicode strings and python2 byte strings. The native string
strategy sounds hard. To achieve the unicode sandwich you should convert
strings to unicode as quickly as possible.

I created the scap.compat module to house our weird compatibility code.
The _unicode function is used here to convert the eyes argument to
unicode from a string input (since that is different in python2 vs

Reviewers: mmodell, Release-Engineering-Team

Reviewed By: mmodell, Release-Engineering-Team

Subscribers: jenkins

Tags: Release-Engineering-Team

Differential Revision: https://phabricator.wikimedia.org/D1136