On Fri, Feb 22, 2019 at 09:21:07PM +0100, Karsten Hilbert wrote:

> Am I confused ?
> 
>       ncq@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
>       False
>       >>> 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.

Because, naively, I'd have assumed this to work:

        os.chmod(directory, mode, follow_symlinks = (os.chmod in 
os.supports_follow_symlinks))

Karsten
-- 
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to