Skip to content

Conversation

@vstinner
Copy link
Member

No description provided.

@sweeneyde
Copy link
Member

Some of these could be changed as well:

(deprecated)
Lib/distutils/command/build.py:        if hasattr(sys, 'gettotalrefcount'):
Lib/distutils/tests/test_build.py:        if hasattr(sys, 'gettotalrefcount'):

(arguably 'gettotalrefcount' is more relavant)
Lib/test/libregrtest/refleak.py:    if not hasattr(sys, 'gettotalrefcount'):

(ok to change?)
Lib/test/pythoninfo.py:    Py_DEBUG = hasattr(sys, 'gettotalrefcount')
Lib/test/support/__init__.py:Py_DEBUG = hasattr(sys, 'gettotalrefcount')
Lib/test/test_gc.py:    BUILD_WITH_NDEBUG = (not hasattr(sys, 'gettotalrefcount'))
Lib/test/test_types.py:        if not hasattr(sys, 'gettotalrefcount'):

(maybe we don't want to access test.support from warnings.py)
Lib/warnings.py:    if not hasattr(sys, 'gettotalrefcount'):`

@vstinner
Copy link
Member Author

Yeah, I also searched for gettotalrefcount.

(deprecated)
Lib/distutils/command/build.py: if hasattr(sys, 'gettotalrefcount'):
Lib/distutils/tests/test_build.py: if hasattr(sys, 'gettotalrefcount'):

I don't want to touch the deprecated distutils module, unless I have a very good reason to do it :-)

(arguably 'gettotalrefcount' is more relavant)
Lib/test/libregrtest/refleak.py: if not hasattr(sys, 'gettotalrefcount'):

gettotalrefcount is more relavant

(ok to change?)
Lib/test/pythoninfo.py: Py_DEBUG = hasattr(sys, 'gettotalrefcount')

I designed pythoninfo to minimize imports and reduce side effects. I prefer to "reimplement" Py_DEBUG there. Also, this code is copied to 3.10 and 3.11 branches.

Lib/test/support/init.py:Py_DEBUG = hasattr(sys, 'gettotalrefcount')

That's my PR :-D

Lib/test/test_gc.py: BUILD_WITH_NDEBUG = (not hasattr(sys, 'gettotalrefcount'))

It's a weird heuristic, I prefer to leave the code unchanged to avoid any regression.

Lib/test/test_types.py: if not hasattr(sys, 'gettotalrefcount'):

gettotalrefcount is more relavant

(maybe we don't want to access test.support from warnings.py)
Lib/warnings.py: if not hasattr(sys, 'gettotalrefcount'):`

The test module is not always installed, test.support imports many modules, and it should not be used in stdlib modules.

@vstinner vstinner merged commit 5185956 into python:main May 25, 2022
@vstinner vstinner deleted the support_py_debug branch May 25, 2022 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants