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

cannot import name: safe_str_cmp after latest release #2359

Closed
scurran1379 opened this issue Mar 28, 2022 · 2 comments
Closed

cannot import name: safe_str_cmp after latest release #2359

scurran1379 opened this issue Mar 28, 2022 · 2 comments

Comments

@scurran1379
Copy link

scurran1379 commented Mar 28, 2022

After the new version release i can no longer import: safe_str_cmp

>>> from werkzeug.security import safe_str_cmp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security'

To be able to import safe_str_cmp without an error

Environment:

  • Python version: 3.8.9
  • Werkzeug version: 2.1.0
@davidism
Copy link
Member

davidism commented Mar 28, 2022

This function was previously deprecated, and is now removed. https://werkzeug.palletsprojects.com/en/2.1.x/changes/#version-2-1-0

2.0.0:

pbkdf2_hex, pbkdf2_bin, and safe_str_cmp are deprecated. hashlib and hmac provide equivalents. #2083

2.1.0:

Remove previously deprecated code. #2276

  • Remove the pbkdf2_hex, pbkdf2_bin, and safe_str_cmp functions. Use equivalents in hashlib and hmac modules instead.

You should use a tool like pip-tools to pin your dependencies and control when you get updates. Be sure to run your tests with deprecation warnings treated as errors so that you get notified of these types of changes early.

@jaapz

This comment was marked as off-topic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants