Skip to content

Commit 677fb6e

Browse files
committed
Catch up with main
2 parents 6b2428d + de2a73d commit 677fb6e

39 files changed

+146
-69
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Programs/test_frozenmain.h generated
9595
Python/Python-ast.c generated
9696
Python/executor_cases.c.h generated
9797
Python/generated_cases.c.h generated
98-
Python/tier2_redundancy_eliminator_cases.c.h generated
98+
Python/optimizer_cases.c.h generated
9999
Python/opcode_targets.h generated
100100
Python/stdlib_module_names.h generated
101101
Tools/peg_generator/pegen/grammar_parser.py generated

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Python/ast_opt.c @isidentical
3838
Python/bytecodes.c @markshannon @gvanrossum
3939
Python/optimizer*.c @markshannon @gvanrossum
4040
Python/optimizer_analysis.c @Fidget-Spinner
41-
Python/tier2_redundancy_eliminator_bytecodes.c @Fidget-Spinner
41+
Python/optimizer_bytecodes.c @Fidget-Spinner
4242
Lib/test/test_patma.py @brandtbucher
4343
Lib/test/test_type_*.py @JelleZijlstra
4444
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum

.github/workflows/jit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
- '**jit**'
66
- 'Python/bytecodes.c'
77
- 'Python/optimizer*.c'
8-
- 'Python/tier2_redundancy_eliminator_bytecodes.c'
8+
- 'Python/optimizer_bytecodes.c'
99
push:
1010
paths:
1111
- '**jit**'
1212
- 'Python/bytecodes.c'
1313
- 'Python/optimizer*.c'
14-
- 'Python/tier2_redundancy_eliminator_bytecodes.c'
14+
- 'Python/optimizer_bytecodes.c'
1515
workflow_dispatch:
1616

1717
concurrency:

Include/cpython/optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ void _Py_ExecutorClear(_PyExecutorObject *);
100100
void _Py_BloomFilter_Init(_PyBloomFilter *);
101101
void _Py_BloomFilter_Add(_PyBloomFilter *bloom, void *obj);
102102
PyAPI_FUNC(void) _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj);
103-
PyAPI_FUNC(void) _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj);
104-
extern void _Py_Executors_InvalidateAll(PyInterpreterState *interp);
103+
PyAPI_FUNC(void) _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is_invalidation);
104+
extern void _Py_Executors_InvalidateAll(PyInterpreterState *interp, int is_invalidation);
105105

106106
/* For testing */
107107
PyAPI_FUNC(PyObject *)PyUnstable_Optimizer_NewCounter(void);

