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.

Title: add os.chflags() and os.lchflags() where available
Type: Stage:
Components: Extension Modules Versions: Python 2.5
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: loewis Nosy List: georg.brandl, levinsm, loewis, nnorwitz
Priority: normal Keywords: patch

Created on 2006-05-17 11:45 by levinsm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
chflags-patch levinsm, 2006-05-17 11:45 patch
updated-chflags-patch levinsm, 2006-05-19 11:47 revised version of patch
chflags.diff loewis, 2007-03-21 16:46
Messages (9)
msg50263 - (view) Author: M. Levinson (levinsm) Date: 2006-05-17 11:45
The return value from os.stat() includes st_flags on some systems, but
currently there's not much that can be done with the value; this patch aims
to make st_flags useful by adding some associated constants to and
the corresponding chflags() and lchflags() functions in posixmodule. For
completeness, shutil.copystat() is also updated to call os.chflags() where
it's available.
msg50264 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-17 14:24
Logged In: YES 

Patch looks good. Do we want to include it?
msg50265 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-05-19 07:31
Logged In: YES 

What operating systems is this available on?  The only one
I've found is OS X.  The man page says it's from BSD 4.4.  I
tried on Linux of various flavors (4+), Solaris, and Tru64.
 None of them had chflags.  I also could only find some of
the flags in my sys/stat.h that were added to 

As far as the patch itself, it looks good.  There are a
couple of changes if this should be accepted though:  doc
needs \versionadded{2.5}, I would prefer flags as the var
name rather than i in posixmodule.c (btw you shouldn't need
to init path).

Also would need to update Misc/NEWS and ACKS if accepted.
msg50266 - (view) Author: M. Levinson (levinsm) Date: 2006-05-19 11:47
Logged In: YES 

In addition to MacOS, chflags(2) is available on FreeBSD,
OpenBSD, and
NetBSD. The flags in Lib/ are the full set of
available values
although, as you noted, MacOS hasn't (yet) implemented
several of them.

Thanks for the comments - I've attached an updated version
of the patch
incorporating your suggestions.
msg50267 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-02-19 10:56
Thanks for the patch. Committed as r53826.
msg50268 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-03-20 06:42
It looks like Tru64 does have some version of chflags, however, it is undocumented and apparently causes  python to exit.  It is at least one of the reasons for the recent buildbot failures:

That doesn't really tell the whole story, but I logged on to the machine and ran the test, after modifying unittest to flush the stream, sigh :-( and got this:

ringneck:/net/cci/nnorwitz/python/trunk.norwitz-tru64/nn-work-build % ./python -E -tt ./Lib/test/ -v test_posix
testNoArgFunctions (test.test_posix.PosixTester) ... ok
test_access (test.test_posix.PosixTester) ... ok
test_chdir (test.test_posix.PosixTester) ... ok
test_chflags (test.test_posix.PosixTester) ... Bad system call
msg50269 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-03-21 16:46
nnorwitz, can you please report whether the attached patch fixes it?
File Added: chflags.diff
msg56988 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-10-31 06:03
Martin's patch from 2007-03-21 fixed the problem with test_posix.  It
now passes all the tests (test_posix and rest of test suite).  The
tests/interpreter do not exit prematurely.

I think it is good to apply this patch.
msg58179 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-12-04 08:38
Committed chflags.diff as r59317.
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43370
2007-12-04 08:38:26loewissetstatus: open -> closed
messages: + msg58179
2007-10-31 06:03:45nnorwitzsetassignee: nnorwitz -> loewis
messages: + msg56988
2006-05-17 11:45:34levinsmcreate