10000 [3.11] gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343) by miss-islington · Pull Request #99793 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343) #99793

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

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ class uname_result(
except when needed.
"""

_fields = ('system', 'node', 'release', 'version', 'machine', 'processor')

@functools.cached_property
def processor(self):
return _unknown_as_blank(_Processor.get())
Expand All @@ -798,7 +800,7 @@ def __iter__(self):
@classmethod
def _make(cls, iterable):
# override factory to affect length check
num_fields = len(cls._fields)
num_fields = len(cls._fields) - 1
result = cls.__new__(cls, *iterable)
if len(result) != num_fields + 1:
msg = f'Expected {num_fields} arguments, got {len(result)}'
Expand All @@ -812,7 +814,7 @@ def __len__(self):
return len(tuple(iter(self)))

def __reduce__(self):
return uname_result, tuple(self)[:len(self._fields)]
return uname_result, tuple(self)[:len(self._fields) - 1]


_uname_cache = None
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ def test_uname_slices(self):
self.assertEqual(res[:], expected)
self.assertEqual(res[:5], expected[:5])

def test_uname_fields(self):
self.assertIn('processor', platform.uname()._fields)

def test_uname_asdict(self):
res = platform.uname()._asdict()
self.assertEqual(len(res), 6)
self.assertIn('processor', res)

@unittest.skipIf(sys.platform in ['win32', 'OpenVMS'], "uname -p not used")
@support.requires_subprocess()
def test_uname_processor(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On ``uname_result``, restored expectation that ``_fields`` and ``_asdict``
would include all six properties including ``processor``.
0