Skip to content

Commit 235e7b2

Browse files
authored
bpo-36465: Fix test_regrtest on Windows (GH-12945)
Fix Py_DEBUG constant: check for sys.gettotalrefcount attribute rather than sys.getobjects. Update also SpecialBuilds.txt documentation.
1 parent f4e4703 commit 235e7b2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Lib/test/test_regrtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from test.libregrtest import utils
2222

2323

24-
Py_DEBUG = hasattr(sys, 'getobjects')
24+
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
2525
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
2626
ROOT_DIR = os.path.abspath(os.path.normpath(ROOT_DIR))
2727

Misc/SpecialBuilds.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ name "_" holds a reference to the last result displayed!
3030
Py_REF_DEBUG also checks after every decref to verify that the refcount hasn't
3131
gone negative, and causes an immediate fatal error if it has.
3232

33+
Py_DEBUG implies Py_REF_DEBUG.
34+
3335
Special gimmicks:
3436

3537
sys.gettotalrefcount()
@@ -39,6 +41,8 @@ sys.gettotalrefcount()
3941
Py_TRACE_REFS
4042
-------------
4143

44+
Build option: ``./configure --with-trace-refs``.
45+
4246
Turn on heavy reference debugging. This is major surgery. Every PyObject grows
4347
two more pointers, to maintain a doubly-linked list of all live heap-allocated
4448
objects. Most built-in type objects are not in this list, as they're statically
@@ -49,8 +53,6 @@ has been created.
4953
Note that because the fundamental PyObject layout changes, Python modules
5054
compiled with Py_TRACE_REFS are incompatible with modules compiled without it.
5155

52-
Py_TRACE_REFS implies Py_REF_DEBUG.
53-
5456
Special gimmicks:
5557

5658
sys.getobjects(max[, type])
@@ -138,7 +140,8 @@ look at the object, you're likely to see that it's entirely filled with 0xDB
138140
(meaning freed memory is getting used) or 0xCB (meaning uninitialized memory is
139141
getting used).
140142

141-
Note that PYMALLOC_DEBUG requires WITH_PYMALLOC.
143+
Note that PYMALLOC_DEBUG requires WITH_PYMALLOC. Py_DEBUG implies
144+
PYMALLOC_DEBUG (if WITH_PYMALLOC is enabled).
142145

143146
Special gimmicks:
144147

@@ -156,7 +159,7 @@ Py_DEBUG
156159

157160
This is what is generally meant by "a debug build" of Python.
158161

159-
Py_DEBUG implies LLTRACE, Py_REF_DEBUG, Py_TRACE_REFS, and PYMALLOC_DEBUG (if
162+
Py_DEBUG implies LLTRACE, Py_REF_DEBUG, and PYMALLOC_DEBUG (if
160163
WITH_PYMALLOC is enabled). In addition, C assert()s are enabled (via the C way:
161164
by not defining NDEBUG), and some routines do additional sanity checks inside
162165
"#ifdef Py_DEBUG" blocks.
@@ -223,3 +226,5 @@ the interpreter is doing are sprayed to stdout, such as every opcode and opcode
223226
argument and values pushed onto and popped off the value stack.
224227

225228
Not useful very often, but very useful when needed.
229+
230+
Py_DEBUG implies LLTRACE.

0 commit comments

Comments
 (0)