Issue 7450: document that os.chmod accepts an octal digit mode (original) (raw)

Created on 2009-12-07 15:54 by clutchski, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg96060 - (view) Author: clutchski (clutchski) Date: 2009-12-07 15:54
It would be helpful to explicitly document that os.chmod accepts octal digit modes e.g. os.chmod(path, 0755). This is much more user friendly than saying you must OR bit constants kept in a completely different module. It could be argued that this change would be make the abstraction leaky, since the values of the stat.S_I* constants could change, but in practice, this seems unlikely.
msg96075 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-12-07 21:13
I think you misunderstand what's happening. It's not that os.chmod accepts octal digits, but Python: py> 04732 2522 So the support for octal numbers isn't something that chmod deserves credit for.
msg96081 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-12-07 22:48
If using octal digits instead of the stat.S_I constants is acceptable, I'd be +1 to add a note to the documentation (something like "mode could be a number (possibly expressed in octal form, such as 0755), one of the following values (as defined in the stat module), or a bitwise ORed combinations of them:").
msg113185 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-07 17:11
(3.1.2) 15.1.5. Files and Directories os.chmode entry: I recommend changing the first sentence "Change the mode of path to the numeric mode." to "Change the mode of path to the integer mode (such as 0x755)." For 2.7, delete the 'x'. This should make it clear to Unix users that they can use the usual octal designations.
msg113235 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-08-08 05:37
I guess you mean 0o755. I think it would be better to mention explicitly octal literals, since they are not so common and, especially in 2.x, 0755 might be confused with a "normal" decimal number.
msg118807 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-15 17:20
We now have the S_IXXX constants documented explicitly, so I don't think this change is needed.
History
Date User Action Args
2022-04-11 14:56:55 admin set github: 51699
2010-10-15 17:20:21 georg.brandl set status: open -> closedresolution: works for memessages: +
2010-08-08 05:37:55 ezio.melotti set messages: +
2010-08-07 17:11:24 terry.reedy set versions: - Python 2.6nosy: + terry.reedy, docs@pythonmessages: + assignee: georg.brandl -> docs@pythonkeywords: + patch, easy
2009-12-07 22:49:00 ezio.melotti set priority: normaltype: enhancementversions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2nosy: + ezio.melottimessages: + stage: needs patch
2009-12-07 21:13:52 loewis set nosy: + loewismessages: +
2009-12-07 15:54:18 clutchski create