Skip to content

Commit d0937ca

Browse files
[Backport 8.15] Add explicit Python 3.13 support (#189)
(cherry picked from commit 6c27e2c) Co-authored-by: Quentin Pradet <[email protected]>
1 parent 71a12b8 commit d0937ca

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Checkout repository
1111
uses: actions/checkout@v1
1212
- name: Set up Python 3.x
13-
uses: actions/setup-python@v4
13+
uses: actions/setup-python@v5
1414
with:
1515
python-version: 3.x
1616
- name: Install dependencies
@@ -24,7 +24,7 @@ jobs:
2424
- name: Checkout Repository
2525
uses: actions/checkout@v1
2626
- name: Set up Python 3.x
27-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2828
with:
2929
python-version: 3.x
3030
- name: Install dependencies
@@ -40,7 +40,7 @@ jobs:
4040
strategy:
4141
fail-fast: false
4242
matrix:
43-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
43+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
4444
os: ["ubuntu-latest"]
4545
experimental: [false]
4646
nox-session: ['']
@@ -58,14 +58,10 @@ jobs:
5858
uses: actions/checkout@v2
5959

6060
- name: Set up Python - ${{ matrix.python-version }}
61-
uses: actions/setup-python@v2
61+
uses: actions/setup-python@v5
6262
with:
6363
python-version: ${{ matrix.python-version }}
64-
65-
- name: Set up Python 3.x to run nox
66-
uses: actions/setup-python@v2
67-
with:
68-
python-version: 3.x
64+
allow-prereleases: true
6965

7066
- name: Install Dependencies
7167
run: python -m pip install --upgrade nox

elastic_transport/_node/_http_aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async def perform_request( # type: ignore[override]
182182
data=body_to_send,
183183
headers=request_headers,
184184
timeout=aiohttp_timeout,
185-
**kwargs,
185+
**kwargs, # type: ignore[arg-type]
186186
) as response:
187187
if is_head: # We actually called 'GET' so throw away the data.
188188
await response.release()

elastic_transport/_node/_http_urllib3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def perform_request(
199199
body=body,
200200
exception=err,
201201
)
202-
raise err from None
202+
raise err from e
203203

204204
meta = ApiResponseMeta(
205205
node=self.config,

elastic_transport/_node/_urllib3_chain_certs.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,20 @@ def _validate_conn(self, conn: HTTPSConnection) -> None: # type: ignore[overrid
105105

106106
fingerprints: List[bytes]
107107
try:
108-
# 'get_verified_chain()' and 'Certificate.public_bytes()' are private APIs
109-
# in CPython 3.10. They're not documented anywhere yet but seem to work
110-
# and we need them for Security on by Default so... onwards we go!
111-
# See: https://github.com/python/cpython/pull/25467
112-
fingerprints = [
113-
hash_func(cert.public_bytes(_ENCODING_DER)).digest()
114-
for cert in conn.sock._sslobj.get_verified_chain() # type: ignore[union-attr]
115-
]
108+
if sys.version_info >= (3, 13):
109+
fingerprints = [
110+
hash_func(cert).digest()
111+
for cert in conn.sock.get_verified_chain()
112+
]
113+
else:
114+
# 'get_verified_chain()' and 'Certificate.public_bytes()' are private APIs
115+
# in CPython 3.10. They're not documented anywhere yet but seem to work
116+
# and we need them for Security on by Default so... onwards we go!
117+
# See: https://github.com/python/cpython/pull/25467
118+
fingerprints = [
119+
hash_func(cert.public_bytes(_ENCODING_DER)).digest()
120+
for cert in conn.sock._sslobj.get_verified_chain() # type: ignore[union-attr]
121+
]
116122
except RERAISE_EXCEPTIONS: # pragma: nocover
117123
raise
118124
# Because these are private APIs we are super careful here

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def lint(session):
5959
session.run("mypy", "--strict", "--show-error-codes", "elastic_transport/")
6060

6161

62-
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
62+
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"])
6363
def test(session):
6464
session.install(".[develop]")
6565
session.run(

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"Programming Language :: Python :: 3.10",
8989
"Programming Language :: Python :: 3.11",
9090
"Programming Language :: Python :: 3.12",
91+
"Programming Language :: Python :: 3.13",
9192
"Programming Language :: Python :: Implementation :: CPython",
9293
"Programming Language :: Python :: Implementation :: PyPy",
9394
],

0 commit comments

Comments
 (0)