You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When executing a script from a UNC path, e.g. //myhost/exports/a.py,
r"\\myhost\exports" gets prepended to sys.path. But it doesn't work.
This means that in a.py, "import b" will fail even though b.py is
present in the same directory.
The workaround is to manually prepend a backslass to the UNC path in
sys.path.
Note the related defect: http://bugs.python.org/issue954115
This intdoruces two functions for testing UNC paths, but it appears
that these functions are nowhere used!
Correction: The workaround is to _append_ a backslash.
loewis commented on Oct 7, 2008
loewismannequin
Mannequin
More actions
Kristjan, you suggested this issue for consideration for 2.5.3.
Is there an actual patch to apply?
If not, the issue should get forwarded to 2.7 (and then to 2.8, and so
on, until somebody actually comes up with a patch).
kristjanvalur commented on Oct 7, 2008
kristjanvalurmannequin
MannequinAuthor
More actions
No, not really.
Again, I refer to defect 954115 by glchapman. And note that those
functions added there are actually not used.
I was hoping that there was someone here more familiar with importing
on PC.
I'll go and see if the old defect still applies and if there is perhaps
a more general fix to be made.
loewis commented on Oct 7, 2008
loewismannequin
Mannequin
More actions
Ok, un-targetting this from 2.5.3 then.
Usage of IsUNCRoot disappeared as part of r42230, which dropped usage of
the C library for stat implementations. This only affects os.stat,
though, so I don't see the relation to this issue.
For the record: What *exactly* is the problem? I.e. specifically, what
do you do, what happens, what do you expect to happen instead?
ocean-city commented on Oct 7, 2008
ocean-citymannequin
Mannequin
More actions
I think this is stat(2) problem on windows. Please try following test
program.
As discussed in bpo-1293, stat(2) fails for the normal folder path with
trailing slash, and also fails for the UNC folder path without trailing
slash. I'm using VC6, but same behavior on VC9?
trunk/Python/import.c(3160) and trunk/Modules/zipimport.c(99) is using
stat(2).
I'll create patch to prove my observation. :-)
ocean-city commented on Oct 7, 2008
ocean-citymannequin
Mannequin
More actions
Ah, of cource, please change path to fit you environment. > test prog
ocean-city commented on Oct 8, 2008
ocean-citymannequin
Mannequin
More actions
zipimport.c seems fine, because stat(2) succeeds for UNC file. It fails
for UNC folder. (zip file is absolutely file)
Already fix for bpo-1293 was in, so maybe I should create the patch for
that direction but... anyway this issue seems to be fixed by my patch. I
also confirmed the test script in http://bugs.python.org/msg56523 works.
ocean-city commented on Oct 8, 2008
ocean-citymannequin
Mannequin
More actions
Just humble thought...
If we can replace stat(2) + S_ISDIR/S_ISREG check with
GetFileAttributesEx, maybe we are safe for this kind of problem, and can
solve bpo-3099 same time? :-)
Activity
kristjanvalur commentedon Aug 25, 2008
When executing a script from a UNC path, e.g. //myhost/exports/a.py,
r"\\myhost\exports" gets prepended to sys.path. But it doesn't work.
This means that in a.py, "import b" will fail even though b.py is
present in the same directory.
The workaround is to manually prepend a backslass to the UNC path in
sys.path.
Note the related defect: http://bugs.python.org/issue954115
This intdoruces two functions for testing UNC paths, but it appears
that these functions are nowhere used!
kristjanvalur commentedon Aug 25, 2008
Correction: The workaround is to _append_ a backslash.
loewis commentedon Oct 7, 2008
Kristjan, you suggested this issue for consideration for 2.5.3.
Is there an actual patch to apply?
If not, the issue should get forwarded to 2.7 (and then to 2.8, and so
on, until somebody actually comes up with a patch).
kristjanvalur commentedon Oct 7, 2008
No, not really.
Again, I refer to defect 954115 by glchapman. And note that those
functions added there are actually not used.
I was hoping that there was someone here more familiar with importing
on PC.
I'll go and see if the old defect still applies and if there is perhaps
a more general fix to be made.
loewis commentedon Oct 7, 2008
Ok, un-targetting this from 2.5.3 then.
Usage of IsUNCRoot disappeared as part of r42230, which dropped usage of
the C library for stat implementations. This only affects os.stat,
though, so I don't see the relation to this issue.
For the record: What *exactly* is the problem? I.e. specifically, what
do you do, what happens, what do you expect to happen instead?
ocean-city commentedon Oct 7, 2008
I think this is stat(2) problem on windows. Please try following test
program.
And this is result.
e:\shared 0 16
e:\shared\ -1 16
e:\shared\a.py 0 32
\\whiterab-c2znlh\shared -1 16
\\whiterab-c2znlh\shared\ 0 16
\\whiterab-c2znlh\shared\a.py 0 32
As discussed in bpo-1293, stat(2) fails for the normal folder path with
trailing slash, and also fails for the UNC folder path without trailing
slash. I'm using VC6, but same behavior on VC9?
trunk/Python/import.c(3160) and trunk/Modules/zipimport.c(99) is using
stat(2).
I'll create patch to prove my observation. :-)
ocean-city commentedon Oct 7, 2008
Ah, of cource, please change path to fit you environment. > test prog
ocean-city commentedon Oct 8, 2008
zipimport.c seems fine, because stat(2) succeeds for UNC file. It fails
for UNC folder. (zip file is absolutely file)
Already fix for bpo-1293 was in, so maybe I should create the patch for
that direction but... anyway this issue seems to be fixed by my patch. I
also confirmed the test script in http://bugs.python.org/msg56523 works.
ocean-city commentedon Oct 8, 2008
Just humble thought...
If we can replace stat(2) + S_ISDIR/S_ISREG check with
GetFileAttributesEx, maybe we are safe for this kind of problem, and can
solve bpo-3099 same time? :-)
kristjanvalur commentedon Jan 5, 2009
Okay, I've tested the patch and made some beauty fixes.
Can we have this in, please?
kristjanvalur commentedon Jan 9, 2009
Checked in as revision: 68457
benjaminp commentedon Jan 23, 2009
This fix needs to be ported to the py3k branch. Can somebody please do it?
ocean-city commentedon Jan 23, 2009
Merged in r68873(py3k).
ggenellina commentedon Jan 24, 2009
The path variable should be PyMem_Free'd (in both trunk and py3k)
(also, I don't see any specific test - is there any?)
kristjanvalur commentedon Jan 24, 2009
added the mem release in r68882.
I'll try to add test cases too.
kristjanvalur commentedon Jan 24, 2009
Added tests for UNC path imports in r68883 and r68884
ocean-city commentedon Jan 24, 2009
Sorry if I'm missing something, but is this really needed?
Other PyArg_ParseTuple(args, "s... doesn't seem to have
corresponding PyMem_Free.
loewis commentedon Jan 24, 2009
Yes, the "es" converter allocates memory.
ocean-city commentedon Jan 24, 2009
Ah, "es" is used in py3k, thanks. And sorry about my merge which had
memory leak.