Page MenuHomePhabricator

scap say: python2/3 compatible

Authored by thcipriani on Jan 3 2019, 7:33 PM.


Group Reviewers
rMSCA57d6fadd7b92: scap say: python2/3 compatible
Patch without arc
git checkout -b D1136 && curl -L | git apply

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

Diff Detail

rMSCA Scap
Lint Not Applicable
Tests Not Applicable

Event Timeline

Build has FAILED

Test Name
tox -vBuild Details

tox -v log

Got exit code 1 from PY_COLORS=1 tox -v

highlighting module code... [ 95%] scap.utils
highlighting module code... [100%] time

writing additional pages... search
copying images... [100%] assets/images/deploy-log.gif

copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded.

The HTML pages are in docs/_build/html.
___________________________________ summary ____________________________________
  py27: commands succeeded
  py34: ignored failed command
SKIPPED:  py35: InterpreterNotFound: python3.5
SKIPPED:  py36: InterpreterNotFound: python3.6
ERROR:   flake8: commands failed
  doc: commands succeeded

Link to build:
See console output for more information:

Harbormaster returned this revision to the author for changes because remote builds failed.Jan 3 2019, 7:34 PM
Harbormaster failed remote builds in B3190: Diff 2951!

extend the default ignore list to include W605

I generally like the idea of compat._unicode.

This revision is now accepted and ready to land.Jan 15 2019, 3:25 PM
This revision was automatically updated to reflect the committed changes.