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 phillmac
Recipients paul.moore, phillmac, steve.dower, tim.golden, zach.ware
Date 2020-08-13.02:29:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1597285797.92.0.269181951645.issue41536@roundup.psfhosted.org>
In-reply-to
Content
I'm looking for the equivalent windows functionality to the posix `/dev/null` file, and I discovered `NUL:`

This snippet works on a windows OS, proving that it is indeed a writable file: `Path('NUL:').write_text('abcd')`

However, `Path('NUL:').resolve()` Throws an exception `OSError: [WinError 87] The parameter is incorrect: 'NUL:'`

Is this the expected behaviour? I.E. I should wrap the call to `resolve()` in a `try...except`?

If I catch all `OSError` types, how can I determine if it's a legitimate error or not?

E.G. Full console output:

    Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from pathlib import Path
    >>> Path('NUL:')
    WindowsPath('NUL:')
    >>> Path('NUL:').write_text('abcd')
    4
    >>> Path('NUL:').resolve()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Program Files\Python37\lib\pathlib.py", line 1134, in resolve
        s = self._flavour.resolve(self, strict=strict)
      File "C:\Program Files\Python37\lib\pathlib.py", line 192, in resolve
        s = self._ext_to_normal(_getfinalpathname(s))
    OSError: [WinError 87] The parameter is incorrect: 'NUL:'
History
Date User Action Args
2020-08-13 02:29:57phillmacsetrecipients: + phillmac, paul.moore, tim.golden, zach.ware, steve.dower
2020-08-13 02:29:57phillmacsetmessageid: <1597285797.92.0.269181951645.issue41536@roundup.psfhosted.org>
2020-08-13 02:29:57phillmaclinkissue41536 messages
2020-08-13 02:29:57phillmaccreate