Title: no extension debug info with
Type: behavior Stage: resolved
Components: Distutils, Windows Versions: Python 3.4, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: steve.dower Nosy List: BreamoreBoy, amaury.forgeotdarc, dstufft, eric.araujo, jpe, loewis, python-dev, robind, steve.dower, tarek
Priority: normal Keywords: patch

Created on 2008-10-27 21:54 by robind, last changed 2015-08-08 05:26 by steve.dower. This issue is now closed.

File name Uploaded Description Edit
Issue4214.diff BreamoreBoy, 2014-07-09 20:30 One line change to remove /pdb:None review
Messages (14)
msg75264 - (view) Author: Robin Dunn (robind) Date: 2008-10-27 21:54
It looks like part of r59290 resulted in /pdb:None always being part of
the ldflags_shared_debug list.  This means that there will be no debug
info stored for extensions built in debug mode, which kinda negates the
purpose of doing a debug build.  

Looking back at the revision history and comparing similar code in it looks like the /pdb:None was optionally added in the
first place because of compatibility issues with earlier compilers.  For
MSVC 7 and 9 I think it should be fine to simply remove /pdb:None from
that list.  My ad hoc testing so far has not revealed any problems with
making this change.
msg75265 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-10-27 22:13
Furthermore, /PDB:None is no more supported by VC2008 express.
You end up with files named "None"...
msg83264 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-03-07 01:01
Since I am unfamiliar with MSVC, I will need to digg on this, so if
anyone can help on this : any idea on what would be the proper fix and
why ?
msg83280 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2009-03-07 14:42
Like Robin, I think it's better to remove the /pdb option, and let the 
default behavior, which is (when /debug is present) to generate a .pdb 
file next to the generated target.
msg122633 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-28 05:36
What are pdb files, by the way?
msg122721 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-11-28 20:28
A .pdb is the "program database" that contain debug info, i.e. the mapping between assembler positions and source lines, the description of data structures, and other things that are necessary to debug a program.
msg122806 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-29 15:02
Thanks for explaining.  Is someone willing to add a test in test_msvc9compiler?
msg122855 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-11-29 19:35
/pdb:None initially did *not* mean "no debug information", but "no pdb file", see

Debug information would be embedded to the DLL.

Later versions of the VS documentation fail to mention "None" as a special value. Assuming it still has its original semantics, I fail to see the bug in this report.
msg122860 - (view) Author: Robin Dunn (robind) Date: 2010-11-29 19:53
No, MSVC does not behave that way any longer.  Now it simply creates a file named "None", so I expect that the newer versions simply do not support writing the "old-style" debug info written to the DLL or EXE. If a setup script creates more than one extension module then they all overwrite that None file.

In order to get debug info in a useable form, distutils simply can not use /pdb:None.  By removing that option entirely then debug info is generated like normal into a *.pdb file and using the debugger to trace through the extension module's code will happily work correctly.

I've had to have this hack in wxPython's since Python 2.6 to work around this problem:

# Yet another distutils hack, this time for the msvc9compiler.  There
# is a bug in at least version distributed with Python 2.6 where it
# adds '/pdb:None' to the linker command-line, but that just results
# in a 'None' file being created instead of putting the debug info
# into the .pyd files as expected.  So we'll strip out that option via
# a monkey-patch of the msvc9compiler.MSVCCompiler.initialize method.

if == 'nt' and  sys.version_info >= (2,6):
    import distutils.msvc9compiler
    _orig_initialize = distutils.msvc9compiler.MSVCCompiler.initialize

    def _initialize(self, *args, **kw):
        rv = _orig_initialize(self, *args, **kw)
        except ValueError:
        return rv

    distutils.msvc9compiler.MSVCCompiler.initialize = _initialize
msg122864 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-11-29 20:13
Ah ok, then removing the option sounds fine to me (not for 2.6, though).
msg222636 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-09 20:30
Patch is against default.  The entire distutils test suite ran okay.  Would someone like to try this in the real world please.
msg248235 - (view) Author: John Ehresman (jpe) * Date: 2015-08-07 23:15
I just ran into this again when I installed 2.7.10 -- evidently I had patched my local installation and forgot about it.  This is very important to anyone who tries to use the Visual Studio C debugger to debug extension modules.
msg248244 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-08-08 02:44
This option is no longer set in 3.5/3.6 (which don't use

I'll get it for 2.7 and 3.4.
msg248248 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-08-08 05:26
New changeset 418095f0d711 by Steve Dower in branch '2.7':
Issue #4214: Remove ineffectual /pdb:none option from

New changeset 7c322c296a3b by Steve Dower in branch '3.4':
Issue #4214: Remove ineffectual /pdb:none option from

New changeset 6a1c2c7b0ee0 by Steve Dower in branch '3.5':
Issue #4214: Remove ineffectual /pdb:none option from

New changeset b35df92f69e4 by Steve Dower in branch 'default':
Issue #4214: Remove ineffectual /pdb:none option from
Date User Action Args
2015-08-08 05:26:50steve.dowersetstatus: open -> closed
assignee: tarek -> steve.dower
resolution: fixed
stage: resolved
2015-08-08 05:26:25python-devsetnosy: + python-dev
messages: + msg248248
2015-08-08 02:44:47steve.dowersettype: compile error -> behavior
messages: + msg248244
versions: - Python 3.5
2015-08-08 01:21:53BreamoreBoysetnosy: + steve.dower
2015-08-07 23:15:00jpesetnosy: + jpe
messages: + msg248235
2014-07-10 10:48:32berker.peksaglinkissue9745 superseder
2014-07-09 20:30:45BreamoreBoysetfiles: + Issue4214.diff

components: - Distutils2
versions: + Python 3.4, Python 3.5, - 3rd party, Python 3.1, Python 3.2
keywords: + patch
nosy: + dstufft, BreamoreBoy

messages: + msg222636
2010-11-29 20:13:32loewissetmessages: + msg122864
versions: - Python 2.6
2010-11-29 19:53:06robindsetmessages: + msg122860
versions: + Python 2.6
2010-11-29 19:35:31loewissetmessages: + msg122855
2010-11-29 15:02:29eric.araujosetnosy: + loewis
messages: + msg122806
2010-11-28 20:28:19amaury.forgeotdarcsetmessages: + msg122721
2010-11-28 05:36:51eric.araujosetversions: + 3rd party, Python 3.2, - Python 2.6, Python 3.0
nosy: + eric.araujo

messages: + msg122633

components: + Distutils2
2009-03-07 14:42:28amaury.forgeotdarcsetmessages: + msg83280
2009-03-07 01:01:27tareksetmessages: + msg83264
versions: + Python 3.0, Python 3.1, Python 2.7
2009-02-28 22:54:09akitadasetnosy: + tarek
components: + Windows
assignee: tarek
2008-10-27 22:13:49amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg75265
2008-10-27 21:54:21robindcreate