[Python-bugs-list] [ python-Bugs-415492 ] Compiler generates relative filenames

noreply@sourceforge.net noreply@sourceforge.net
Fri, 13 Apr 2001 10:52:42 -0700


Bugs item #415492, was updated on 2001-04-11 11:52
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=415492&group_id=5470

Category: Parser/Compiler
Group: None
Status: Open
Priority: 5
Submitted By: Paul Prescod (prescod)
>Assigned to: Paul Prescod (prescod)
Summary: Compiler generates relative filenames

Initial Comment:
Make a file called "test.py"
----
import pack

print pack.func.func_code.co_filename
-----

Make a directory called "pack". Put a file in it 
called "__init__.py" with the contents:

def func(): pass

Now run test.py. It will compile a relative path into 
these modules. Now you can change to any directory on 
the system and run test.py and it will return the 
original relative path. The problem is that the 
relative path is compiled into the .pyc. It should be 
an absolute path.

----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2001-04-13 07:12

Message:
Logged In: YES 
user_id=31392

I'm not clear on what the rules for co_filename are, but it
looks like the absolute path is only used for package
imports.  If you cd into the package directory, run python
-c "import __init__", and then later import the package the
path name is relative.

The compiler package isn't connected to the import
mechanism, so there's no way for it to know whether it is
compiling a module or a package.  I don't think there's a
way to do anything better.


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=415492&group_id=5470