[python-win32] inspect.getsource fails

Mark Hammond mhammond at skippinet.com.au
Mon Jun 11 15:13:52 CEST 2007


The inspect module is expecting "normal" .py files, which ActiveScript based
objects don't support.  It might be possible to tweak things so it does work
- last time I tried was many years ago now, and things may be easier to
trick now - see pyscript.py for any filename magic which does exist (eg, for
tracebacks etc)
 
Cheers,
 
Mark.
 
 
 -----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Marc-André Belzile
Sent: Saturday, 9 June 2007 5:26 AM
To: python-win32 at python.org
Subject: [python-win32] inspect.getsource fails



Hi,
 
I get an IO error when executing some code based on the inspect module:
 
import inspect
 
def FunctionTest():
    x = 1
    y = 2
    return x+1
 
stringFunction = inspect.getsource(FunctionTest)
    
print stringFunction

 
# ERROR : Traceback (most recent call last):
#   File "<Script Block >", line 8, in <module>
#     stringFunction = inspect.getsource(FunctionTest)
#   File "C:\Python25\Lib\inspect.py", line 614, in getsource
#     lines, lnum = getsourcelines(object)
#   File "C:\Python25\Lib\inspect.py", line 603, in getsourcelines
#     lines, lnum = findsource(object)
#   File "C:\Python25\Lib\inspect.py", line 468, in findsource
#     raise IOError('could not get source code')
# IOError: could not get source code
#  - [line 8]

The script is invoked through the pywin ActiveX engine
IActiveScriptParse::ParseScriptText.
 
Any ideas what is going on?
 
thanks
 
-mab

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 5284 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20070611/fd72b201/attachment.bin 


More information about the Python-win32 mailing list