Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pathlib OS detection #66565

Closed
anntzer mannequin opened this issue Sep 9, 2014 · 3 comments
Closed

pathlib OS detection #66565

anntzer mannequin opened this issue Sep 9, 2014 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Sep 9, 2014

BPO 22370
Nosy @pitrou, @serhiy-storchaka, @anntzer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/pitrou'
closed_at = <Date 2014-11-18.23:33:26.243>
created_at = <Date 2014-09-09.16:24:51.681>
labels = ['type-bug', 'library']
title = 'pathlib OS detection'
updated_at = <Date 2014-11-18.23:33:26.241>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2014-11-18.23:33:26.241>
actor = 'python-dev'
assignee = 'pitrou'
closed = True
closed_date = <Date 2014-11-18.23:33:26.243>
closer = 'python-dev'
components = ['Library (Lib)']
creation = <Date 2014-09-09.16:24:51.681>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 22370
keywords = []
message_count = 3.0
messages = ['226644', '231318', '231352']
nosy_count = 4.0
nosy_names = ['pitrou', 'python-dev', 'serhiy.storchaka', 'Antony.Lee']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue22370'
versions = ['Python 3.4', 'Python 3.5']

@anntzer
Copy link
Mannequin Author

anntzer mannequin commented Sep 9, 2014

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.

@anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Sep 9, 2014
@serhiy-storchaka serhiy-storchaka added the type-bug An unexpected behavior, bug, or error label Nov 18, 2014
@pitrou
Copy link
Member

pitrou commented Nov 18, 2014

This sounds reasonable, indeed.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Nov 18, 2014

New changeset cb1d7eac601d by Antoine Pitrou in branch '3.4':
Close bpo-22370: Windows detection in pathlib is now more robust.
https://hg.python.org/cpython/rev/cb1d7eac601d

New changeset 712f246da49b by Antoine Pitrou in branch 'default':
Close bpo-22370: Windows detection in pathlib is now more robust.
https://hg.python.org/cpython/rev/712f246da49b

@python-dev python-dev mannequin closed this as completed Nov 18, 2014
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants