[Python-checkins] gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343)
jaraco
webhook-mailer at python.org
Sat Nov 26 08:28:55 EST 2022
https://github.com/python/cpython/commit/dc063a25d29840d863b15c86fdab15b4a1894c73
commit: dc063a25d29840d863b15c86fdab15b4a1894c73
branch: main
author: Jason R. Coombs <jaraco at jaraco.com>
committer: jaraco <jaraco at jaraco.com>
date: 2022-11-26T08:28:49-05:00
summary:
gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343)
files:
A Misc/NEWS.d/next/Library/2022-10-16-18-52-00.gh-issue-97966.humlhz.rst
M Lib/platform.py
M Lib/test/test_platform.py
diff --git a/Lib/platform.py b/Lib/platform.py
index 9f5b31728753..6745321e31c2 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -847,6 +847,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())
@@ -860,7 +862,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)}'
@@ -874,7 +876,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
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 9c03a89fd57d..3992faf8e5cd 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -277,6 +277,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):
diff --git a/Misc/NEWS.d/next/Library/2022-10-16-18-52-00.gh-issue-97966.humlhz.rst b/Misc/NEWS.d/next/Library/2022-10-16-18-52-00.gh-issue-97966.humlhz.rst
new file mode 100644
index 000000000000..b725465ae4f0
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-10-16-18-52-00.gh-issue-97966.humlhz.rst
@@ -0,0 +1,2 @@
+On ``uname_result``, restored expectation that ``_fields`` and ``_asdict``
+would include all six properties including ``processor``.
More information about the Python-checkins
mailing list