New submission from Luis Conejo-Alpizar <luisco...@gmail.com>:

Windows has a maximum path length limitation of 260 characters. This 
limitation, however, can be bypassed in the scenario described below. When this 
occurs, os.isfile() will return false, even when the affected file does exist. 
For Windows systems, the behavior should be for os.isfile() to return an 
exception in this case, indicating that maximum path length has been exceeded.

Sample scenario:

1. Let's say you have a folder, named F1 and located in your local machine at 
this path:

C:\tc\proj\MTV\cs_fft\Milo\Fries\STL\BLNA\F1\

2. Inside of that folder, you have a log file with this name:

This_is_a_really_long_file_name_that_by_itself_is_not_capable_of_exceeding_the_path_length_limitation_Windows_has_in_pretty_much_every_single_version_of_Wind.log

3. The combined length of the path and the file is exactly 260 characters, so 
Windows lets you get away with it when the file is initially created and/or 
placed there.

4. Later, you decide to make the F1 folder available on your network, under 
this name:

\\tst\tc\proj\MTV\cs_fft\Milo\Fries\STL\BLNA\F1\

5. Your log file continues to be in the folder, but its full network path is 
now 263 characters, effectively violating the maximum path length limitation.

6. If you use os.listdir() on the networked folder, the log file will come up.

7. Now, if you try os.path.isfile(os.path.join(networked_path,logfile_name)) it 
will return false, even though the file is indeed there and is indeed a file.

----------
components: Library (Lib)
messages: 314109
nosy: ldconejo
priority: normal
severity: normal
status: open
title: os.isfile returns false on Windows when file path is longer than 260 
characters
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33105>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to