Skip to content

Commit

Permalink
GH-69564: Clarify use of octal format of mode argument in help(os.chm…
Browse files Browse the repository at this point in the history
…od) (#20621)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
  • Loading branch information
amaajemyfren and kumaraditya303 authored Dec 21, 2022
1 parent d713c54 commit bbf4a66
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify use of octal format of mode argument in help(os.chmod) as well as help(os.fchmod)
13 changes: 12 additions & 1 deletion Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3173,6 +3173,9 @@ os.chmod
mode: int
Operating-system mode bitfield.
Be careful when using number literals for *mode*. The conventional UNIX notation for
numeric modes uses an octal base, which needs to be indicated with a ``0o`` prefix in
Python.
*
Expand All @@ -3198,7 +3201,7 @@ dir_fd and follow_symlinks may not be implemented on your platform.
static PyObject *
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
int follow_symlinks)
/*[clinic end generated code: output=5cf6a94915cc7bff input=989081551c00293b]*/
/*[clinic end generated code: output=5cf6a94915cc7bff input=674a14bc998de09d]*/
{
int result;

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

static PyObject *
os_fchmod_impl(PyObject *module, int fd, int mode)
/*[clinic end generated code: output=afd9bc05b4e426b3 input=8ab11975ca01ee5b]*/
/*[clinic end generated code: output=afd9bc05b4e426b3 input=b5594618bbbc22df]*/
{
int res;
int async_err = 0;
Expand Down

0 comments on commit bbf4a66

Please sign in to comment.