Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment:
I suggest to raise exception when target regular file exists:
try:
mkdir(name, mode)
except OSError as e:
if not (exist_ok and e.errno == errno.EEXIST and path.isdir(name)):
raise
--
Terry J. Reedy tjre...@udel.edu added the comment:
On windows, I can only import nt, not posix, ce, os2.
import posix
Traceback (most recent call last):
File pyshell#0, line 1, in module
import posix
ImportError: No module named posix
import nt
dir(nt)
['F_OK', 'O_APPEND', 'O_BINARY',
Guido van Rossum gu...@python.org added the comment:
On Wed, Jul 21, 2010 at 3:32 AM, Terry J. Reedy rep...@bugs.python.org wrote:
Terry J. Reedy tjre...@udel.edu added the comment:
Discussion has continued on pydev thread mkdir -p in python. Some suggested
a new function. Others
Ray.Allen ysj@gmail.com added the comment:
I found in Modules/posixmodule.c that:
#if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__))
!defined(__QNX__)
#define INITFUNC PyInit_nt
#define MODNAME nt
#elif defined(PYOS_OS2)
#define INITFUNC PyInit_os2
#define MODNAME
Terry J. Reedy tjre...@udel.edu added the comment:
Guido: Hm. I wonder if os.mkdir() should not be left alone (so as to continue
to match the system call most exactly, as is our convention) and the extra
functionality added to os.makedirs() only.
Sticking with that convention seems like a
Ray.Allen ysj@gmail.com added the comment:
Agree! Sure, the functions in os are mainly to simulate the system call but not
the system command. This seems like a good suggestion.
So here is the new patch which leave posixmodule.c alone and just wrappers
os.mkdir() with try...except... in
Terry J. Reedy tjre...@udel.edu added the comment:
Discussion has continued on pydev thread mkdir -p in python. Some suggested a
new function. Others questioned the details of the new behavior. Guido prefers
the flag approach and imitation of mkdir -p.
-1 on a new function (despite the
Ray.Allen ysj@gmail.com added the comment:
Thanks for conclusion! I'll try to check and improve my patch.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Ray.Allen ysj@gmail.com added the comment:
I update my patch with improved doc string of posix_mkdir.
By the way, after I search in the source, I could not find the nt, os2,
ce modules, I guess these modules only exist in python source at one time,
maybe very earlier releases, but not
New submission from Ray.Allen ysj@gmail.com:
As discussed in python-dev mailing list, something should be add to os.mkdir()
and os.makedirs() to simulate the shell's mkdir -p function, that is,
suppress the OSError exception if the target directory exists.
Here is a patch against py3k,
Changes by Giampaolo Rodola' g.rod...@gmail.com:
--
nosy: +giampaolo.rodola
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
___
Giampaolo Rodola' g.rod...@gmail.com added the comment:
I don't think this can go into 2.7.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Changes by Ray.Allen ysj@gmail.com:
Removed file: http://bugs.python.org/file18059/mkdir_py3k.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Ray.Allen ysj@gmail.com added the comment:
I update the patch since an problem is found in doc/library/os.rst.
--
Added file: http://bugs.python.org/file18060/mkdir_py3k.diff
___
Python tracker rep...@bugs.python.org
Isaac Morland ijmor...@uwaterloo.ca added the comment:
This exact issue has already been discussed in Issue 1675.
--
nosy: +ijmorlan
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Isaac Morland ijmor...@uwaterloo.ca added the comment:
How different is this issue from Issue 1608579, Issue 1239890, Issue 1223238,
and Issue 1314067?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
Ray.Allen ysj@gmail.com added the comment:
If I understander correctly, Issue 1608579, Issue 1239890, Issue 1223238, and
Issue 1314067 all deal with the case that the intermediate directories already
exists during creating them caused by race condition, but if the target
directory(the
Terry J. Reedy tjre...@udel.edu added the comment:
Since this is a library issue, it can go into 3.2.
It is definitely a feature request, hence not in 2.7. Code that depends on the
exception suppression would crash on an earlier release.
Changes by Terry J. Reedy tjre...@udel.edu:
--
nosy: +draghuram, gagenellina, gvanrossum, zooko
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Changes by Éric Araujo mer...@netwok.org:
--
nosy: +merwok
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
___
Python-bugs-list mailing
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9299
___
Ray.Allen ysj@gmail.com added the comment:
Thanks for reviewing!
The name 'ensure_exist' for the new parameter strikes me as wrong, as well as
too long for something that will nearly always be set to True. The function
always ensures that the directory exists. The question is whether
22 matches
Mail list logo