Skip to content

Commit e7af412

Browse files
authored
Merge branch 'main' into run-test-suite-with-warnings-as-error
2 parents 5886785 + d05140f commit e7af412

25 files changed

+715
-412
lines changed

Doc/library/importlib.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,15 @@ ABC hierarchy::
380380

381381
.. class:: ResourceLoader
382382

383+
*Superseded by TraversableResources*
384+
383385
An abstract base class for a :term:`loader` which implements the optional
384386
:pep:`302` protocol for loading arbitrary resources from the storage
385387
back-end.
386388

387389
.. deprecated:: 3.7
388390
This ABC is deprecated in favour of supporting resource loading
389-
through :class:`importlib.resources.abc.ResourceReader`.
391+
through :class:`importlib.resources.abc.TraversableResources`.
390392

391393
.. abstractmethod:: get_data(path)
392394

Include/internal/pycore_gc.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ static inline PyObject* _Py_FROM_GC(PyGC_Head *gc) {
4545
* the per-object lock.
4646
*/
4747
#ifdef Py_GIL_DISABLED
48-
# define _PyGC_BITS_TRACKED (1) // Tracked by the GC
49-
# define _PyGC_BITS_FINALIZED (2) // tp_finalize was called
50-
# define _PyGC_BITS_UNREACHABLE (4)
51-
# define _PyGC_BITS_FROZEN (8)
52-
# define _PyGC_BITS_SHARED (16)
53-
# define _PyGC_BITS_DEFERRED (64) // Use deferred reference counting
48+
# define _PyGC_BITS_TRACKED (1<<0) // Tracked by the GC
49+
# define _PyGC_BITS_FINALIZED (1<<1) // tp_finalize was called
50+
# define _PyGC_BITS_UNREACHABLE (1<<2)
51+
# define _PyGC_BITS_FROZEN (1<<3)
52+
# define _PyGC_BITS_SHARED (1<<4)
53+
# define _PyGC_BITS_ALIVE (1<<5) // Reachable from a known root.
54+
# define _PyGC_BITS_DEFERRED (1<<6) // Use deferred reference counting
5455
#endif
5556

5657
#ifdef Py_GIL_DISABLED
@@ -330,6 +331,9 @@ struct _gc_runtime_state {
330331
collections, and are awaiting to undergo a full collection for
331332
the first time. */
332333
Py_ssize_t long_lived_pending;
334+
335+
/* True if gc.freeze() has been used. */
336+
int freeze_active;
333337
#endif
334338
};
335339

Include/internal/pycore_object.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *op, Py_ssize_t extra);
299299
extern int _PyType_CheckConsistency(PyTypeObject *type);
300300
extern int _PyDict_CheckConsistency(PyObject *mp, int check_content);
301301

302-
/* Update the Python traceback of an object. This function must be called
303-
when a memory block is reused from a free list.
304-
305-
Internal function called by _Py_NewReference(). */
306-
extern int _PyTraceMalloc_TraceRef(PyObject *op, PyRefTracerEvent event, void*);
307-
308302
// Fast inlined version of PyType_HasFeature()
309303
static inline int
310304
_PyType_HasFeature(PyTypeObject *type, unsigned long feature) {

Include/internal/pycore_tracemalloc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct _PyTraceMalloc_Config {
2525
} initialized;
2626

2727
/* Is tracemalloc tracing memory allocations?
28-
Variable protected by the GIL */
28+
Variable protected by the TABLES_LOCK(). */
2929
int tracing;
3030

3131
/* limit of the number of frames in a traceback, 1 by default.
@@ -85,14 +85,14 @@ struct _tracemalloc_runtime_state {
8585
size_t peak_traced_memory;
8686
/* Hash table used as a set to intern filenames:
8787
PyObject* => PyObject*.
88-
Protected by the GIL */
88+
Protected by the TABLES_LOCK(). */
8989
_Py_hashtable_t *filenames;
9090
/* Buffer to store a new traceback in traceback_new().
91-
Protected by the GIL. */
91+
Protected by the TABLES_LOCK(). */
9292
struct tracemalloc_traceback *traceback;
9393
/* Hash table used as a set to intern tracebacks:
9494
traceback_t* => traceback_t*
95-
Protected by the GIL */
95+
Protected by the TABLES_LOCK(). */
9696
_Py_hashtable_t *tracebacks;
9797
/* pointer (void*) => trace (trace_t*).
9898
Protected by TABLES_LOCK(). */
@@ -144,7 +144,7 @@ extern PyObject* _PyTraceMalloc_GetTraces(void);
144144
extern PyObject* _PyTraceMalloc_GetObjectTraceback(PyObject *obj);
145145

146146
/* Initialize tracemalloc */
147-
extern int _PyTraceMalloc_Init(void);
147+
extern PyStatus _PyTraceMalloc_Init(void);
148148

149149
/* Start tracemalloc */
150150
extern int _PyTraceMalloc_Start(int max_nframe);

Lib/importlib/abc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self):
7474
import warnings
7575
warnings.warn('importlib.abc.ResourceLoader is deprecated in '
7676
'favour of supporting resource loading through '
77-
'importlib.resources.abc.ResourceReader.',
77+
'importlib.resources.abc.TraversableResources.',
7878
DeprecationWarning, stacklevel=2)
7979
super().__init__()
8080

