This project has moved and is read-only. For the latest updates, please go here.

Debug external python25.dll

Mar 23, 2011 at 1:01 AM

Is there a way to debug a local dll based implementation of Python? The Maya 3D package (amongst others) comes with an embedded copy of python that is distributed as a .dll and which is invoked by the Maya executable. Various IDEs such as Eclipse/PyDev have a module that you can import to allow remote debugging for cases such as these. I have looked at various packages that utilize MPI such as PyPar, but I don't see an obvious avenue here for pt4vs to hook into. Ideas?

Mar 23, 2011 at 5:17 AM

can you try Debug->Attach to Process and see if you can attach to Maya's process with Python code selected as the target code type?  That may work w/o out any external changes to your scripts.  If that's inadequate we can probably add a feature to import a module and enable remote debugging that way.

Mar 23, 2011 at 10:06 PM

Well, this certainly does something. After attaching to Maya, importing certain modules now throws errors:

import platform

# Error: global name '__file__' is not defined

# Traceback (most recent call last):

#   File "<maya console>", line 1, in <module>

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 116, in <module>

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 180, in compile

#     return _compile(pattern, flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 231, in _compile

#     p = sre_compile.compile(pattern, flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 511, in compile

#     code = _code(p, flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 495, in _code

#     _compile(code,, flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 148, in _compile

#    _compile(code, av, flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 107, in _compile

#     _compile(code, av[1], flags)

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 46, in _compile

#     for op, av in pattern:

#   File "C:\Program Files (x86)\Autodesk\Maya2009\bin\\", line 137, in __getitem__

#     return[index]

#   File "", line 146, in trace_func

#   File "", line 236, in handle_exception

# NameError: global name '__file__' is not defined #


Two things here seem odd beyond the obvious. line 146 of seems to be in the package that Maya ships with. The line 236 error below that seems to be located in another that is part of the pt4vs package in: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\1.0

I don't believe that either one of these are the direct error however...


Mar 23, 2011 at 10:33 PM

narrowing it down further, the following regex fails after attaching to the process, but apparently works otherwise:

Import re

_libc_search = re.compile(r'(__libc_init)'






The actual error is masked by the '__file__' issue in mentioned above. Could this pt4vs python file be geared toward a version of Python other than 2.5x?

Mar 25, 2011 at 5:04 AM

I think the existance of 2's could be the real problem (w/ the side effect of breaking the re.compile call).  We should probably give this a more unique name like our profiler (such as visualstudio_debugger).  But there may also be an issue where sys.settrace() has already been called and we should forward the call to the previous version as well.  Maybe that's part of what's going on here as well.

Mar 25, 2011 at 9:19 PM

I think both of those observations are spot on.

Apr 1, 2011 at 1:05 AM

I've opened this issue: