This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sys.path[0] should contain absolute pathname
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, skip.montanaro, theller
Priority: normal Keywords: patch

Created on 2003-01-08 13:26 by theller, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sysmodule.diff theller, 2003-01-08 13:31 sysmodule.diff with Windows patch
sysmodule.diff theller, 2003-01-10 14:24 sysmodule.diff patched to use realpath()
abspath.diff skip.montanaro, 2003-01-10 21:32
Messages (15)
msg42379 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2003-01-08 13:26
This patch changes sys.path[0] to contain an absolute 
instead of a relative pathname.

See python-dev thread starting here:
http://mail.python.org/pipermail/python-dev/2003-
January/031896.html
msg42380 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2003-01-08 13:31
Logged In: YES 
user_id=11105

The attached patch (sysmodule.diff) fixes the problem on 
Windows - that's the only system where I can test it.

It leaves sys.argv alone and only changes sys.path[0] to an 
absolute pathname.
msg42381 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-08 14:00
Logged In: YES 
user_id=6380

Feel free to check this in.
msg42382 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2003-01-08 15:02
Logged In: YES 
user_id=11105

Checked in as sysmodule.c, rev 2.112.
msg42383 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2003-01-10 14:24
Logged In: YES 
user_id=11105

I believe this problem should be fixed also on systems other
than Windows, or the checkin should be reverted again.

I've prepared a patch based on an idea of Skip Montanaro,
who pointed my to the realpath() function.
It is tested on a SuSE 7.0 Linux system, but I don't know
which #ifdef I have to se around this code. See the patch
for details.

Reopened and unassigned for review.
msg42384 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-10 21:32
Logged In: YES 
user_id=44345

Here's a somewhat different patch.  I don't know if the actual sysmodule.c
patch is correct or not, but it includes the necessary framework to
verify that realpath() is available.  Pick and choose bits as you like.

Skip
msg42385 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-10 21:58
Logged In: YES 
user_id=6380

The abspath.diff patch seems to work.

But the two new includes in sysmodule.c are not needed AFAICT.

Check in time!
msg42386 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-10 22:15
Logged In: YES 
user_id=44345

Regarding the includes, I was just going by the realpath manpage on 
my Mac and the fact that a quick scan of Include/*.h didn't turn them up.
S
msg42387 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-10 22:18
Logged In: YES 
user_id=6380

stdlib.h is included by Python.h and pyport.h.

I don't see anything in sys/param.h that provides realpath().
msg42388 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-10 23:08
Logged In: YES 
user_id=44345

On my Mac stdlib.h contains the declaration for realpath() and sys/param.h defines MAXPATHLEN which is referenced in the realpath man page.  On
my Mandrake system, realpath() is declared in stdlib.h.  The man page there
references limits.h, though I didn't see any constant like MAXPATHLEN
referenced in the man page.

I guess dump the #includes and wait to see if any platforms complain.
S
msg42389 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-01-11 04:07
Logged In: YES 
user_id=6380

Yeah, but stdlib.h is *already* being included (by Python.h)
and MAXPATHLEN is also already available (through osdefs.h).
msg42390 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2003-02-18 15:13
Logged In: YES 
user_id=11105

Will this patch make it into 2.3a2?
msg42391 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-02-18 16:16
Logged In: YES 
user_id=6380

I'd like this in 2.3a2.

Skip, do you have time to check this in (less the #include
<sys/param.h> and #include <stdlib.h>)? If not, I can do it.
msg42392 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-02-19 15:25
Logged In: YES 
user_id=6380

I'll check this in.
msg42393 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-02-19 15:33
Logged In: YES 
user_id=6380

All checked in.
History
Date User Action Args
2022-04-10 16:06:07adminsetgithub: 37742
2003-01-08 13:26:43thellercreate