[ python-Bugs-1193180 ] Strange os.path.exists() results with invalid chars

SourceForge.net noreply at sourceforge.net
Sun Jul 30 13:30:09 CEST 2006


Bugs item #1193180, was opened at 2005-04-30 23:13
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1193180&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: Python 2.4
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Daniele Varrazzo (dvarrazzo)
Assigned to: Nobody/Anonymous (nobody)
Summary: Strange os.path.exists() results with invalid chars

Initial Comment:
Hi,

when there are invalid chars in a filename, os.path.exists
() behaves oddly, returning True.

The bug appears on win32 system, not on unix ones. 
Thus is probably related to some weird windows api call 
and doesn't maybe worth fixing.

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 
32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more 
information.
>>> import os
>>> f = file("a_b", "w")
>>> f.close()
>>> os.listdir(".")
['a_b']
>>> os.path.exists("a<b")
True
>>> os.path.exists("a>b")
True

And, even more strange...

>>> os.path.exists("a<")
True
>>> os.path.exists("a>")
False

Better answers would have been:
  * False
  * raise ValueError


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

Comment By: Georg Brandl (birkenfeld)
Date: 2005-05-31 09:56

Message:
Logged In: YES 
user_id=1188172

I think Python just uses the Win32 system call, so there
isn't much Python can do about it.

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

Comment By: engelbert gruber (grubert)
Date: 2005-05-23 06:52

Message:
Logged In: YES 
user_id=147070

testing with perl: print -e "a<"; returns True/1 too

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

Comment By: Jarek Zgoda (zgoda)
Date: 2005-05-02 12:04

Message:
Logged In: YES 
user_id=92222

Same for Python 2.3.5.

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

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


More information about the Python-bugs-list mailing list