-
Notifications
You must be signed in to change notification settings - Fork 209
Support free-threaded Python 3.13 #925
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
Changes from 8 commits
87257a2
fb0606b
b7f6fbd
f0f4c17
95d99e1
9f49f5a
b557966
1a26622
7465f54
46fa817
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ jobs: | |
| PYTHON: | ||
| - {VERSION: "3.8", TOXENV: "py38"} | ||
| - {VERSION: "3.13", TOXENV: "py313"} | ||
| - {VERSION: "3.13t", TOXENV: "py313"} | ||
| MACOS: | ||
| - macos-13 | ||
| - macos-latest | ||
|
|
@@ -24,7 +25,7 @@ jobs: | |
| - uses: actions/[email protected] | ||
| - name: Setup python | ||
| id: setup-python | ||
| uses: actions/[email protected].0 | ||
| uses: quansight-labs/[email protected].1 | ||
| with: | ||
| python-version: ${{ matrix.PYTHON.VERSION }} | ||
| - uses: actions/[email protected] | ||
|
|
@@ -53,12 +54,13 @@ jobs: | |
| PYTHON: | ||
| - {VERSION: "3.8", TOXENV: "py38"} | ||
| - {VERSION: "3.13", TOXENV: "py313"} | ||
| - {VERSION: "3.13t", TOXENV: "py313"} | ||
| name: "Python ${{ matrix.PYTHON.VERSION }} on ${{ matrix.WINDOWS.WINDOWS }}" | ||
| steps: | ||
| - uses: actions/[email protected] | ||
| - name: Setup python | ||
| id: setup-python | ||
| uses: actions/[email protected].0 | ||
| uses: quansight-labs/[email protected].1 | ||
| with: | ||
| python-version: ${{ matrix.PYTHON.VERSION }} | ||
| architecture: ${{ matrix.WINDOWS.ARCH }} | ||
|
|
@@ -92,19 +94,20 @@ jobs: | |
| - {VERSION: "3.11", TOXENV: "py311"} | ||
| - {VERSION: "3.12", TOXENV: "py312"} | ||
| - {VERSION: "3.13", TOXENV: "py313"} | ||
| - {VERSION: "3.13t", TOXENV: "py313"} | ||
| - {VERSION: "pypy-3.9", TOXENV: "pypy3"} | ||
| - {VERSION: "pypy-3.10", TOXENV: "pypy3"} | ||
|
|
||
| # MSRV | ||
| - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "1.64.0"} | ||
| - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "beta"} | ||
| - {VERSION: "3.13", TOXENV: "py313", RUST_VERSION: "nightly"} | ||
| name: "${{ matrix.PYTHON.TOXENV }} on linux, Rust ${{ matrix.PYTHON.RUST_VERSION || 'stable' }}" | ||
| name: "${{ matrix.PYTHON.VERSION }} on linux, Rust ${{ matrix.PYTHON.RUST_VERSION || 'stable' }}" | ||
| steps: | ||
| - uses: actions/[email protected] | ||
| - name: Setup python | ||
| id: setup-python | ||
| uses: actions/[email protected].0 | ||
| uses: quansight-labs/[email protected].1 | ||
| with: | ||
| python-version: ${{ matrix.PYTHON.VERSION }} | ||
| - uses: actions/[email protected] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| import uuid | ||
| from concurrent.futures import ThreadPoolExecutor | ||
|
|
||
| import pytest | ||
|
|
||
| import bcrypt | ||
|
|
@@ -171,7 +174,7 @@ | |
| ] | ||
|
|
||
|
|
||
| def test_gensalt_basic(monkeypatch): | ||
| def test_gensalt_basic(): | ||
| salt = bcrypt.gensalt() | ||
| assert salt.startswith(b"$2b$12$") | ||
|
|
||
|
|
@@ -219,7 +222,7 @@ def test_gensalt_bad_prefix(): | |
| bcrypt.gensalt(prefix=b"bad") | ||
|
|
||
|
|
||
| def test_gensalt_2a_prefix(monkeypatch): | ||
| def test_gensalt_2a_prefix(): | ||
| salt = bcrypt.gensalt(prefix=b"2a") | ||
| assert salt.startswith(b"$2a$12$") | ||
|
|
||
|
|
@@ -464,6 +467,8 @@ def test_kdf_no_warn_rounds(): | |
| bcrypt.kdf(b"password", b"salt", 10, 10, True) | ||
|
|
||
|
|
||
| # Python warning state is global | ||
| @pytest.mark.thread_unsafe() | ||
alex marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def test_kdf_warn_rounds(): | ||
| with pytest.warns(UserWarning): | ||
| bcrypt.kdf(b"password", b"salt", 10, 10) | ||
|
|
@@ -494,3 +499,31 @@ def test_2a_wraparound_bug(): | |
| ) | ||
| == b"$2a$04$R1lJ2gkNaoPGdafE.H.16.1MKHPvmKwryeulRe225LKProWYwt9Oi" | ||
| ) | ||
|
|
||
|
|
||
| # this test spawns threads and is slow, so don't run it in many threads | ||
| @pytest.mark.parallel_threads(1) | ||
|
||
| def test_multithreading(): | ||
| class User: | ||
| def __init__(self, pw): | ||
| self.salt = bcrypt.gensalt(4) | ||
| self.hash_ = bcrypt.hashpw(pw, self.salt) | ||
| self.key = bcrypt.kdf(pw, self.salt, 32, 50) | ||
|
||
| assert self.check(pw) | ||
|
|
||
| def check(self, pw): | ||
| return bcrypt.checkpw(pw, self.hash_) | ||
|
|
||
| # use UUIDs as both ID and passwords | ||
|
||
| num_users = 50 | ||
| user_creator = ThreadPoolExecutor(max_workers=4) | ||
| pws = [uuid.uuid4().bytes for _ in range(num_users)] | ||
|
|
||
| futures = [user_creator.submit(User, pw) for pw in pws] | ||
|
||
|
|
||
| users = [future.result() for future in futures] | ||
|
|
||
| for pw, user in zip(pws, users): | ||
| assert bcrypt.hashpw(pw, user.salt) == user.hash_ | ||
| assert user.check(pw) | ||
| assert bcrypt.kdf(pw, user.salt, 32, 50) == user.key | ||
Uh oh!
There was an error while loading. Please reload this page.