confusion with os.chmod() and follow_symlinks

Karsten Hilbert Karsten.Hilbert at
Fri Feb 22 15:21:07 EST 2019

Am I confused ?

	ncq at hermes:~$ python3
	Python 3.7.2+ (default, Feb  2 2019, 14:31:48)
	[GCC 8.2.0] on linux
	Type "help", "copyright", "credits" or "license" for more information.
	>>> import os
	>>> print(os.supports_follow_symlinks)
	{<built-in function utime>, <built-in function chown>, <built-in function access>, <built-in function stat>, <built-in function link>}
	>>> os.chmod in os.supports_follow_symlinks
	>>> os.chmod('/tmp/test', 0o0700, follow_symlinks = False)
	Traceback (most recent call last):
	  File "<stdin>", line 1, in <module>
	NotImplementedError: chmod: follow_symlinks unavailable on this platform

I would only have expected this exception when I actually
request the unavailable functionality, like so:

	os.chmod('/tmp/test', 0o0700, follow_symlinks = True)

This, however, works:

		os.chmod('/tmp/test', 0o0700)

DESPITE the documentation saying

	os.chmod(path, mode, *, dir_fd=None, follow_symlinks=True)

IOW, the default for <follow_symlinks> being "True", which is
certainly illogical to succeed when it is not even supported
on this platform.

Where is my reasoning going astray ?

GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

More information about the Python-list mailing list