cannatag / ldap3

a strictly RFC 4510 conforming LDAP V3 pure Python client. The same codebase works with Python 2. Python 3, PyPy and PyPy3
Other
877 stars 271 forks source link

ldap3 is incompatible with Python 3.7 #428

Closed warsaw closed 6 years ago

warsaw commented 7 years ago

async and await have become keywords in Python 3.7, and this breaks ldap3 because you can no longer have an async.py module. This is a new SyntaxError:

    from .core.connection import Connection
E     File "venv/lib/python3.7/site-packages/ldap3/core/connection.py", line 53
E       from ..strategy.async import AsyncStrategy
E                           ^
E   SyntaxError: invalid syntax

I think you're going to have no choice but to rename that module unfortunately. It's also unfortunate that DeprecationWarnings are disabled by default because if they weren't you would have seen that warning in Python 3.6:

% python3.6 -W error::DeprecationWarning
Python 3.6.3 (default, Oct  4 2017, 06:09:15) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import async
DeprecationWarning: 'async' and 'await' will become reserved keywords in Python 3.7
>>> 
cannatag commented 7 years ago

Thanks Barry, I will update the codebase accordingly to your suggestion.

Bye, Giovanni

Il giorno 07 nov 2017, alle ore 00:45, Barry Warsaw notifications@github.com ha scritto:

async and await have become keywords in Python 3.7, and this breaks ldap3 because you can no longer have an async.py module. This is a new SyntaxError:

from .core.connection import Connection

E File "venv/lib/python3.7/site-packages/ldap3/core/connection.py", line 53 E from ..strategy.async import AsyncStrategy E ^ E SyntaxError: invalid syntax I think you're going to have no choice but to rename that module unfortunately. It's also unfortunate that DeprecationWarnings are disabled by default because if they weren't you would have seen that warning in Python 3.6:

% python3.6 -W error::DeprecationWarning Python 3.6.3 (default, Oct 4 2017, 06:09:15) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import async DeprecationWarning: 'async' and 'await' will become reserved keywords in Python 3.7

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

warsaw commented 7 years ago

Awesome, thanks @cannatag - if there's anything I can help with or a branch I can test, please let me know!

BTW, as it turns out, enabling DeprecationWarnings would not have caught this one. https://bugs.python.org/issue31973

cannatag commented 7 years ago

@warsaw Do you think that changing from async to async_ could suffice? This module is used mainly internally, so this should not be an issue for the users.

warsaw commented 7 years ago

@cannatag probably better to use _async then. We typically read leading single underscore to mean "private", so that both fixes the problem and is a strong clue that the module is to be only used internally.

Thanks!

cannatag commented 7 years ago

I know, but in this case I should change a bunch of functions to remain coherent throughout the codebase. I was following the convention of adding a trailing underscore when there is a conflict with a reserved keyword as suggested in PEP8. Anyway I will think about it.

Il giorno 09 nov 2017, alle ore 16:50, Barry Warsaw notifications@github.com ha scritto:

@cannatag probably better to use _async then. We typically read leading single underscore to mean "private", so that both fixes the problem and is a strong clue that the module is to be only used internally.

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

warsaw commented 7 years ago

On Nov 9, 2017, at 09:42, Giovanni Cannata notifications@github.com wrote:

I know, but in this case I should change a bunch of functions to remain coherent throughout the codebase. I was following the convention of adding a trailing underscore when there is a conflict with a reserved keyword as suggested in PEP8. Anyway I will think about it.

Sure thing. You know your codebase best. I really appreciate anything you do to fix the Python 3.7 support!

cannatag commented 6 years ago

Please check code in dev. It should work with Python 3.7 now.

warsaw commented 6 years ago

@cannatag Works for me, thanks!

cannatag commented 6 years ago

Released in v 2.4.

arielb2 commented 5 years ago

Hello Can you update the tarball, please? https://pypi.org/project/python3-ldap/#files

jonfen commented 5 years ago

Hello Can you update the tarball, please? https://pypi.org/project/python3-ldap/#files

ldap3==2.6.0 is the latest, @cannatag the issue came back

work around:

$ pip install ldap3==2.5.1

josuepirolo commented 2 years ago

If someone needs to use ldap3 without much configuration, Python 3.9 still accepts ldap3 2.4.1.