Eryk Sun <eryk...@gmail.com> added the comment:

> Why catch ERROR_NOT_READY and ERROR_BAD_NET_NAME as well?

When os.stat() falls back on FindFirstFileW(), an error that means the file 
doesn't exist should be kept. ERROR_BAD_NET_NAME is an obvious error to keep 
because it's already mapped to ENOENT (i.e. file not found). This error 
typically means that share was removed or the network went down. 
ERROR_NOT_READY typically means that the media was removed from a volume (e.g. 
ejected disk). pathlib.Path.exists() returns False for ERROR_NOT_READY.

> Why can't the filename of the "foo"-like file in the test be 
> simply os_helper.TESTFN, as done in some other tests?

I suppose the current working directory will be fine. I was looking to keep the 
test on a NTFS filesystem, with known behavior, but there's no hard guarantee 
that the user's temp directory is on the system volume.

> I noticed some code snippets used in tests are wrapped in a 
> seemingly-redundant `if 1: ...` statement. Why is that?

The `if 1` test is logically redundant but convenient for using a multiline 
string that has an arbitrary indentation level. For example:

    >>> exec('''
    ...         print(42)
    ... ''')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<string>", line 2
        print(42)
    IndentationError: unexpected indent

    >>> exec('''if 1:
    ...         print(42)
    ... ''')
    42

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46785>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to