[python-win32] ValueError in relpath

Niemann, Hartmut hartmut.niemann at siemens.com
Fri Sep 14 11:03:58 CEST 2012


Hello Tim!

Thank you for your reply.

> -----Ursprüngliche Nachricht-----
> Niemann, Hartmut wrote:
> > I am not subscribed to this mailing list (so CC me on all 
> replies please), 
> 
> How did you send this?  The list only accepts postings from members.

I did nothing special, it obviously accepted mine, or someone accepted it manually.
> 
> 
> > My conclusions:
> >  
> > (1) I wonder what limitation on windows was hit by the 
> _getfullpathname(path) call. 
> > The file name is long but not so exceptionally long. Maybe 
> this is a python problem
> > that can be fixed?
> 
> How long is the path?  Your sample below is only about 150 
> characters. 
> The GetFullPathName API is limited to 260 characters, unless one uses
> the Unicode version and uses the \\?\ prefix, which extends that to
> 32,768.  I'll have to check the library source code to see which one
> they use.
> 

No, the relative path that crashed it has 245 characters:

2012-08-07_diffzu_2012-09-12\PRJ\I1SITRAC\wrk\130_Eclipse\Workspace\.metadata\.plugins\com.python.pydev.analysis\python_v1_eo3pb4rfuku7u65tfbbltnbp5\v1_indexcache\pylint.test.input.func_noerror_classes_meth_could_be_a_function_bhwc.v1_indexcache

so the absolute path exceeded 260. That makes sense.

This was a real crash, i. e. this is the filename that crashed.

I used to have problems with long and strange file names from
saving web pages, but this time the problems came (on several places)
with internal eclipse data which has quite long (but 'regular', 
i.e. no special characters) file names.

I could do some more tests if you want me to, just tell me what you are
interested in.

>  
> > (2) The fact that abspath(path) swallows the windows error, 
> returning
> > something that is definitely wrong (a relative path where 
> an absolute
> > one is expected) makes it hard to use it safely. Could it simply
> > not catch the WindowsError or raise an Error (which one?)?
> 
> "Which one" is an excellent question.  It's not clear what 
> the behavior
> should be.  Perhaps just allowing the WindowsError to leak 
> through would
> be the safest.
> 
>  
> > (3) why does relpath() need absolute paths at all? Could it 
> work without this
> > path normalisation if both paths are relative and 
> path.startswith(start) is true?
> 
> The relpath operation is tricky, because it's possible for 
> paths to have
> things like a\b\..\..\c\d\..\other.  You generally want to unravel all
> of that before you begin.
I understand.

I used relpath with walk, so the path starts always with base,
maybe I'll try to use that knowledge to circumvent the problem.

Do you think what I saw is a bug? Can you enter it into the bug database?

With best regards
Hartmut.


More information about the python-win32 mailing list