co_filename in code objects is None


<Thanks>Christian Muirhead</Thanks>
c = compile("x = 2", "test", "exec") >>> c.co_filename 'test'
IronPython 1.0.1
c = compile("x = 2", "test", "exec") >>> c.co_filename >>>
(That is, it was None)
It would be handy for us if IP's behaviour matched CPython's here. Can you please add a bug for this?
Closed Jul 21, 2008 at 11:19 PM by dfugate


sanxiyn wrote Dec 3, 2006 at 1:48 PM

Patch: http://fepy.sourceforge.net/patches.html (patch-ironpython-compile-co-filename)

dfugate wrote Apr 22, 2008 at 11:05 PM

Works in 2.0 as well now. Enabled regression tests.

** Closed by dfugate 9/26/2007 10:47 AM

dfugate wrote Apr 22, 2008 at 11:05 PM

dfugate wrote Apr 22, 2008 at 11:24 PM

Reopened this as I've found another scenario it fails in:

E:\Merlin\External\Languages\IronPython20\25\Lib>type E:\blah.py
import sys

from new import module
name = '__inspect_dummy'
m = sys.modules[name] = module(name)
m.file = "<string>"
m.loader = "dummy"
exec "def x(): pass" in m.dict

print m.x.func_code.co_filename
E:\Merlin\External\Languages\IronPython20\25\Lib>cpy E:\blah.py

E:\Merlin\External\Languages\IronPython20\25\Lib>ipyd E:\blah.py

dinov wrote Jun 4, 2008 at 9:42 PM

we need to check for the filename from CodeContext if we don't get one from the source file. We don't always pull it from globals because:

file = 'abc'
def f(): pass


still has the real filename