scap say: python2/3 compatible
AcceptedPublic

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

Details

Reviewers
mmodell
Group Reviewers
Release-Engineering-Team
Patch without arc
git checkout -b D1136 && curl -L https://phabricator.wikimedia.org/D1136?download=true | git apply
Summary

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
python3).

Diff Detail

thcipriani created this revision.Thu, Jan 3, 7:33 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald TranscriptThu, Jan 3, 7:33 PM
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript
jenkins added a subscriber: jenkins.Thu, Jan 3, 7:34 PM

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: https://integration.wikimedia.org/ci/job/phabricator-jessie-diffs/1182/
See console output for more information: https://integration.wikimedia.org/ci/job/phabricator-jessie-diffs/1182/console

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

extend the default ignore list to include W605

thcipriani requested review of this revision.Thu, Jan 3, 7:42 PM
mmodell accepted this revision.Tue, Jan 15, 3:25 PM

I generally like the idea of compat._unicode.

This revision is now accepted and ready to land.Tue, Jan 15, 3:25 PM