Lib/opcode.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
EXTENDED_ARG = opmap['EXTENDED_ARG']
1818

1919
opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
20-
for op, i in opmap.items():
21-
opname[i] = op
20+
for m in (opmap, _specialized_opmap):
21+
for op, i in m.items():
22+
opname[i] = op
2223

2324
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
2425

Lib/test/test__opcode.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ def test_is_valid(self):
3838
opcodes = [dis.opmap[opname] for opname in names]
3939
self.check_bool_function_result(_opcode.is_valid, opcodes, True)
4040

41+
def test_opmaps(self):
42+
def check_roundtrip(name, map):
43+
return self.assertEqual(opcode.opname[map[name]], name)
44+
45+
check_roundtrip('BINARY_OP', opcode.opmap)
46+
check_roundtrip('BINARY_OP_ADD_INT', opcode._specialized_opmap)
47+
4148
def test_oplists(self):
4249
def check_function(self, func, expected):
4350
for op in [-10, 520]:

Lib/test/test_cmd_line_script.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ def test_syntaxerror_invalid_escape_sequence_multi_line(self):
659659
stderr.splitlines()[-3:],
660660
[ b' foo = """\\q"""',
661661
b' ^^^^^^^^',
662-
b'SyntaxError: invalid escape sequence \'\\q\''
662+
b'SyntaxError: "\\q" is an invalid escape sequence. '
663+
b'Did you mean "\\\\q"? A raw string is also an option.'
663664
],
664665
)
665666

Lib/test/test_codeop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def test_warning(self):
282282
# Test that the warning is only returned once.
283283
with warnings_helper.check_warnings(
284284
('"is" with \'str\' literal', SyntaxWarning),
285-
("invalid escape sequence", SyntaxWarning),
285+
('"\\\\e" is an invalid escape sequence', SyntaxWarning),
286286
) as w:
287287
compile_command(r"'\e' is 0")
288288
self.assertEqual(len(w.warnings), 2)

Lib/test/test_dis.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,12 +999,14 @@ def test_boundaries(self):
999999
def test_widths(self):
10001000
long_opcodes = set(['JUMP_BACKWARD_NO_INTERRUPT',
10011001
'INSTRUMENTED_CALL_FUNCTION_EX'])
1002-
for opcode, opname in enumerate(dis.opname):
1002+
for op, opname in enumerate(dis.opname):
10031003
if opname in long_opcodes or opname.startswith("INSTRUMENTED"):
10041004
continue
1005+
if opname in opcode._specialized_opmap:
1006+
continue
10051007
with self.subTest(opname=opname):
10061008
width = dis._OPNAME_WIDTH
1007-
if opcode in dis.hasarg:
1009+
if op in dis.hasarg:
10081010
width += 1 + dis._OPARG_WIDTH
10091011
self.assertLessEqual(len(opname), width)
10101012

0 commit comments

Comments
 (0)