Blame SOURCES/0001-Fix-compatibility-with-Python-3.14.0a1-848.patch

346ca4
From d33028e43b814615a33e231925eaddb0f679fa2b Mon Sep 17 00:00:00 2001
346ca4
From: Karolina Surma <33810531+befeleme@users.noreply.github.com>
346ca4
Date: Fri, 15 Nov 2024 04:53:12 +0100
346ca4
Subject: [PATCH] Fix compatibility with Python 3.14.0a1 (#848)
346ca4
346ca4
typing.ByteString has been removed from Python 3.14.
346ca4
Ported the suggested way from the documentation:
346ca4
https://docs.python.org/3.13/library/typing.html#typing.ByteString
346ca4
---
346ca4
 src/nacl/bindings/crypto_secretstream.py | 3 ++-
346ca4
 tests/test_secretstream.py               | 3 ++-
346ca4
 2 files changed, 4 insertions(+), 2 deletions(-)
346ca4
346ca4
diff --git a/src/nacl/bindings/crypto_secretstream.py b/src/nacl/bindings/crypto_secretstream.py
346ca4
index d7c6725..59b074c 100644
346ca4
--- a/src/nacl/bindings/crypto_secretstream.py
346ca4
+++ b/src/nacl/bindings/crypto_secretstream.py
346ca4
@@ -11,7 +11,7 @@
346ca4
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
346ca4
 # See the License for the specific language governing permissions and
346ca4
 # limitations under the License.
346ca4
-from typing import ByteString, Optional, Tuple, cast
346ca4
+from typing import Optional, Tuple, Union, cast
346ca4
 
346ca4
 from nacl import exceptions as exc
346ca4
 from nacl._sodium import ffi, lib
346ca4
@@ -73,6 +73,7 @@ class crypto_secretstream_xchacha20poly1305_state:
346ca4
 
346ca4
     def __init__(self) -> None:
346ca4
         """Initialize a clean state object."""
346ca4
+        ByteString = Union[bytes, bytearray, memoryview]
346ca4
         self.statebuf: ByteString = ffi.new(
346ca4
             "unsigned char[]",
346ca4
             crypto_secretstream_xchacha20poly1305_STATEBYTES,
346ca4
diff --git a/tests/test_secretstream.py b/tests/test_secretstream.py
346ca4
index d1b7273..9a847bb 100644
346ca4
--- a/tests/test_secretstream.py
346ca4
+++ b/tests/test_secretstream.py
346ca4
@@ -16,7 +16,7 @@ import binascii
346ca4
 import json
346ca4
 import os
346ca4
 import random
346ca4
-from typing import ByteString, List, Optional, Tuple
346ca4
+from typing import List, Optional, Tuple, Union
346ca4
 
346ca4
 from _pytest._code import ExceptionInfo
346ca4
 from _pytest.monkeypatch import MonkeyPatch
346ca4
@@ -219,6 +219,7 @@ def test_it_like_libsodium():
346ca4
 
346ca4
     header = crypto_secretstream_xchacha20poly1305_init_push(state, k)
346ca4
 
346ca4
+    ByteString = Union[bytes, bytearray, memoryview]
346ca4
     state_save: ByteString = ffi.buffer(state.statebuf)[:]
346ca4
 
346ca4
     c1 = crypto_secretstream_xchacha20poly1305_push(
346ca4
-- 
346ca4
2.47.0
346ca4