Skip to content

Commit

Permalink
Use legacycrypt where crypt isn't available
Browse files Browse the repository at this point in the history
Since Python 3.13 has removed the crypt module, add legacycrypt to the
requirements if we're using that version of Python, importing it if the
crypt module isn't found.

Fixes networktocode#594
  • Loading branch information
s-t-e-v-e-n-k committed Dec 3, 2024
1 parent b35bad3 commit 3517bfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 4 additions & 2 deletions netutils/password.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Functions for working with Passwords."""

# TODO: Swap out crypt prior to py3.13
import crypt # pylint: disable=deprecated-module
try:
import crypt # pylint: disable=deprecated-module
except ModuleNotFoundError:
import legacycrypt as crypt
import random
import secrets
import string
Expand Down
17 changes: 14 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ include = [
python = "^3.8"
napalm = {version = "^4.0.0", optional = true}
jsonschema = {version = "^4.17.3", optional = true}
legacycrypt = {markers = "python_version >= \"3.13\"", version = "^0.3"}

[tool.poetry.extras]
optionals = ["jsonschema", "napalm"]
Expand Down

0 comments on commit 3517bfc

Please sign in to comment.