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

Python 3 compatibility #7

Closed
wants to merge 4 commits into from
Closed

Python 3 compatibility #7

wants to merge 4 commits into from

Conversation

lucaswiman
Copy link

@gorakhargosh cc @nickjacobson Supercedes #6. Fixes #4.

  • Adds a tox.ini file for running the tests in both python 2 and python 3.
  • Updates the raised ValueError to something with the same __repr__ in both python 2 and python 3. This fixes the doctests.
  • Updates trove classifiers to indicate this package is python 2 and python 3 compatible. Bumps version to 0.2.0.

Other than some of the build scripts (which I couldn't get working even on python 2), everything was Python 3 compatible, except that the doctests had an annoying incompatibility where the exception had a different repr between python 2 and python 3:

Failed example:
    match_path("/users/gorakhargosh/FOOBAR.PY", ["*.py"], ["*.PY"], False)
Expected:
    Traceback (most recent call last):
        ...
    ValueError: conflicting patterns `set(['*.py'])` included and excluded
Got:
    Traceback (most recent call last):
      File "/Users/lucaswiman/.pyenv/versions/3.5/lib/python3.5/doctest.py", line 1320, in __run
        compileflags, 1), test.globs)
      File "<doctest pathtools.patterns.match_path[5]>", line 1, in <module>
        match_path("/users/gorakhargosh/FOOBAR.PY", ["*.py"], ["*.PY"], False)
      File "/Users/lucaswiman/opensource/pathtools/pathtools/patterns.py", line 174, in match_path
        return _match_path(pathname, included, excluded, case_sensitive)
      File "/Users/lucaswiman/opensource/pathtools/pathtools/patterns.py", line 125, in _match_path
        % common_patterns)
    ValueError: conflicting patterns `{'*.py'}` included and excluded

I updated the error so it includes a list of conflicting patterns. That has the same repr on python 2 and python 3.

Lucas Wiman added 3 commits September 13, 2016 18:40
- Adds a tox.ini file for running the tests in both python 2 and python 3.
- Update raised ValueError to something with the same __repr__ in both python 2 and python 3.
  This fixes the doctests.
- Update trove classifiers to indicate this package is python 2 and python 3 compatible.
@@ -69,12 +69,12 @@
except ImportError:
ez = {}
if USE_DISTRIBUTE:
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
).read() in ez
exec(urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fixes were added automatically by the futurize command. The script still isn't quite python 3 compatible, but seems to be broken anyway, since the link 404s.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has upstream bootstrap been updated for python 3 as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to have been updated, yes: https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py I don't understand the build scripts well enough to test them, so I've reverted my changes to the scripts directory in 27ce639.

My primary purpose in this PR was get the test suite to pass on Python 3 and update the trove classifiers so that pathtools no longer appears as "not ready" on the wall of python 3 readiness. The build scripts can stay on python 2 until its end of life.

Copy link

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to run the tests on Travis CI.

@eirnym
Copy link

eirnym commented Mar 15, 2018

@lucaswiman Why have you reverted changes in scripts/*.py? Python 2.7 supports these calls natively.

@eirnym
Copy link

eirnym commented Mar 15, 2018

@hugovk It's a separate task to run tests on Travis CI. I'd prefer to be sure that this task is complete and this PR doesn't add new features.

@lucaswiman
Copy link
Author

lucaswiman commented Mar 15, 2018

Why have you reverted changes in scripts/*.py? Python 2.7 supports these calls natively.

As I said in my comment above, the scripts still aren't python 3 compatible after those changes, but I don't understand scripts well enough to test them on python 3. They're not part of the sdist package, so upgrading them isn't as big a priority.

I can investigate making additional changes if you want. However, I do not want to devote more effort unless there's some chance it will get merged and deployed to pypi. This PR has been open for 18 months. Are you in favor of deploying this change to pypi once your review comments are addressed?

@@ -73,7 +73,7 @@ def walk(path, topdown=topdown, followlinks=followlinks):
try:
yield next(os.walk(path, topdown=topdown, followlinks=followlinks))
except NameError:
yield os.walk(path, topdown=topdown, followlinks=followlinks).next() #IGNORE:E1101
yield next(os.walk(path, topdown=topdown, followlinks=followlinks)) #IGNORE:E1101
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is now exactly the same line as inside the "try". I think this was here for Python 2.6 compatibility. Instead of this change, the except clause should simply be removed.

@westover
Copy link

With Python2 EOL approaching I am curious if this effort can be revived

@eirnym
Copy link

eirnym commented Jul 30, 2019

Why have you reverted changes in scripts/*.py? Python 2.7 supports these calls natively.

As I said in my comment above, the scripts still aren't python 3 compatible after those changes, but I don't understand scripts well enough to test them on python 3. They're not part of the sdist package, so upgrading them isn't as big a priority.

I can investigate making additional changes if you want. However, I do not want to devote more effort unless there's some chance it will get merged and deployed to pypi. This PR has been open for 18 months. Are you in favor of deploying this change to pypi once your review comments are addressed?

This could be done in a few steps. It's not required to do it all at once. For bootstrap on python3 I'd recommend to install the most recent setuptools, wheel and pip if you really had to do bootstrapping (I really doubt in it).

@lucaswiman
Copy link
Author

I am not planning any further work on this. Please open a new PR if anyone wants to take this on.

@lucaswiman lucaswiman closed this Jul 30, 2019
@eirnym
Copy link

eirnym commented Jul 31, 2019

@lucaswiman Thank you for your efforts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 3 compatible?
6 participants