Skip to content

Commit bbf4a66

Browse files
GH-69564: Clarify use of octal format of mode argument in help(os.chmod) (#20621)
Co-authored-by: Kumar Aditya <[email protected]>
1 parent d713c54 commit bbf4a66

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify use of octal format of mode argument in help(os.chmod) as well as help(os.fchmod)

Modules/clinic/posixmodule.c.h

+12-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,9 @@ os.chmod
31733173
31743174
mode: int
31753175
Operating-system mode bitfield.
3176+
Be careful when using number literals for *mode*. The conventional UNIX notation for
3177+
numeric modes uses an octal base, which needs to be indicated with a ``0o`` prefix in
3178+
Python.
31763179
31773180
*
31783181
@@ -3198,7 +3201,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
31983201
static PyObject *
31993202
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
32003203
int follow_symlinks)
3201-
/*[clinic end generated code: output=5cf6a94915cc7bff input=989081551c00293b]*/
3204+
/*[clinic end generated code: output=5cf6a94915cc7bff input=674a14bc998de09d]*/
32023205
{
32033206
int result;
32043207

@@ -3328,7 +3331,12 @@ os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
33283331
os.fchmod
33293332
33303333
fd: int
3334+
The file descriptor of the file to be modified.
33313335
mode: int
3336+
Operating-system mode bitfield.
3337+
Be careful when using number literals for *mode*. The conventional UNIX notation for
3338+
numeric modes uses an octal base, which needs to be indicated with a ``0o`` prefix in
3339+
Python.
33323340
33333341
Change the access permissions of the file given by file descriptor fd.
33343342
@@ -3337,7 +3345,7 @@ Equivalent to os.chmod(fd, mode).
33373345

33383346
static PyObject *
33393347
os_fchmod_impl(PyObject *module, int fd, int mode)
3340-
/*[clinic end generated code: output=afd9bc05b4e426b3 input=8ab11975ca01ee5b]*/
3348+
/*[clinic end generated code: output=afd9bc05b4e426b3 input=b5594618bbbc22df]*/
33413349
{
33423350
int res;
33433351
int async_err = 0;

0 commit comments

Comments
 (0)