Include/cpython/pystats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ typedef struct _optimization_stats {
115115
uint64_t inner_loop;
116116
uint64_t recursive_call;
117117
uint64_t low_confidence;
118+
uint64_t executors_invalidated;
118119
UOpStats opcode[512];
119120
uint64_t unsupported_opcode[256];
120121
uint64_t trace_length_hist[_Py_UOP_HIST_SIZE];

Lib/argparse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ def _get_help_string(self, action):
708708
if action.default is not SUPPRESS:
709709
defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
710710
if action.option_strings or action.nargs in defaulting_nargs:
711-
help += ' (default: %(default)s)'
711+
help += _(' (default: %(default)s)')
712712
return help
713713

714714

@@ -1159,8 +1159,10 @@ def __init__(self,
11591159
version=None,
11601160
dest=SUPPRESS,
11611161
default=SUPPRESS,
1162-
help="show program's version number and exit",
1162+
help=None,
11631163
deprecated=False):
1164+
if help is None:
1165+
help = _("show program's version number and exit")
11641166
super(_VersionAction, self).__init__(
11651167
option_strings=option_strings,
11661168
dest=dest,

Lib/inspect.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,18 +762,14 @@ def unwrap(func, *, stop=None):
762762
:exc:`ValueError` is raised if a cycle is encountered.
763763
764764
"""
765-
if stop is None:
766-
def _is_wrapper(f):
767-
return hasattr(f, '__wrapped__')
768-
else:
769-
def _is_wrapper(f):
770-
return hasattr(f, '__wrapped__') and not stop(f)
771765
f = func # remember the original func for error reporting
772766
# Memoise by id to tolerate non-hashable objects, but store objects to
773767
# ensure they aren't destroyed, which would allow their IDs to be reused.
774768
memo = {id(f): f}
775769
recursion_limit = sys.getrecursionlimit()
776-
while _is_wrapper(func):
770+
while not isinstance(func, type) and hasattr(func, '__wrapped__'):
771+
if stop is not None and stop(func):
772+
break
777773
func = func.__wrapped__
778774
id_func = id(func)
779775
if (id_func in memo) or (len(memo) >= recursion_limit):

Lib/pydoc.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,9 @@ def docmodule(self, object, name=None, mod=None, *ignored):
855855
cdict[key] = cdict[base] = modname + '.html#' + key
856856
funcs, fdict = [], {}
857857
for key, value in inspect.getmembers(object, inspect.isroutine):
858-
# if __all__ exists, believe it. Otherwise use old heuristic.
859-
if (all is not None or
860-
inspect.isbuiltin(value) or inspect.getmodule(value) is object):
858+
# if __all__ exists, believe it. Otherwise use a heuristic.
859+
if (all is not None
860+
or (inspect.getmodule(value) or object) is object):
861861
if visiblename(key, all, object):
862862
funcs.append((key, value))
863863
fdict[key] = '#-' + key
@@ -1299,9 +1299,9 @@ def docmodule(self, object, name=None, mod=None, *ignored):
12991299
classes.append((key, value))
13001300
funcs = []
13011301
for key, value in inspect.getmembers(object, inspect.isroutine):
1302-
# if __all__ exists, believe it. Otherwise use old heuristic.
1303-
if (all is not None or
1304-
inspect.isbuiltin(value) or inspect.getmodule(value) is object):
1302+
# if __all__ exists, believe it. Otherwise use a heuristic.
1303+
if (all is not None
1304+
or (inspect.getmodule(value) or object) is object):
13051305
if visiblename(key, all, object):
13061306
funcs.append((key, value))
13071307
data = []

Lib/test/test_generated_cases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def skip_if_different_mount_drives():
3333
import parser
3434
from stack import Stack
3535
import tier1_generator
36-
import tier2_abstract_generator
36+
import optimizer_generator
3737

3838

3939
def handle_stderr():
@@ -841,7 +841,7 @@ def run_cases_test(self, input: str, input2: str, expected: str):
841841
temp_input.flush()
842842

843843
with handle_stderr():
844-
tier2_abstract_generator.generate_tier2_abstract_from_files(
844+
optimizer_generator.generate_tier2_abstract_from_files(
845845
[self.temp_input_filename, self.temp_input2_filename],
846846
self.temp_output_filename
847847
)

Lib/test/test_inspect/test_inspect.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,6 +3137,10 @@ def m1d(*args, **kwargs):
31373137
int))
31383138

31393139
def test_signature_on_classmethod(self):
3140+
self.assertEqual(self.signature(classmethod),
3141+
((('function', ..., ..., "positional_only"),),
3142+
...))
3143+
31403144
class Test:
31413145
@classmethod
31423146
def foo(cls, arg1, *, arg2=1):
@@ -3155,6 +3159,10 @@ def foo(cls, arg1, *, arg2=1):
31553159
...))
31563160

31573161
def test_signature_on_staticmethod(self):
3162+
self.assertEqual(self.signature(staticmethod),
3163+
((('function', ..., ..., "positional_only"),),
3164+
...))
3165+
31583166
class Test:
31593167
@staticmethod
31603168
def foo(cls, *, arg):
@@ -3678,16 +3686,20 @@ class Bar(Spam, Foo):
36783686
((('a', ..., ..., "positional_or_keyword"),),
36793687
...))
36803688

3681-
class Wrapped:
3682-
pass
3683-
Wrapped.__wrapped__ = lambda a: None
3684-
self.assertEqual(self.signature(Wrapped),
3689+
def test_signature_on_wrapper(self):
3690+
class Wrapper:
3691+
def __call__(self, b):
3692+
pass
3693+
wrapper = Wrapper()
3694+
wrapper.__wrapped__ = lambda a: None
3695+
self.assertEqual(self.signature(wrapper),
36853696
((('a', ..., ..., "positional_or_keyword"),),
36863697
...))
36873698
# wrapper loop:
3688-
Wrapped.__wrapped__ = Wrapped
3699+
wrapper = Wrapper()
3700+
wrapper.__wrapped__ = wrapper
36893701
with self.assertRaisesRegex(ValueError, 'wrapper loop'):
3690-
self.signature(Wrapped)
3702+
self.signature(wrapper)
36913703

36923704
def test_signature_on_lambdas(self):
36933705
self.assertEqual(self.signature((lambda a=10: a)),
@@ -4999,6 +5011,14 @@ def test_recursion_limit(self):
49995011
with self.assertRaisesRegex(ValueError, 'wrapper loop'):
50005012
inspect.unwrap(obj)
50015013

5014+
def test_wrapped_descriptor(self):
5015+
self.assertIs(inspect.unwrap(NTimesUnwrappable), NTimesUnwrappable)
5016+
self.assertIs(inspect.unwrap(staticmethod), staticmethod)
5017+
self.assertIs(inspect.unwrap(classmethod), classmethod)
5018+
self.assertIs(inspect.unwrap(staticmethod(classmethod)), classmethod)
5019+
self.assertIs(inspect.unwrap(classmethod(staticmethod)), staticmethod)
5020+
5021+
50025022
class TestMain(unittest.TestCase):
50035023
def test_only_source(self):
50045024
module = importlib.import_module('unittest')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy