[New-bugs-announce] [issue22370] pathlib OS detection

Antony Lee report at bugs.python.org
Tue Sep 9 18:24:51 CEST 2014

New submission from Antony Lee:

Currently, pathlib contains the following check for the OS in the import section:

        import nt
    except ImportError:
        nt = None
        if sys.getwindowsversion()[:2] >= (6, 0):
            from nt import _getfinalpathname
            supports_symlinks = False
            _getfinalpathname = None

I would like to suggest to switch this on testing for the value of `os.name` (as `PurePath.__new__` does), or possibly testing whether `sys.getwindowsversion` exists: the `nt` module is not publicly defined, so it wouldn't be unreasonable to have a file named `nt.py` on an Unix system (where this shouldn't cause any problems), in which case importing `pathlib` raises an AttributeError at the `getwindowsversion` line.

components: Library (Lib)
messages: 226644
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: pathlib OS detection
versions: Python 3.4, Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list