Skip to content

Commit 6a9962d

Browse files
frenzymadnesschenx97
authored andcommitted
AOSCOS: fix python 3.14 support
SQUASHED UPSTREAM COMMITS: tools: make nodedownload module compatible with Python 3.14 FancyURLopener and URLopener have been deprecated since Python 3.3 and they are removed completely from 3.14. Fixes: nodejs#58740 PR-URL: nodejs#58752 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> build: test on Python 3.14 release candidate 3 Python v3.14 -- October 7th * https://www.python.org/download/pre-releases * https://www.python.org/downloads/release/python-3140rc3 PR-URL: nodejs#59983 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com> Reviewed-By: Stewart X Addison <sxa@redhat.com>
1 parent 6a530fe commit 6a9962d

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Note that the mix of single and double quotes is intentional,
55
# as is the fact that the ] goes on a new line.
66
_=[ 'exec' '/bin/sh' '-c' '''
7+
command -v python3.14 >/dev/null && exec python3.14 "$0" "$@"
78
command -v python3.13 >/dev/null && exec python3.13 "$0" "$@"
89
command -v python3.12 >/dev/null && exec python3.12 "$0" "$@"
910
command -v python3.11 >/dev/null && exec python3.11 "$0" "$@"
@@ -25,7 +26,7 @@ except ImportError:
2526
from distutils.spawn import find_executable as which
2627

2728
print('Node.js configure: Found Python {}.{}.{}...'.format(*sys.version_info))
28-
acceptable_pythons = ((3, 13), (3, 12), (3, 11), (3, 10), (3, 9), (3, 8), (3, 7), (3, 6))
29+
acceptable_pythons = ((3, 14), (3, 13), (3, 12), (3, 11), (3, 10), (3, 9))
2930
if sys.version_info[:2] in acceptable_pythons:
3031
import configure
3132
else:

tools/configure.d/nodedownload.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import zipfile
88
import tarfile
99
import contextlib
10-
try:
11-
from urllib.request import FancyURLopener, URLopener
12-
except ImportError:
13-
from urllib import FancyURLopener, URLopener
10+
from urllib.request import build_opener, install_opener, urlretrieve
1411

1512
def formatSize(amt):
1613
"""Format a size as a string in MB"""
@@ -21,11 +18,6 @@ def spin(c):
2118
spin = ".:|'"
2219
return (spin[c % len(spin)])
2320

24-
class ConfigOpener(FancyURLopener):
25-
"""fancy opener used by retrievefile. Set a UA"""
26-
# append to existing version (UA)
27-
version = '%s node.js/configure' % URLopener.version
28-
2921
def reporthook(count, size, total):
3022
"""internal hook used by retrievefile"""
3123
sys.stdout.write(' Fetch: %c %sMB total, %sMB downloaded \r' %
@@ -38,7 +30,10 @@ def retrievefile(url, targetfile):
3830
try:
3931
sys.stdout.write(' <%s>\nConnecting...\r' % url)
4032
sys.stdout.flush()
41-
ConfigOpener().retrieve(url, targetfile, reporthook=reporthook)
33+
opener = build_opener()
34+
opener.addheaders = [('User-agent', f'Python-urllib/{sys.version_info.major}.{sys.version_info.minor} node.js/configure')]
35+
install_opener(opener)
36+
urlretrieve(url, targetfile, reporthook=reporthook)
4237
print('') # clear the line
4338
return targetfile
4439
except IOError as err:

0 commit comments

Comments
 (0)