Add support for Python 3.14.0-alpha1

This commit is contained in:
Val Lorentz 2024-12-20 07:58:40 +01:00 committed by GitHub
parent ab25c3e039
commit e57f7ebc2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 24 deletions

View File

@ -15,6 +15,10 @@ jobs:
strategy:
matrix:
include:
- python-version: "3.14.0-alpha.1"
with-opt-deps: true
runs-on: ubuntu-22.04
- python-version: "3.13.0"
with-opt-deps: true
runs-on: ubuntu-22.04

View File

@ -1355,13 +1355,9 @@ class CommandProcess(world.SupyProcess):
pn,
cn)
log.debug('Spawning process %s (args: %r)', procName, args)
self.__parent = super(CommandProcess, self)
self.__parent.__init__(target=target, name=procName,
super().__init__(target=target, name=procName,
args=args, kwargs=kwargs)
def run(self):
self.__parent.run()
class CanonicalString(registry.NormalizedString):
def normalize(self, s):
return canonicalName(s)

View File

@ -88,6 +88,20 @@ def _rlimit_min(a, b):
else:
return min(soft, heap_size)
def _process_target(f, q, heap_size, *args, **kwargs):
"""Called by :func:`process`"""
if resource:
rsrc = resource.RLIMIT_DATA
(soft, hard) = resource.getrlimit(rsrc)
soft = _rlimit_min(soft, heap_size)
hard = _rlimit_min(hard, heap_size)
resource.setrlimit(rsrc, (soft, hard))
try:
r = f(*args, **kwargs)
q.put([False, r])
except Exception as e:
q.put([True, e])
def process(f, *args, **kwargs):
"""Runs a function <f> in a subprocess.
@ -122,20 +136,8 @@ def process(f, *args, **kwargs):
'(See https://github.com/travis-ci/travis-core/issues/187\n'
'for more information about this bug.)\n')
raise
def newf(f, q, *args, **kwargs):
if resource:
rsrc = resource.RLIMIT_DATA
(soft, hard) = resource.getrlimit(rsrc)
soft = _rlimit_min(soft, heap_size)
hard = _rlimit_min(hard, heap_size)
resource.setrlimit(rsrc, (soft, hard))
try:
r = f(*args, **kwargs)
q.put([False, r])
except Exception as e:
q.put([True, e])
targetArgs = (f, q,) + args
p = callbacks.CommandProcess(target=newf,
targetArgs = (f, q, heap_size) + args
p = callbacks.CommandProcess(target=_process_target,
args=targetArgs, kwargs=kwargs)
try:
p.start()

View File

@ -154,8 +154,16 @@ class SafeEvalVisitor(ast.NodeVisitor):
return self.visit(node.body)
def visit_Num(self, node):
"""Python < 3.14 only"""
return self._convert_num(node.n)
def visit_Constant(self, node):
"""Python >= 3.14 only"""
if type(node.value) in (float, complex, int):
return self._convert_num(node.value)
else:
raise InvalidNode('illegal constant %s' % node.value)
def visit_Name(self, node):
id_ = node.id.lower()
if id_ in self._env:

View File

@ -307,9 +307,9 @@ def perlReToReplacer(s):
flags = ''.join(flags)
r = perlReToPythonRe(sep.join(('', regexp, flags)))
if g:
return lambda s: r.sub(replace, s)
return functools.partial(r.sub, replace)
else:
return lambda s: r.sub(replace, s, 1)
return functools.partial(r.sub, replace, count=1)
_perlVarSubstituteRe = re.compile(r'\$\{([^}]+)\}|\$([a-zA-Z][a-zA-Z0-9]*)')
def perlVariableSubstitute(vars, text):

View File

@ -65,7 +65,7 @@ class SupyThread(threading.Thread, object):
log.debug('Spawning thread %q.', self.getName())
processesSpawned = 1 # Starts at one for the initial process.
class SupyProcess(multiprocessing.Process):
class SupyProcess(multiprocessing.get_context('fork').Process):
def __init__(self, *args, **kwargs):
global processesSpawned
processesSpawned += 1