Skip to content

Commit 7eb1572

Browse files
authored
Merge branch 'main' into main
2 parents 86847e8 + 8320582 commit 7eb1572

File tree

14 files changed

+173
-189
lines changed

14 files changed

+173
-189
lines changed

Include/internal/pycore_interpframe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ static inline _PyStackRef *_PyFrame_Stackbase(_PyInterpreterFrame *f) {
4848
}
4949

5050
static inline _PyStackRef _PyFrame_StackPeek(_PyInterpreterFrame *f) {
51-
assert(f->stackpointer > f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
51+
assert(f->stackpointer > _PyFrame_Stackbase(f));
5252
assert(!PyStackRef_IsNull(f->stackpointer[-1]));
5353
return f->stackpointer[-1];
5454
}
5555

5656
static inline _PyStackRef _PyFrame_StackPop(_PyInterpreterFrame *f) {
57-
assert(f->stackpointer > f->localsplus + _PyFrame_GetCode(f)->co_nlocalsplus);
57+
assert(f->stackpointer > _PyFrame_Stackbase(f));
5858
f->stackpointer--;
5959
return *f->stackpointer;
6060
}

Lib/compression/zstd/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_frame_info(frame_buffer):
7171
the frame may or may not need a dictionary to be decoded,
7272
and the ID of such a dictionary is not specified.
7373
"""
74-
return FrameInfo(*_zstd._get_frame_info(frame_buffer))
74+
return FrameInfo(*_zstd.get_frame_info(frame_buffer))
7575

7676

7777
def train_dict(samples, dict_size):
@@ -91,7 +91,7 @@ def train_dict(samples, dict_size):
9191
chunk_sizes = tuple(_nbytes(sample) for sample in samples)
9292
if not chunks:
9393
raise ValueError("samples contained no data; can't train dictionary.")
94-
dict_content = _zstd._train_dict(chunks, chunk_sizes, dict_size)
94+
dict_content = _zstd.train_dict(chunks, chunk_sizes, dict_size)
9595
return ZstdDict(dict_content)
9696

9797

@@ -127,7 +127,7 @@ def finalize_dict(zstd_dict, /, samples, dict_size, level):
127127
if not chunks:
128128
raise ValueError("The samples are empty content, can't finalize the"
129129
"dictionary.")
130-
dict_content = _zstd._finalize_dict(zstd_dict.dict_content,
130+
dict_content = _zstd.finalize_dict(zstd_dict.dict_content,
131131
chunks, chunk_sizes,
132132
dict_size, level)
133133
return ZstdDict(dict_content)
@@ -201,7 +201,7 @@ def bounds(self):
201201
202202
Both the lower and upper bounds are inclusive.
203203
"""
204-
return _zstd._get_param_bounds(self.value, is_compress=True)
204+
return _zstd.get_param_bounds(self.value, is_compress=True)
205205

206206

207207
class DecompressionParameter(enum.IntEnum):
@@ -214,7 +214,7 @@ def bounds(self):
214214
215215
Both the lower and upper bounds are inclusive.
216216
"""
217-
return _zstd._get_param_bounds(self.value, is_compress=False)
217+
return _zstd.get_param_bounds(self.value, is_compress=False)
218218

219219

220220
class Strategy(enum.IntEnum):
@@ -237,4 +237,4 @@ class Strategy(enum.IntEnum):
237237

238238

239239
# Check validity of the CompressionParameter & DecompressionParameter types
240-
_zstd._set_parameter_types(CompressionParameter, DecompressionParameter)
240+
_zstd.set_parameter_types(CompressionParameter, DecompressionParameter)

Lib/compression/zstd/_zstdfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def __init__(self, file, /, mode="r", *,
8989
raw = _streams.DecompressReader(
9090
self._fp,
9191
ZstdDecompressor,
92-
trailing_error=ZstdError,
9392
zstd_dict=zstd_dict,
9493
options=options,
9594
)

Lib/inspect.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,13 +2074,11 @@ def _signature_is_functionlike(obj):
20742074
code = getattr(obj, '__code__', None)
20752075
defaults = getattr(obj, '__defaults__', _void) # Important to use _void ...
20762076
kwdefaults = getattr(obj, '__kwdefaults__', _void) # ... and not None here
2077-
annotations = getattr(obj, '__annotations__', None)
20782077

20792078
return (isinstance(code, types.CodeType) and
20802079
isinstance(name, str) and
20812080
(defaults is None or isinstance(defaults, tuple)) and
2082-
(kwdefaults is None or isinstance(kwdefaults, dict)) and
2083-
(isinstance(annotations, (dict)) or annotations is None) )
2081+
(kwdefaults is None or isinstance(kwdefaults, dict)))
20842082

20852083

20862084
def _signature_strip_non_python_syntax(signature):

Lib/test/test_inspect/test_inspect.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4997,6 +4997,37 @@ def test_signature_annotation_format(self):
49974997
with self.assertRaisesRegex(NameError, "undefined"):
49984998
signature_func(ida.f)
49994999

5000+
def test_signature_deferred_annotations(self):
5001+
def f(x: undef):
5002+
pass
5003+
5004+
class C:
5005+
x: undef
5006+
5007+
def __init__(self, x: undef):
5008+
self.x = x
5009+
5010+
sig = inspect.signature(f, annotation_format=Format.FORWARDREF)
5011+
self.assertEqual(list(sig.parameters), ['x'])
5012+
sig = inspect.signature(C, annotation_format=Format.FORWARDREF)
5013+
self.assertEqual(list(sig.parameters), ['x'])
5014+
5015+
class CallableWrapper:
5016+
def __init__(self, func):
5017+
self.func = func
5018+
self.__annotate__ = func.__annotate__
5019+
5020+
def __call__(self, *args, **kwargs):
5021+
return self.func(*args, **kwargs)
5022+
5023+
@property
5024+
def __annotations__(self):
5025+
return self.__annotate__(Format.VALUE)
5026+
5027+
cw = CallableWrapper(f)
5028+
sig = inspect.signature(cw, annotation_format=Format.FORWARDREF)
5029+
self.assertEqual(list(sig.parameters), ['args', 'kwargs'])
5030+
50005031
def test_signature_none_annotation(self):
50015032
class funclike:
50025033
# Has to be callable, and have correct

Lib/test/test_zstd.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,43 +1174,43 @@ def test_finalize_dict_arguments(self):
11741174
def test_train_dict_c(self):
11751175
# argument wrong type
11761176
with self.assertRaises(TypeError):
1177-
_zstd._train_dict({}, (), 100)
1177+
_zstd.train_dict({}, (), 100)
11781178
with self.assertRaises(TypeError):
1179-
_zstd._train_dict(b'', 99, 100)
1179+
_zstd.train_dict(b'', 99, 100)
11801180
with self.assertRaises(TypeError):
1181-
_zstd._train_dict(b'', (), 100.1)
1181+
_zstd.train_dict(b'', (), 100.1)
11821182

11831183
# size > size_t
11841184
with self.assertRaises(ValueError):
1185-
_zstd._train_dict(b'', (2**64+1,), 100)
1185+
_zstd.train_dict(b'', (2**64+1,), 100)
11861186

11871187
# dict_size <= 0
11881188
with self.assertRaises(ValueError):
1189-
_zstd._train_dict(b'', (), 0)
1189+
_zstd.train_dict(b'', (), 0)
11901190

11911191
def test_finalize_dict_c(self):
11921192
with self.assertRaises(TypeError):
1193-
_zstd._finalize_dict(1, 2, 3, 4, 5)
1193+
_zstd.finalize_dict(1, 2, 3, 4, 5)
11941194

11951195
# argument wrong type
11961196
with self.assertRaises(TypeError):
1197-
_zstd._finalize_dict({}, b'', (), 100, 5)
1197+
_zstd.finalize_dict({}, b'', (), 100, 5)
11981198
with self.assertRaises(TypeError):
1199-
_zstd._finalize_dict(TRAINED_DICT.dict_content, {}, (), 100, 5)
1199+
_zstd.finalize_dict(TRAINED_DICT.dict_content, {}, (), 100, 5)
12001200
with self.assertRaises(TypeError):
1201-
_zstd._finalize_dict(TRAINED_DICT.dict_content, b'', 99, 100, 5)
1201+
_zstd.finalize_dict(TRAINED_DICT.dict_content, b'', 99, 100, 5)
12021202
with self.assertRaises(TypeError):
1203-
_zstd._finalize_dict(TRAINED_DICT.dict_content, b'', (), 100.1, 5)
1203+
_zstd.finalize_dict(TRAINED_DICT.dict_content, b'', (), 100.1, 5)
12041204
with self.assertRaises(TypeError):
1205-
_zstd._finalize_dict(TRAINED_DICT.dict_content, b'', (), 100, 5.1)
1205+
_zstd.finalize_dict(TRAINED_DICT.dict_content, b'', (), 100, 5.1)
12061206

12071207
# size > size_t
12081208
with self.assertRaises(ValueError):
1209-
_zstd._finalize_dict(TRAINED_DICT.dict_content, b'', (2**64+1,), 100, 5)
1209+
_zstd.finalize_dict(TRAINED_DICT.dict_content, b'', (2**64+1,), 100, 5)
12101210

12111211
# dict_size <= 0
12121212
with self.assertRaises(ValueError):
1213-
_zstd._finalize_dict(TRAINED_DICT.dict_content, b'', (), 0, 5)
1213+
_zstd.finalize_dict(TRAINED_DICT.dict_content, b'', (), 0, 5)
12141214

12151215
def test_train_buffer_protocol_samples(self):
12161216
def _nbytes(dat):
@@ -1232,19 +1232,19 @@ def _nbytes(dat):
12321232
# wrong size list
12331233
with self.assertRaisesRegex(ValueError,
12341234
"The samples size tuple doesn't match the concatenation's size"):
1235-
_zstd._train_dict(concatenation, tuple(wrong_size_lst), 100*_1K)
1235+
_zstd.train_dict(concatenation, tuple(wrong_size_lst), 100*_1K)
12361236

12371237
# correct size list
1238-
_zstd._train_dict(concatenation, tuple(correct_size_lst), 3*_1K)
1238+
_zstd.train_dict(concatenation, tuple(correct_size_lst), 3*_1K)
12391239

12401240
# wrong size list
12411241
with self.assertRaisesRegex(ValueError,
12421242
"The samples size tuple doesn't match the concatenation's size"):
1243-
_zstd._finalize_dict(TRAINED_DICT.dict_content,
1243+
_zstd.finalize_dict(TRAINED_DICT.dict_content,
12441244
concatenation, tuple(wrong_size_lst), 300*_1K, 5)
12451245

12461246
# correct size list
1247-
_zstd._finalize_dict(TRAINED_DICT.dict_content,
1247+
_zstd.finalize_dict(TRAINED_DICT.dict_content,
12481248
concatenation, tuple(correct_size_lst), 300*_1K, 5)
12491249

12501250
def test_as_prefix(self):
@@ -1682,10 +1682,10 @@ def test_read_incomplete(self):
16821682

16831683
# Trailing data isn't a valid compressed stream
16841684
with ZstdFile(io.BytesIO(self.FRAME_42 + b'12345')) as f:
1685-
self.assertEqual(f.read(), self.DECOMPRESSED_42)
1685+
self.assertRaises(ZstdError, f.read)
16861686

16871687
with ZstdFile(io.BytesIO(SKIPPABLE_FRAME + b'12345')) as f:
1688-
self.assertEqual(f.read(), b'')
1688+
self.assertRaises(ZstdError, f.read)
16891689

16901690
def test_read_truncated(self):
16911691
# Drop stream epilogue: 4 bytes checksum

Misc/NEWS.d/3.14.0a1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ retrieve the spec information.
10331033
.. nonce: s3vKql
10341034
.. section: Library
10351035
1036-
:mod:`argparse` vim supports abbreviated single-dash long options separated
1036+
:mod:`argparse` supports abbreviated single-dash long options separated
10371037
by ``=`` from its value.
10381038

10391039
..
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Avoid accessing ``__annotations__`` unnecessarily in
2+
:func:`inspect.signature`.

0 commit comments

Comments
 (0)