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.

Author eryksun
Recipients Antony.Lee, eryksun, itaisteinherz, paul.moore, steve.dower, tim.golden, zach.ware
Date 2022-03-13.20:39:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647203968.36.0.831675353594.issue46785@roundup.psfhosted.org>
In-reply-to
Content
> 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
History
Date User Action Args
2022-03-13 20:39:28eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, Antony.Lee, steve.dower, itaisteinherz
2022-03-13 20:39:28eryksunsetmessageid: <1647203968.36.0.831675353594.issue46785@roundup.psfhosted.org>
2022-03-13 20:39:28eryksunlinkissue46785 messages
2022-03-13 20:39:28eryksuncreate