How to find out if the interpreter is a debug build?

L

llothar

How can i find out if a selected python interpreter (i only know the
path name under which i should start it) is a debug build? I tried

sys.api_version, sys.platform, sys.version, sys.version_info

and there is no difference between "python.exe" and "python_d.exe".
I'm pretty sure the information is stored somewhere but i can't find
it. Please help.
 
L

Lawrence D'Oliveiro

llothar said:
How can i find out if a selected python interpreter (i only know the
path name under which i should start it) is a debug build?

What's the difference in their behaviour?
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

llothar said:
How can i find out if a selected python interpreter (i only know the
path name under which i should start it) is a debug build? I tried

sys.api_version, sys.platform, sys.version, sys.version_info

and there is no difference between "python.exe" and "python_d.exe".

Sure there is:

if sys.executable.endswith("_d.exe"):
print "Debug version"

If relying on the executable name is too unsafe, you can also look
at imp.get_suffixes(), which includes "_d.pyd" in a debug build on
Windows.

If you want it cross-platform, you can check whether sys.getobjects
is available. That, of course, is also unsafe because there isn't
a single "debug build" on Unix, but instead, several debugging
features can be enabled and disabled separately, so you would have
to specify first what precisely a debug build is.

Regards,
Martin
 
L

llothar

What's the difference in their behaviour?

Total different and total incompatible behaviour if you write
an IDE (Debugger/Profiler etc.)

And total different for binary extensions.
 
L

llothar

If you want it cross-platform, you can check whether sys.getobjects
is available. That, of course, is also unsafe because there isn't
a single "debug build" on Unix, but instead, several debugging
features can be enabled and disabled separately, so you would have
to specify first what precisely a debug build is.

I thought that the answer is as complicated as this. At the moment it
would be nice and enough if i only can find out if my binary
extension can be loaded into an interpreter or if this requires a
new extension build.

It is a huge problem and weakness of python if this is impossible
with
debug builds. And if you answer that this is up to the user, i have
to
say, no it isn't: At least if you are like me and are working on an
IDE with a debugger component.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

It is a huge problem and weakness of python

Would you like to contribute a patch?

Regards,
Martin
 
L

llothar

Would you like to contribute a patch?

Would such a patch require a full blown PEP?

If i have to write a PEP i can better add it to the documentation of
my application and be sure that the problem is solved. A patch might
be rejected by anybody in a bad mood or who don't understand why it is
usefull.
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

Would such a patch require a full blown PEP?

No.
If i have to write a PEP i can better add it to the documentation of
my application and be sure that the problem is solved.

I don't understand. Are you saying you would rather not write a PEP,
and add something to the documentation of your application instead?
If that solves your problem, go for it!
A patch might
be rejected by anybody in a bad mood or who don't understand why it is
usefull.

That's true.

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top