-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-45354: Skip obsolete device name tests on Windows 11 #28712
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,9 +92,11 @@ def test_open_name(self): | |
f.close() | ||
f.close() | ||
|
||
f = open('C:/con', 'rb', buffering=0) | ||
self.assertIsInstance(f, ConIO) | ||
f.close() | ||
# bpo-45354: Windows 11 changed MS-DOS device name handling | ||
if sys.getwindowsversion()[:3] < (10, 0, 22000): | ||
f = open('C:/con', 'rb', buffering=0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both calls return a normalized pathname, not the device object name. That said, as the tests in question are originally from you, shouldn't the tests then be written in terms of _getfullpathname() ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meaning, instead of using open(), just check the results of _getfullpathname() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified the new behavior in Windows 11. If the path is qualified (i.e. contains slashes), only the "nul" device name appears to be reserved (e.g. "./nul" -> "\\.\nul"). The other DOS device names aren't reserved in a qualified path (e.g. "./com1" is just a regular file in the current working directory). DOS device names are still reserved in an unqualified relative path, but extensions are no longer ignored (e.g. "con.txt" is just a regular file). This means that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
self.assertIsInstance(f, ConIO) | ||
f.close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please modify the test to use "with f: ..."? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you notice, the rest of the test cases do not do that. Changing to context managers should probably be done as another issue. The only change here is moving the existing test into the if-block. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Leave it as it is. |
||
|
||
@unittest.skipIf(sys.getwindowsversion()[:2] <= (6, 1), | ||
"test does not work on Windows 7 and earlier") | ||
|
@@ -114,7 +116,8 @@ def test_conout_path(self): | |
conout_path = os.path.join(temp_path, 'CONOUT$') | ||
|
||
with open(conout_path, 'wb', buffering=0) as f: | ||
if sys.getwindowsversion()[:2] > (6, 1): | ||
# bpo-45354: Windows 11 changed MS-DOS device name handling | ||
if (6, 1) < sys.getwindowsversion()[:3] < (10, 0, 22000): | ||
self.assertIsInstance(f, ConIO) | ||
else: | ||
self.assertNotIsInstance(f, ConIO) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we'll want this to become a constant in the test suite soon enough, but doesn't have to be in this PR. Let's just keep an eye out for the next time it gets copied somewhere and then insist it gets centralised.