Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 etc #31

Merged
merged 18 commits into from
Jun 4, 2015
Merged

Python3 etc #31

merged 18 commits into from
Jun 4, 2015

Conversation

samv
Copy link
Contributor

@samv samv commented Apr 17, 2014

As an exercise after the python 2 to 3 talk at PyCon (go watch http://pyvideo.org/video/2626/by-your-bootstraps-porting-your-application-to-p ), I thought I'd work on portability for this simple module.

/review @akshayjshah @dhui @rbm

samv added 18 commits April 17, 2014 11:14
This error is too much of a squeaky wheel in this module.
No need to catch the exception and raise a more helpful error; simply
annotate the test instead.
See python3porting.com :)
Replace with a helper (2to3 is too expensive!)
The test which sets up an enum with integers and tuples as values fails
here in this deprecated block because the values don't compare.  Just skip
that if it happens; it's probably a silly case anyway.
Use the 'six' with_metaclass helper.  The exception must handle a new type
of virtual base class; make it generic while we're here.  ie, a 'RichEnum'
sub-class can define __virtual__ to suppress this exception.
The total_ordering wrapper is a no-op on python 3.
This was sporadic on Python 3 and a deprecated field, so just make sure
all fields are present.
Changelog, add trove classifiers to setup.py, and complete
the tox.ini
    E:  3, 0: No name 'total_ordering' in module 'functools' (no-name-in-module)

Ah, well.  I'm not sure the workarounds are worth it.  Patches from
2.6-folk welcome.
'unicode' does not exist in python 3, and flake8 doesn't know that
these branches aren't reachable.
Pypy returns the following strange encoding error sometimes:

    ======================================================================
    FAIL: test_unicode_handling
    (tests.richenum.test_ordered_rich_enums.OrderedRichEnumTestSuite)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/samv/projects/richenum/tests/richenum/test_ordered_rich_enums.py", line 120, in test_unicode_handling
        r"<BreakfastEnumValue hearsaycorp#3: oatmeal. \('Oatmeal.'\)>",
    AssertionError: Regexp didn't match: "<BreakfastEnumValue hearsaycorp#3: oatmeal. \\('Oatmeal.'\\)>" not found in "<BreakfastEnumValue hearsaycorp#3: oatmeal??
    ('Oatmeal??')>"

    ======================================================================
    FAIL: test_unicode_handling
    (tests.richenum.test_rich_enums.RichEnumTestSuite)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/samv/projects/richenum/tests/richenum/test_rich_enums.py", line 145, in test_unicode_handling
        "<VegetableEnumValue: okra. \('Okra.'\)>",
    AssertionError: Regexp didn't match: "<VegetableEnumValue: okra. \\('Okra.'\\)>" not found in "<VegetableEnumValue: okra?? ('Okra??')>"

    ----------------------------------------------------------------------
    Ran 34 tests in 0.047s

    FAILED (failures=2)

Somehow this multi-byte character is getting converted to two ??'s.  It
happens occasionally locally, but not repeatably.  It doesn't matter
hugely, as it is mostly costmetic: let it stand.
@akshayjshah
Copy link
Contributor

@samv These changes look fine to me, but we'll need to bump the version number.

@samv
Copy link
Contributor Author

samv commented Oct 21, 2014

Sure, I'm down with that. Also, now that Python 3.4 ships with an enum module, it would be good to review and document how this module's API is different, and whether it can be made usefully compatible.

adepue pushed a commit that referenced this pull request Jun 4, 2015
@adepue adepue merged commit a7d275a into hearsaycorp:master Jun 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants