[Patches] [ python-Patches-664376 ] sys.path[0] should contain absolute pathname

SourceForge.net noreply@sourceforge.net
Tue, 18 Feb 2003 07:13:54 -0800


Patches item #664376, was opened at 2003-01-08 14:26
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=664376&group_id=5470

Category: None
Group: None
Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Nobody/Anonymous (nobody)
Summary: sys.path[0] should contain absolute pathname

Initial Comment:
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

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

>Comment By: Thomas Heller (theller)
Date: 2003-02-18 16:13

Message:
Logged In: YES 
user_id=11105

Will this patch make it into 2.3a2?

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-11 05:07

Message:
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).

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

Comment By: Skip Montanaro (montanaro)
Date: 2003-01-11 00:08

Message:
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


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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-10 23:18

Message:
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().

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

Comment By: Skip Montanaro (montanaro)
Date: 2003-01-10 23:15

Message:
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

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-10 22:58

Message:
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!

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

Comment By: Skip Montanaro (montanaro)
Date: 2003-01-10 22:32

Message:
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

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

Comment By: Thomas Heller (theller)
Date: 2003-01-10 15:24

Message:
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.

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

Comment By: Thomas Heller (theller)
Date: 2003-01-08 16:02

Message:
Logged In: YES 
user_id=11105

Checked in as sysmodule.c, rev 2.112.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-01-08 15:00

Message:
Logged In: YES 
user_id=6380

Feel free to check this in.

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

Comment By: Thomas Heller (theller)
Date: 2003-01-08 14:31

Message:
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.


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=664376&group_id=5470