fedora-python / crypt_r

A copy of the crypt module that was removed in Python 3.13
Other
1 stars 2 forks source link

Harmful renaming? #12

Closed zx80 closed 1 month ago

zx80 commented 1 month ago

I'm a lost at the renaming, couldn't you have keep it with the same previous name, ie crypt?

I had hoped that installing passlib 1.7.4 + _cryptr with Python 3.13 would work out of the box.

However passlib (which does not seem to be updated soon) does from crypt import crypt ..., so a key point is that the package name (not its publication name, I'm fine with crypt_r) must be crypt and the provided function must be crypt for this to work.

There should not be any issue with Python 3.13 because there is no crypt, it was removed, that's the point.

There should not be any issue with prior versions because there is a crypt there and it is the same as this one, so declaring a dependency conditional on the version would be enough. The new crypt_r module should declare that it requires Python 3.13 or above.

What am I missing?

hroncok commented 1 month ago

I'm a lost at the renaming, couldn't you have keep it with the same previous name, ie crypt?

Hello @zx80. I'm sorry if the renaming is confusing. I certainly hope it isn't harmful.

I had hoped that installing passlib 1.7.4 + _cryptr with Python 3.13 would work out of the box.

However passlib (which does not seem to be updated soon) does from crypt import crypt ..., so a key point is that the package name (not its publication name, I'm fine with crypt_r) must be crypt and the provided function must be crypt for this to work.

And that should work. The README says:

To use this module, you can either import crypt_r explicitly or use the old crypt name for backward compatibility. However, on Python older than 3.13, the crypt module from the standard library will usually take precedence on sys.path.

And it works for me:

$ python3.13 -m pip install crypt_r
$ python
Python 3.13.0rc1 (main, Aug  6 2024, 00:00:00) [GCC 13.3.1 20240522 (Red Hat 13.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from crypt import crypt
>>> crypt.__module__
'crypt_r'

This is even tested in our test suite.

https://github.com/fedora-python/crypt_r/blob/b20e21d9f24d6fa17a6781bbc9f272ce38246eef/tests/test_crypt_r.py#L89-L93

There should not be any issue with Python 3.13 because there is no crypt, it was removed, that's the point.

Exactly.

There should not be any issue with prior versions because there is a crypt there and it is the same as this one, so declaring a dependency conditional on the version would be enough. The new crypt_r module should declare that it requires Python 3.13 or above.

The way I did it is that you can use import crypt_r even on older Python to avoid the deprecation warning. But you can keep doing import crypt if you don't mind that it will get you the old crypt on old Pythons and this crypt_r on new Pythons.

What am I missing?

Probably that it actually works?

zx80 commented 1 month ago

What am I missing?

Probably that it actually works?

Ok, good news! Thanks!!

Thanks for the reply.