[Python-Dev] Issue #25256: Add sys.debug_build? (original) (raw)
Nir Soffer nirsof at gmail.com
Fri Oct 2 13:16:48 CEST 2015
- Previous message (by thread): [Python-Dev] Issue #25256: Add sys.debug_build?
- Next message (by thread): [Python-Dev] Issue #25256: Add sys.debug_build?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Whats wrong with:
sysconfig.getconfigvar('PyDEBUG') 0
Nir
On Fri, Oct 2, 2015 at 10:18 AM, Victor Stinner <victor.stinner at gmail.com> wrote:
Hi,
I created the issue "Add sys.debugbuild public variable to check if Python was compiled in debug mode": http://bugs.python.org/issue25256 I would like to add an obvious way to check if Python was compiled in debug mode, instead of having hacks/tips to check it. On the Internet, I found various recipes to check if Python is compiled is debug mode. Sadly, some of them are not portable. For example, 3 different checks are proposed on StackOverflow but 2 of them are specific to Windows: http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter Even if the exact impact of a debug build depends on the Python implementation and the Python version, we can use it to have the same behaviour on all Python implementations. For example, the warnings module shows warnings by default if Python is compiled in debug mode: Extract of my patch: - if hasattr(sys, 'gettotalrefcount'): + if sys.debugbuild: resourceaction = "always" else: resourceaction = "ignore" Alternative: Add a new sys.implementation.debugbuild flag. Problem: extending sys.implementation requires a new PEP, and I don't think that debugbuild fits into this object. Berker Peksag likes the idea. Serhiy Storchaka dislike the new flag: "I don't like this. The sys module is one of most used module, but it has too many members, and adding yet one makes the situation worse." (sys has 81 symbols) "Checking for debug mode is not often needed, and mainly in tests. Current way
hasattr(sys, 'gettotalrefcount')
works good. You also can check'd' in sys.abiflags
if it looks cleaner to you. Or add a member to test.support." The name "debugbuild" comes from the existing sysconfig.ispythonbuild() function. There is a sys.flags.debug flag, so "sys.debug" can be confusing. I prefer to attach the "build" suffix. First I proposed a function sys.isdebugbuild(), but a flag is simpler than a function. There is not need to compute a version it's known at build time. What do you think? Should we add sys.debugbuild? Victor
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/nirsof%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20151002/f5abb67a/attachment.html>
- Previous message (by thread): [Python-Dev] Issue #25256: Add sys.debug_build?
- Next message (by thread): [Python-Dev] Issue #25256: Add sys.debug_build?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]