-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-138712: Add os.NODEV #138728
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
gh-138712: Add os.NODEV #138728
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 |
---|---|---|
|
@@ -757,12 +757,30 @@ def test_makedev(self): | |
self.assertRaises((ValueError, OverflowError), posix.makedev, x, minor) | ||
self.assertRaises((ValueError, OverflowError), posix.makedev, major, x) | ||
|
||
if sys.platform == 'linux' and not support.linked_to_musl(): | ||
NODEV = -1 | ||
# The following tests are needed to test functions accepting or | ||
# returning the special value NODEV (if it is defined). major(), minor() | ||
# and makefile() are the only easily reproducible examples, but that | ||
# behavior is platform specific -- on some platforms their code has | ||
# a special case for NODEV, on others this is just an implementation | ||
# artifact. | ||
if (hasattr(posix, 'NODEV') and | ||
sys.platform.startswith(('linux', 'macos', 'freebsd', 'dragonfly', | ||
'sunos'))): | ||
NODEV = posix.NODEV | ||
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. Is this code path still skipped on Alpine Linux (musl)? 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 is skipped if NODEV is not defined in musl. But if it is defined, the following tests will fail, so we will need to add an additional condition. |
||
self.assertEqual(posix.major(NODEV), NODEV) | ||
self.assertEqual(posix.minor(NODEV), NODEV) | ||
self.assertEqual(posix.makedev(NODEV, NODEV), NODEV) | ||
|
||
def test_nodev(self): | ||
# NODEV is not a part of Posix, but is defined on many systems. | ||
if (not hasattr(posix, 'NODEV') | ||
and (not sys.platform.startswith(('linux', 'macos', 'freebsd', | ||
'dragonfly', 'netbsd', 'openbsd', | ||
'sunos')) | ||
or support.linked_to_musl())): | ||
self.skipTest('not defined on this platform') | ||
self.assertHasAttr(posix, 'NODEV') | ||
|
||
def _test_all_chown_common(self, chown_func, first_param, stat_func): | ||
"""Common code for chown, fchown and lchown tests.""" | ||
def check_stat(uid, gid): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add :const:`os.NODEV`. |
Uh oh!
There was an error while loading. Please reload this page.