-
Notifications
You must be signed in to change notification settings - Fork 580
Misc py3 compatibility fixes. #373
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
Conversation
|
hmm, isn't this handled by py2to3 in setup.py? I wonder how all the tests in the python3 environments on travis pass otherwise?!? |
|
It is handled by setup, but that won't work if you can't predict which Python version will be used to run the program (we ship rdflib bundled with a LibreOffice plugin, and a version built specifically for Python 2 or 3 will break things depending on which Python is used in at runtime). In this patch, I tried to follow the style of compatibility hacks already found in some rdflib modules, thus assuming a pull request is at least worth proposing, although may need additional work to make sure all the parsers/stores work in either Python. |
|
yes, it's definitely worth proposing, i'm just not sure how far we should go trying to recreate py2to3 within rdflib at runtime, in how many different places and if your fix is enough to achieve your goal. just a thought: Another thought: |
|
The theory of 2to3 was that you would port your code-base once, and then work on the new one. Using it like we do, to continously convert the code at install time is a bit of a pain in the neck, it makes it very awkward to actually develop on py3. So does this make the code so py3 compatible that the tests pass without running 2to3 first? |
|
I'm getting a lot of errors when running tests on either raw or prepared sources (./run_tests_py3.sh). At least some of the errors are seemingly unrelated to py3: undefined identifiers, etc. but few of them are py3-related syntax errors. The patch above only touches the few modules used by https://github.com/commonsmachinery/libcredit , and tested to work under py2 or py3. I could probably extend it to cover remaining modules if you guys don't object the "get rid of 2to3" idea and that doesn't conflict with any general rdflib plans. |
3 similar comments
Then your setup is somehow broken. On Travis both 3.2 and 3.3 pass fine: https://travis-ci.org/RDFLib/rdflib/builds/20659051 Running tests on the raw sources with py3 is unlikely to work. If we want to make a codebase that "natively" supports both 2 and 3, we could look into https://pypi.python.org/pypi/six - it does a lot of what our py3compat layer also does and more. |
|
Hi, I think six could be really helpful to clean up packaging. It seems a bit Cheers, Gerhard Sent from my iPad On 14 Mar 2014, at 5:05 pm, Gunnar Aastrand Grimnes < I'm getting a lot of errors when running tests on either raw or prepared Then your setup is somehow broken. On Travis both 3.2 and 3.3 pass fine: Running tests on the raw sources with py3 is unlikely to work. If we want to make a codebase that "natively" supports both 2 and 3, we — |
|
+1 to outsourcing the runtime compatibility layer to six; html5lib appears to be using it successfully |
|
ok, uhm shall we close this pull request and open a branch for moving things to six then? |
|
Fine! |
This commit fixes some minor issues that arise when importing rdflib in a Py3 environment. Compatibility with at least Python 2.6 is verified.