New submission from Antony Lee:

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

    try:
        import nt
    except ImportError:
        nt = None
    else:
        if sys.getwindowsversion()[:2] >= (6, 0):
            from nt import _getfinalpathname
        else:
            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 <rep...@bugs.python.org>
<http://bugs.python.org/issue22370>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to