homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.makedirs() cannot handle "."
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, tzot, vimboss
Priority: normal Keywords:

Created on 2003年10月24日 11:44 by vimboss, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
diff vimboss, 2003年10月24日 20:13 patch to fix the problem.
os.patch akuchling, 2003年10月31日 19:41
Messages (6)
msg18750 - (view) Author: Bram Moolenaar (vimboss) Date: 2003年10月24日 11:44
Invoking os.makedirs() with an argument that contains a
directory name with a single dot fails. The resulting
error is confusing: "File exists".
The problem is that the path is split up in pieces and
an attempt is made to create the "." directory. This
always exists, of course. It happens anyway, because
the test for existence is done before creating the
directory that contains ".".
There are various possible solutions:
1. First normalize the path so that "." entries are
removed. This would also work for ".." entries. But
it might cause trouble for symbolic links and there is
a performance penalty.
2. Check for existence of the directory again after the
recursive call to create the directory that contains
the entry. This will cause the normal error for an
existing directory to be skipped, unless an extra flag
is added. This gets complicated.
3. Simply skip creating a directory with the name ".".
I propose to use the third solution. I have attached a
patch for this.
msg18751 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003年10月24日 17:46
Logged In: YES 
user_id=11375
There's no uploaded file! You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.
Please try again.
(This is a SourceForge annoyance that we can do
nothing about. :-( )
msg18752 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2003年10月28日 00:54
Logged In: YES 
user_id=539787
Minor correction (in ex cmdline style :):
:%s/"\."/curdir/g
 in the 'diff' patch (making it more OS independent).
msg18753 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003年10月31日 19:41
Logged In: YES 
user_id=11375
Note that the documentation for os.makedirs() says it raises an exception if the 
directory already exists, so os.makedirs('.') has to continue to be an error, 
though os.makedirs('/foo/bar/.') should be made to work properly.
The attached patch implements this.
msg18754 - (view) Author: Bram Moolenaar (vimboss) Date: 2003年10月31日 22:10
Logged In: YES 
user_id=57665
The patch suggested by akuchling doesn't work for "dir/./.".
And the remark is false anyway, the patch I suggested does
generate an exception for makedirs(".").
msg18755 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2003年12月23日 16:34
Logged In: YES 
user_id=11375
Your patch is correct. Checked in as rev. 1.74 of os.py. Thanks!
History
Date User Action Args
2022年04月11日 14:56:00adminsetgithub: 39454
2003年10月24日 11:44:04vimbosscreate

AltStyle によって変換されたページ (->オリジナル) /