-
Notifications
You must be signed in to change notification settings - Fork 53
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 support #55
Comments
|
I have a python3 branch for about a year. Every month or so I check to see if the required twisted component has been ported yet or not. It is on the list. :) |
|
@psi29a: I noticed your py3 branch hasn't had an update for about a year now. With twsited 16.4.0 being released stating 35+ modules ported to py3, by any chance, the one you've been looking for is in that list? |
|
I've been looking forward to that release a lot. When I have time, I'll give it a glance. I have a lot on my plate at the moment. If you would like to take my branch for a spin and test with 16.4, let us know! :) |
|
I'll try it |
This port depends on Twisted, which supports Python 3.x as of a number of versions ago for some growing number of its components. On initial view, ldaptor appears inconsistent (at least not explicit) in its state of Python 3.x support for its latest version (16.0.0, not this ports version, 0.0.43) - A Python 3 compatible wheel is available on PyPI - Python 3.3-3.5 are included in tox.ini for testing However: - Travis CI configuration only tests with 2.7 - Open "Python3 support #55" upstream issue [1] Additionally, Twisted/Python3 support aside, test builds (without USES=twisted declared), results in a build error at configure time: SyntaxError: invalid syntax This change limits build support to Python 2.7 accordingly. While I'm here: - Pet portlint: LICENSE [2], PLIST_FILES, makepatch. [1] twisted/ldaptor#55 [2] twisted/ldaptor@7e249b1 PR: 219323 Reported by: Johannes Jost Meixner Approved by: portmgr (blanket) MFH: 2017Q3 git-svn-id: svn+ssh://svn.freebsd.org/ports/head@448296 35697150-7ecd-e111-bb59-0022644237b5
This port depends on Twisted, which supports Python 3.x as of a number of versions ago for some growing number of its components. On initial view, ldaptor appears inconsistent (at least not explicit) in its state of Python 3.x support for its latest version (16.0.0, not this ports version, 0.0.43) - A Python 3 compatible wheel is available on PyPI - Python 3.3-3.5 are included in tox.ini for testing However: - Travis CI configuration only tests with 2.7 - Open "Python3 support #55" upstream issue [1] Additionally, Twisted/Python3 support aside, test builds (without USES=twisted declared), results in a build error at configure time: SyntaxError: invalid syntax This change limits build support to Python 2.7 accordingly. While I'm here: - Pet portlint: LICENSE [2], PLIST_FILES, makepatch. [1] twisted/ldaptor#55 [2] twisted/ldaptor@7e249b1 PR: 219323 Reported by: Johannes Jost Meixner Approved by: portmgr (blanket) MFH: 2017Q3
net/py-ldaptor: Limit to 2.7 (Does not support Python 3.x) This port depends on Twisted, which supports Python 3.x as of a number of versions ago for some growing number of its components. On initial view, ldaptor appears inconsistent (at least not explicit) in its state of Python 3.x support for its latest version (16.0.0, not this ports version, 0.0.43) - A Python 3 compatible wheel is available on PyPI - Python 3.3-3.5 are included in tox.ini for testing However: - Travis CI configuration only tests with 2.7 - Open "Python3 support #55" upstream issue [1] Additionally, Twisted/Python3 support aside, test builds (without USES=twisted declared), results in a build error at configure time: SyntaxError: invalid syntax This change limits build support to Python 2.7 accordingly. While I'm here: - Pet portlint: LICENSE [2], PLIST_FILES, makepatch. [1] twisted/ldaptor#55 [2] twisted/ldaptor@7e249b1 PR: 219323 Reported by: Johannes Jost Meixner Approved by: portmgr (blanket) Approved by: ports-secteam (blanket)
|
Is there a list of Twisted code which needs to be ported to py3? We can use that to prioritize the Twisted port... and if there is a list in this ticket maybe people wanting to see ldaptor on py3 can help first with those ports. Thanks :) |
|
It's been awhile, I should give this a go again to see where we stand. I had a branch I was working on, but was blocked by 'srvconnect'. My branch is here, 3 commits ahead of master. That was from Sep 14, 2015 |
|
The Twisted modules not ported to py3 are listed here https://github.com/twisted/twisted/blob/twisted-17.9.0/src/twisted/python/_setup.py#L366 I don't see twisted.names there so I guess that the whole DNS part was ported to py3 |
|
super...you can take my branch and move forward if you want. I'll give it an eyeball over the weekend. |
|
FWIW, we are willing to switch buildbot to ldaptor from ldap3 if this lib is compatible with py3. |
|
@psi29a thanks. Let me see what I can do... is only 3 comments but py3 porting stuff are mixed with style changes so it hard to tell which are the critical parts which needs extra care during review. I will try to break it into 2 PRs. One for the cleanup and then another one for the actual py3 stuff. I expect that the cleanup PR will be accepted without any controversy :) |
|
If this gets py3 support I'll also move an internal project to it(been using a java test LDAP server for integration tests, ugh)... |
|
@psi29a I am trying to work on your branch... but is hard. For example, I don't understand why list is forced in some places, where an iterator would also be fine: master...psi29a:python3#diff-27e63de333e9229e42907d35ed5b030aR138 |
|
I sent some PR which are targeting the py3 port. To make it easier to review I plan to break them into multiple ones. Next I plan to work on updating the code so that If you have time, please review the current PRs |
|
Sure, thanks for putting forth the effort! Update: merged the cleanup branch. for future reference, we should be touching the Changelog as well when making PRs, so that it makes it easier to make releases... it's already in the changelog! :) |
|
@s0undt3ch since you are already using a java ldap server, I guess that this is done in a separate process. Note that I am helping with porting the tests to python3... and check no regressions are done in python2. @psi29a does coveralls provide diff reports. I searched the internet but I could not find how to enable it. Maybe we should switch from coveralls to codecov.io and get diff reports and enforce a 100% coverage for the diff. |
|
I'll look into it, thanks. :) |
|
Coverage reported for added to the PR diff. I am doing my best to not introduce regressions ... so when tests are missing I will do my try to write them... resulting in bigger diffs... but I hope for the best #86 needs review I have to other branches on the pipeline... but they depend on the changes from #86 |
|
Just wondering-- do we have some kind of strategy for supporting Python 3.x? Is there a recommended approach we want contributors to take? Is there existing guidance? |
|
Latest Twisted release has even more things ported to Py3. I think the strategy is making sure code runs on both Py2 and Py3 but I believe the blocker has always been Twisted itself. |
|
I think that the first thing to do is to make sure that the existing test pass on py3.... that is a test driven porting. Not sure if latest Twisted can help. AFAIK, all modules used by ldaptor were already ported in January 2018. Even with #96 merged, there is still a significant number of failing test. But, as far as I remember, most part of the remaining failures are due to 2 or 3 methods which needs to be ported |
|
I think that that the main decision should be made regarding the internal handling of data. When running ldaptor under python2 there might be some places where Unicode/text will work due to the relax comparison in Python2.7 For example: There are a couple of things that need to be agreed in term of strategy when the default behaviour of py2 and py3 differ. For example: Since there are not many people with time to develop ldaptor and dedicate time to work at backward compatibility code, I suggest to look to the future and implement Python3 behaviour, even in Python2. This might break the Python code using ldaptor, but python2 will be gone anyway so the code should be updated anyway at some point. But I am ok to go with any other option. |
|
@wiml and merged! :) Thanks for bringing us one step further. |
|
Hi! Anything I can do to lend some of my porting expertise? |
|
@hawkowl see status of latest tests https://travis-ci.org/twisted/ldaptor/jobs/443707583 @GrayAn made a great step by implemeting Some ldiff related tests are failing... but because of Unicode vs bytes values... so they only need explicit bytes markup in the code. ex and more code need to be migrated to - server.dataReceived(str(pureldap.LDAPMessage(pureldap.LDAPBindRequest(dn='cn=jack,dc=example,dc=com', auth='s3krit'), id=4)))
+ server.dataReceived(pureldap.LDAPMessage(pureldap.LDAPBindRequest(dn='cn=jack,dc=example,dc=com', auth='s3krit'), id=4).toWire())So, I think that there is nothing complicated left on the porting... just hard work :( |
|
If we want PRs for Python3 compatibility, should be have something in CONTRIBUTING that gives some pointers on how to get started or how to test? E.g. do I need to make changes to the |
|
@cwaldbieser We can put some notes to CONTRIBUTING.... but I guess that each person can have a different strategy. My plan was to migrate all the existing tests first and only then look at the actual ldaptor functionality on Py3. If I found a major issue, I just wrote here or discussed it as part of a specific PR. But, I don't know if it is still worth updating CONTRIBUTING. |
|
I agree with @adiroiban, refactoring to use .toWire() will get Ldaptor far without any additional major refactoring work. |
|
Yes, I agree that What I mean is that "CONTRIBUTING.rst" currently has a helpful bit in it about what I'm thinking that the time is probably right to update the recommended environment to something like |
|
Sounds good to me. :) |
|
I've got a problem when porting LDIF and LDAPServer modules. In short: encoding and decoding back BaseLDAPEntry (and similar objects) with unicode attributes turns it to an object with bytes attributes. For example this object: turns into this after encoding and decoding back: It is perfectly compatible with Python 2. But for Python 3 users it can be confusing as they might expect unicode values for entry attributes. Do we need to leave entry attributes in bytes for backward compatibility? |
|
Well... https://pythonclock.org/ We'll eventually have to deprecate Python2, but sadly we can't break compatibility. |
|
I'd say that regardless of Python version, clients expect to get text for LDAP strings, ints for LDAP ints, etc. @GrayAn , do you have a minimal sample script where this happens so I can understand what is going on better? |
Yep. Ugly stuff. I think that for now, we need to leave them as bytes :( You might want to add a separate decoding function which will take bytes and an encoding (can default to UTF-8) and return an LDAP entry in Unicode.
I think that the main question here is back compatibility.
Does ldaptor implement schema / matching rules as in https://tools.ietf.org/html/rfc4517 ? I am using ldaptor in Python 2.7 and I am handling everything as raw bytes without schemas. |
|
So if I understand correctly, the crux of the issue is:
What about DNs, though? In RFC 4514, section 3:
Seems like the |
|
And attribute names-- don't they have to be LDAPStrings? |
Yes. I think that Attributes names should be Unicode/text.
I remember seeing some LDAP based tool using base64 to store the profile picture or SSH/GPG public keys.
Yes. I don't know how else you can do it without a schema. As a workaround, we can hardcode some conversions based on some well known schemas/attribute names. I think that unless we have a search method which takes a schema, the values should be bytes and each user will do its conversion... but as a helper, we can have a separate search function which does UTF-8 decoding for all values. I am storing/searching only text in LDAP with ldaptor, but with the current API I work with bytes, and I do explicit encoding/decoding of data when passing / receiving from ldaptor. I don't have Unicode attribute names. Any implicit encoding done in any future ldaptor version will break my code...and I guess the same will happen to other users. So, the default API should return bytes as values in LDAP search. I don't know what to say about the server, as I am only using ldaptor in production for client-side. |
Here is a small example for illustration: The output in Python 2.7: The output in Python 3.5:
Agree. So, bytestrings are decoded to objects with bytes attributes. And if we want them to be decoded to unicode additional flag |
|
So all tests are passed for Python 2.7 and Python 3.5 now. I checked how the head version works for my project (it uses LDAPServer functionality). Python 3 support required me to make several changes in places where I deal with internal library objects (
It looks like it works :) |
Great news. I would argue that using .toWire() instead of Keeping str() would have put a lot of effort on ldaptor maintainers ...and as we can see there are not many resources. Also, the Using string literals in Python3 for @GrayAn Thanks for your example. Much appreciated. I don't understand |
|
This should be documented then we can make a big-bang release |
Yes, it looks better without many quotation marks. |
I think that
For decoding, you might want to pass a Schema Decoder... so that numbers are decoded as numbers, and text as unicode, and photos will continue to stay as bytes. From RFC, my understanding is that values should be 'bytes' https://tools.ietf.org/html/rfc4511#section-4.1.5 .... so, if no explicit decoder is passed to LDAPSearchResultEntry, it should return all values as bytes in both Python 2 and Python3. To answer the original question
Yes. We need to leave attributes in bytes. Python2 and Python3 users should expect that they will get bytes and for now they should do their own conversions. We can implement a simple utility to decode all BaseLDAPEntry as UTF-8 text.... or implement an TextLDAPEntry which is similar to BaseLDAPEntry but does an implicit utf-8 decoding. |
|
I've got a question regarding These methods can raise exceptions if running on the Python 3. For example, LDAPServer with logging enabled uses Maybe they deserve to be test covered? :) |
Yes. It would be nice to have a bare minimal tests... if you or someone else has time. |
|
twisted has dropped support for python 2 |
|
Some serious efforts are going on here: |
|
Because we test against twisted trunk, Python 2 support has been dropped. Python 3.5 support will be dropped once twisted trunk drops py3.5 support |
net/py-ldaptor: Limit to 2.7 (Does not support Python 3.x) This port depends on Twisted, which supports Python 3.x as of a number of versions ago for some growing number of its components. On initial view, ldaptor appears inconsistent (at least not explicit) in its state of Python 3.x support for its latest version (16.0.0, not this ports version, 0.0.43) - A Python 3 compatible wheel is available on PyPI - Python 3.3-3.5 are included in tox.ini for testing However: - Travis CI configuration only tests with 2.7 - Open "Python3 support #55" upstream issue [1] Additionally, Twisted/Python3 support aside, test builds (without USES=twisted declared), results in a build error at configure time: SyntaxError: invalid syntax This change limits build support to Python 2.7 accordingly. While I'm here: - Pet portlint: LICENSE [2], PLIST_FILES, makepatch. [1] twisted/ldaptor#55 [2] twisted/ldaptor@7e249b1 PR: 219323 Reported by: Johannes Jost Meixner Approved by: portmgr (blanket) Approved by: ports-secteam (blanket)
This port depends on Twisted, which supports Python 3.x as of a number of versions ago for some growing number of its components. On initial view, ldaptor appears inconsistent (at least not explicit) in its state of Python 3.x support for its latest version (16.0.0, not this ports version, 0.0.43) - A Python 3 compatible wheel is available on PyPI - Python 3.3-3.5 are included in tox.ini for testing However: - Travis CI configuration only tests with 2.7 - Open "Python3 support #55" upstream issue [1] Additionally, Twisted/Python3 support aside, test builds (without USES=twisted declared), results in a build error at configure time: SyntaxError: invalid syntax This change limits build support to Python 2.7 accordingly. While I'm here: - Pet portlint: LICENSE [2], PLIST_FILES, makepatch. [1] twisted/ldaptor#55 [2] twisted/ldaptor@7e249b1 PR: 219323 Reported by: Johannes Jost Meixner Approved by: portmgr (blanket) MFH: 2017Q3
Hi, could you please support Python3? Many distributions are shifting to Python3 very soon and Python 2.7 will be supported only until 2020.
The text was updated successfully, but these errors were encountered: