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 #242

Closed
cwarren-mw opened this issue Apr 16, 2014 · 4 comments
Closed

Python 3 compatibility #242

cwarren-mw opened this issue Apr 16, 2014 · 4 comments
Assignees

Comments

@cwarren-mw
Copy link

These lines cause errors in Python 3:

https://github.com/jacquev6/PyGithub/blob/develop_v2/PyGithub/Blocking/_receive.py#L68

            except _ConversionException, e:

https://github.com/jacquev6/PyGithub/blob/develop_v2/PyGithub/Blocking/_receive.py#L120

            except (ValueError, TypeError), e:

If I'm reading http://python3porting.com/noconv.html correctly, they could be written like this, which would work for Python 2.6 and later:

            except _ConversionException as e:
            except (ValueError, TypeError) as e:
@jacquev6 jacquev6 added the v2 label Apr 16, 2014
@jacquev6 jacquev6 self-assigned this Apr 16, 2014
@jacquev6
Copy link
Member

So you're trying to use PyGithub with Python 3 directly from the source code without using 2to3 first.

Until now, the "correct" (understand "simple" and "supported") way to use PyGithub with Python 3 is to run "python3 setup.py install" and then use the installed version, because the use2to3 setuptools option will fix the code for you. If you really want to work in the source tree, you can run ./manage/2to3.sh first.

I'm not sure writing code compatible with both python 2 and 3 is worth it; I will keep this issue open until I've more time to think about it, but things like "iteritems" on dictionaries becoming "items", or name changes for imports may make it cumbersome, while the use2to3=True has proved to be reliable and easy to manage in v1 of PyGithub.

And by the way, Travis verifies PyGithub works with Python 3: https://travis-ci.org/jacquev6/PyGithub/builds/21856204

@nilp0inter
Copy link

I faced the same problems with python3 following the installation guide http://jacquev6.github.io/PyGithub/v2/introduction.html#installation .

The problem is that at the end of the installation process we are inside the source tree and the execution of python -c "import PyGithub" use the source tree version instead of the installed one.

Adding cd .. before python -c "import PyGithub" in the guide would be helpful for beginners.

Thank you.

@jacquev6
Copy link
Member

That's very true, thank you! I will make this change soon.

@jacquev6
Copy link
Member

Closing this issue now: I'll continue to use the use2to3 option and not try to write code that can be used as-is with the two major versions of Python.

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

No branches or pull requests

3 participants