Python: How to detect debug interpreter

前端 未结 3 1271
悲&欢浪女
悲&欢浪女 2021-01-04 09:09

How can I detect in my python script if its being run by the debug interpreter (ie python_d.exe rather than python.exe)? I need to change the paths to some dlls that I pass

3条回答
  •  春和景丽
    2021-01-04 09:24

    Distutils use sys.gettotalrefcount to detect a debug python build:

    # ...
    if hasattr(sys, 'gettotalrefcount'):
       plat_specifier += '-pydebug'
    
    • this method doesn't rely on an executable name '*_d.exe'. It works for any name.
    • this method is cross-platform. It doesn't depend on '_d.pyd' suffix.

    See Debugging Builds and Misc/SpecialBuilds.txt

提交回复
热议问题