Title: Wrong paths from nt._getfinalpathname with DOS device selectors in the CWD · Issue #112563 · python/cpython · GitHub
Open Graph Title: Wrong paths from nt._getfinalpathname with DOS device selectors in the CWD · Issue #112563 · python/cpython
X Title: Wrong paths from nt._getfinalpathname with DOS device selectors in the CWD · Issue #112563 · python/cpython
Description: Bug report Bug description: In Windows if the CWD has a device selector \\.\ or \\?\ any function dependent on nt._getfullpathname may change the meaning of the path. import os import ntpath os.chdir('\\\\?\\C:\\') # any path with a devi...
Open Graph Description: Bug report Bug description: In Windows if the CWD has a device selector \\.\ or \\?\ any function dependent on nt._getfullpathname may change the meaning of the path. import os import ntpath os.chd...
X Description: Bug report Bug description: In Windows if the CWD has a device selector \\.\ or \\?\ any function dependent on nt._getfullpathname may change the meaning of the path. import os import ntpath os.chd...
Opengraph URL: https://github.com/python/cpython/issues/112563
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong paths from nt._getfinalpathname with DOS device selectors in the CWD","articleBody":"# Bug report\n\n### Bug description:\n\nIn Windows if the CWD has a device selector `\\\\.\\` or `\\\\?\\` any function dependent on `nt._getfullpathname` may change the meaning of the path.\n\n```python\nimport os\nimport ntpath\nos.chdir('\\\\\\\\?\\\\C:\\\\') # any path with a device selector\nprint(ntpath.abspath('\\\\')) # NOTE: single slash character\n```\n\nThat code will print `\\\\`\nand I mean 2 slashes, not an escaped one.\n\nSo if you use:\n```python\nprint(ntpath.abspath('\\\\Some\\\\Path')) # single slash before each component\n```\n\nThe result is `\\\\Some\\Path`.\nThat is an UNC network share, not a file named `Path` a couple of levels down from the root of the volume.\nPerhaps there are security concerns there.\n\nAnd if the CWD is a volume root, or drive device root, then:\n\n```python\nos.chdir('\\\\\\\\.\\\\C:\\\\') # or \\\\?\\Volume{GUID}\\\nprint(ntpath.abspath('.')) # current directory\n```\n\nThat will show `\\\\.\\C:`\nwhich is a device block, which means `os.scandir` would raise an error with that path.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nWindows","author":{"url":"https://github.com/CarlitoGil","@type":"Person","name":"CarlitoGil"},"datePublished":"2023-11-30T21:51:28Z","url":"https://github.com/python/cpython/issues/112563"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:018d48bd-edba-fce7-44de-4950c20a1783 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC30:20AA01:442C9E1:56702F1:6B021B26 |
| html-safe-nonce | 9d89cfb44c832f8dd77efbf769b11001ead3402118e8dd1ff8ee59cbf60e12fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzMwOjIwQUEwMTo0NDJDOUUxOjU2NzAyRjE6NkIwMjFCMjYiLCJ2aXNpdG9yX2lkIjoiNzg2MTI0NDAzNDI2NDczNDUwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5dc20d5efb83d5139884c213cb50cd5adb5e4b0fe41e0f21b72ae6628a1d42d5 |
| hovercard-subject-tag | issue:2019568544 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/112563/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ae98c673a2595e4e301a626a7330b5cc39883baaff55dcee6ba583e326da039/python/cpython/issues/112563 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ae98c673a2595e4e301a626a7330b5cc39883baaff55dcee6ba583e326da039/python/cpython/issues/112563 |
| og:image:alt | Bug report Bug description: In Windows if the CWD has a device selector \\.\ or \\?\ any function dependent on nt._getfullpathname may change the meaning of the path. import os import ntpath os.chd... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | CarlitoGil |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width