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 expect_ok=True test_os failure when directory has S_ISGID bit set
Type: Stage:
Components: Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: gregory.p.smith, python-dev, r.david.murray
Priority: normal Keywords:

Created on 2012-06-03 19:16 by gregory.p.smith, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg162228 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2012-06-03 19:16
======================================================================
ERROR: test_exist_ok_existing_directory (__main__.MakedirTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "Lib/test/test_os.py", line 842, in test_exist_ok_existing_directory
    os.makedirs(path, mode=mode, exist_ok=True)
  File "/home/greg/sandbox/python/cpython/default/Lib/os.py", line 161, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists (mode 0o2755 != desired mode 0o755): '@test_4027_tmp/dir1'

(I modified os.makedirs to add the info on the mode differences above to highlight the source of the problem)

0o2000 is the S_ISGID bit on a directory which is a "contagious" bit that is automatically copied onto subdirectories.  os.makedirs is not expecting to find it so exist_ok does not work as desired.

Workaround: Don't run the Python test suite from a directory with that bit set.

I think the os.makedirs() behavior should be to ignore bits that can appear regardless of the umask as it makes exist_ok=True useless in that situation.
msg162234 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-06-03 21:36
New changeset fef529f3de5b by Gregory P. Smith in branch '3.2':
Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
http://hg.python.org/cpython/rev/fef529f3de5b

New changeset eed26e508b7e by Gregory P. Smith in branch 'default':
Fixes Issue #14992: os.makedirs(path, exist_ok=True) would raise an OSError
http://hg.python.org/cpython/rev/eed26e508b7e
msg162969 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-06-16 13:49
See also issue 13498.
msg167758 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-08-09 04:03
New changeset 3f42c9dbd8a7 by Ned Deily in branch '3.2':
Issue #14992: Prevent test_os test_exist_ok_s_isgid_directory test case
http://hg.python.org/cpython/rev/3f42c9dbd8a7

New changeset a1c8c79e035d by Ned Deily in branch 'default':
Issue #14992: merge from 3.2
http://hg.python.org/cpython/rev/a1c8c79e035d
History
Date User Action Args
2022-04-11 14:57:31adminsetgithub: 59197
2012-08-09 04:03:48python-devsetmessages: + msg167758
2012-06-16 13:49:59r.david.murraysetnosy: + r.david.murray
messages: + msg162969
2012-06-03 21:42:29gregory.p.smithsetstatus: open -> closed
assignee: gregory.p.smith
resolution: fixed
2012-06-03 21:36:53python-devsetnosy: + python-dev
messages: + msg162234
2012-06-03 20:51:05gregory.p.smithsetversions: + Python 3.2
2012-06-03 19:16:34gregory.p.smithcreate