-
-
Notifications
You must be signed in to change notification settings - Fork 91
typing.Bytes string will be removed in Python 3.14 #238
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
Comments
Just got the same filed downstream in Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=2326925 . Our Python maintainers caught this, too. |
Python 3.13 |
diff -up zstandard-0.23.0/zstandard/__init__.py.py314 zstandard-0.23.0/zstandard/__init__.py
--- zstandard-0.23.0/zstandard/__init__.py.py314 2024-07-14 23:58:50.000000000 +0200
+++ zstandard-0.23.0/zstandard/__init__.py 2025-03-28 17:16:47.339256930 +0100
@@ -18,7 +18,10 @@ import io
import os
import platform
-from typing import ByteString
+try:
+ from typing import ByteString
+except ImportError:
+ from collections.abc import Buffer as ByteString
# Some Python implementations don't support C extensions. That's why we have
# a CFFI implementation in the first place. The code here import one of our The above patch makes it build with Python 3.14a6. @indygreg shall I submit a PR? |
@rathann Yes please, that would be very helpful! My only recommendation would be to not catch an exception in the new common case and instead use a conditional: if sys.version_info >= (3, 12):
from collections.abc import Buffer
else:
from typing import ByteString as Buffer |
`ByteString` was [deprecated](https://docs.python.org/3.12/whatsnew/3.12.html#deprecated) in Python 3.12 and [removed](https://docs.python.org/3.14/whatsnew/3.14.html#collections-abc) in 3.14. `collections.abc.Buffer` is available since Python 3.12. Fixes indygreg#238 .
`ByteString` was [deprecated](https://docs.python.org/3.12/whatsnew/3.12.html#deprecated) in Python 3.12 and [removed](https://docs.python.org/3.14/whatsnew/3.14.html#collections-abc) in 3.14. `collections.abc.Buffer` is available since Python 3.12. Fixes indygreg#238 .
I was trying to use this module in Python 3.14.0-alpha.0, and encountered this error:
Looking at the changelog, it seems that
typing.ByteString
has been removed.The text was updated successfully, but these errors were encountered: