A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2010-February/097472.html below:

[Python-Dev] __file__ is not always an absolute path

[Python-Dev] __file__ is not always an absolute path [Python-Dev] __file__ is not always an absolute pathChristian Heimes lists at cheimes.de
Sun Feb 7 01:36:12 CET 2010
Guido van Rossum schrieb:
> Are you sure you remember this right? The <code>.co_filename
> attributes will be unmarshalled straight from the bytecode file which
> indeed will have the relative path in this case (hopefully we'll
> finally fix this in 3.2 and 2.7). But if I read the code in import.c
> correctly, __file__ is set on the basis of the path of the file read,
> which in turn comes from sys.path which will have been "absolufied" by
> site.py. Or maybe this was so long ago that site.py didn't yet do
> that?

I ran into the problem years ago. I can recall the Python version but it
must have been 2.2 or 2.3, maybe 2.1. I'm not entirely sure how it
happened, too. All I can remember that I traced the cause down to the
way compileall was called. I've tried to reproduce the issue with Python
2.6 but failed. It looks like the code does the right thing.

Christian
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4