Skip to content

Commit e57f7eb

Browse files
authored
Add support for Python 3.14.0-alpha1
1 parent ab25c3e commit e57f7eb

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

.github/workflows/test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
strategy:
1616
matrix:
1717
include:
18+
- python-version: "3.14.0-alpha.1"
19+
with-opt-deps: true
20+
runs-on: ubuntu-22.04
21+
1822
- python-version: "3.13.0"
1923
with-opt-deps: true
2024
runs-on: ubuntu-22.04

src/callbacks.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1355,12 +1355,8 @@ def __init__(self, target=None, args=(), kwargs={}):
13551355
pn,
13561356
cn)
13571357
log.debug('Spawning process %s (args: %r)', procName, args)
1358-
self.__parent = super(CommandProcess, self)
1359-
self.__parent.__init__(target=target, name=procName,
1360-
args=args, kwargs=kwargs)
1361-
1362-
def run(self):
1363-
self.__parent.run()
1358+
super().__init__(target=target, name=procName,
1359+
args=args, kwargs=kwargs)
13641360

13651361
class CanonicalString(registry.NormalizedString):
13661362
def normalize(self, s):

src/commands.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,20 @@ def _rlimit_min(a, b):
8888
else:
8989
return min(soft, heap_size)
9090

91+
def _process_target(f, q, heap_size, *args, **kwargs):
92+
"""Called by :func:`process`"""
93+
if resource:
94+
rsrc = resource.RLIMIT_DATA
95+
(soft, hard) = resource.getrlimit(rsrc)
96+
soft = _rlimit_min(soft, heap_size)
97+
hard = _rlimit_min(hard, heap_size)
98+
resource.setrlimit(rsrc, (soft, hard))
99+
try:
100+
r = f(*args, **kwargs)
101+
q.put([False, r])
102+
except Exception as e:
103+
q.put([True, e])
104+
91105
def process(f, *args, **kwargs):
92106
"""Runs a function <f> in a subprocess.
93107
@@ -122,21 +136,9 @@ def process(f, *args, **kwargs):
122136
'(See https://github.com/travis-ci/travis-core/issues/187\n'
123137
'for more information about this bug.)\n')
124138
raise
125-
def newf(f, q, *args, **kwargs):
126-
if resource:
127-
rsrc = resource.RLIMIT_DATA
128-
(soft, hard) = resource.getrlimit(rsrc)
129-
soft = _rlimit_min(soft, heap_size)
130-
hard = _rlimit_min(hard, heap_size)
131-
resource.setrlimit(rsrc, (soft, hard))
132-
try:
133-
r = f(*args, **kwargs)
134-
q.put([False, r])
135-
except Exception as e:
136-
q.put([True, e])
137-
targetArgs = (f, q,) + args
138-
p = callbacks.CommandProcess(target=newf,
139-
args=targetArgs, kwargs=kwargs)
139+
targetArgs = (f, q, heap_size) + args
140+
p = callbacks.CommandProcess(target=_process_target,
141+
args=targetArgs, kwargs=kwargs)
140142
try:
141143
p.start()
142144
except OSError as e:

src/utils/math_evaluator.py

+8
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,16 @@ def visit_Expression(self, node):
154154
return self.visit(node.body)
155155

156156
def visit_Num(self, node):
157+
"""Python < 3.14 only"""
157158
return self._convert_num(node.n)
158159

160+
def visit_Constant(self, node):
161+
"""Python >= 3.14 only"""
162+
if type(node.value) in (float, complex, int):
163+
return self._convert_num(node.value)
164+
else:
165+
raise InvalidNode('illegal constant %s' % node.value)
166+
159167
def visit_Name(self, node):
160168
id_ = node.id.lower()
161169
if id_ in self._env:

src/utils/str.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ def perlReToReplacer(s):
307307
flags = ''.join(flags)
308308
r = perlReToPythonRe(sep.join(('', regexp, flags)))
309309
if g:
310-
return lambda s: r.sub(replace, s)
310+
return functools.partial(r.sub, replace)
311311
else:
312-
return lambda s: r.sub(replace, s, 1)
312+
return functools.partial(r.sub, replace, count=1)
313313

314314
_perlVarSubstituteRe = re.compile(r'\$\{([^}]+)\}|\$([a-zA-Z][a-zA-Z0-9]*)')
315315
def perlVariableSubstitute(vars, text):

src/world.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, *args, **kwargs):
6565
log.debug('Spawning thread %q.', self.getName())
6666

6767
processesSpawned = 1 # Starts at one for the initial process.
68-
class SupyProcess(multiprocessing.Process):
68+
class SupyProcess(multiprocessing.get_context('fork').Process):
6969
def __init__(self, *args, **kwargs):
7070
global processesSpawned
7171
processesSpawned += 1

0 commit comments

Comments
 (0)