WIP: cdblib: Fix py2/py3 compat
ClosedPublic

Authored by demon on Apr 30 2018, 8:42 PM.

Details

Reviewers
mmodell
thcipriani
Group Reviewers
Release-Engineering-Team
Commits
rMSCAcd15f2d78712: WIP: cdblib: Fix py2/py3 compat
Patch without arc
git checkout -b D1036 && curl -L https://phabricator.wikimedia.org/D1036?download=true | git apply
Summary
  • Use byte-array in a couple of places instead of str
  • Python3 folded IOError into OSError, so just throw OSError instead

WIP because I haven't gotten py_djb_hash()'s doctest working yet in py3

Diff Detail

Repository
rMSCA Scap
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
demon created this revision.Apr 30 2018, 8:42 PM
Restricted Application added a reviewer: mmodell. · View Herald TranscriptApr 30 2018, 8:42 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald Transcript
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript
demon requested review of this revision.Apr 30 2018, 8:46 PM
demon updated this revision to Diff 2755.May 4 2018, 8:17 PM
  • Better fixes
demon updated this revision to Diff 2756.May 4 2018, 8:22 PM
  • Vary encode() call on PY2/PY3. Bleh
demon added inline comments.May 4 2018, 8:23 PM
scap/cdblib.py
82

Probably should vary here as well.

demon updated this revision to Diff 2758.May 4 2018, 9:13 PM
  • Actually fix DJB hash func now

Because of the wide range of inputs we allow, we can easily end up in a weird state of byte arrays or strings. So variably use ord() depending on what we need

thcipriani accepted this revision.May 4 2018, 9:19 PM
thcipriani added a subscriber: thcipriani.

well played

This revision is now accepted and ready to land.May 4 2018, 9:19 PM
This revision was automatically updated to reflect the committed changes.

reverted saturday. Causing scap to fail. I think due to the data = data.encode('utf-8') on line 82.