Skip to content

Commit 523a8df

Browse files
Fix patching of removed URLopener class in Python 3.14
The class urllib.request.URLopener has been removed in Python 3.14: python/cpython#125739 Because of this, trying to run the tests in `test__greenness.py` fails with the following on Python 3.14: ``` ERROR tests/test__greenness.py - NameError: name 'URLopener' is not defined ``` Update the patching so that we only do it for Python versions lower than 3.14.
1 parent e470c1f commit 523a8df

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

eventlet/green/urllib/request.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
from eventlet import patcher
24
from eventlet.green import ftplib, http, os, socket, time
35
from eventlet.green.http import client as http_client
@@ -37,7 +39,12 @@
3739
del ftplib
3840

3941
FTPHandler.ftp_open = patcher.patch_function(FTPHandler.ftp_open, *to_patch_in_functions)
40-
URLopener.open_ftp = patcher.patch_function(URLopener.open_ftp, *to_patch_in_functions)
42+
43+
if sys.version_info < (3, 14):
44+
URLopener.open_ftp = patcher.patch_function(URLopener.open_ftp, *to_patch_in_functions)
45+
else:
46+
# Removed in python3.14+, nothing to do
47+
pass
4148

4249
ftperrors = patcher.patch_function(ftperrors, *to_patch_in_functions)
4350

0 commit comments

Comments
 (0)