diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-26 13:53:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-26 13:53:00 (GMT) |
commit | 45ffab40e86777ecd49786a2c18c0c044ef0cb5b (patch) | |
tree | 0e97b8faebefab094453e73a5544a8e72c112c32 /Lib | |
parent | 3e3980b49e6c089b6f9fe74bae97458c643233a9 (diff) | |
download | cpython-45ffab40e86777ecd49786a2c18c0c044ef0cb5b.zip cpython-45ffab40e86777ecd49786a2c18c0c044ef0cb5b.tar.gz cpython-45ffab40e86777ecd49786a2c18c0c044ef0cb5b.tar.bz2 |
gh-97966: Restore prior expectation that uname_result._fields and ._asdict would include the processor. (gh-98343)
(cherry picked from commit dc063a25d29840d863b15c86fdab15b4a1894c73)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/platform.py | 6 | ||||
-rw-r--r-- | Lib/test/test_platform.py | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Lib/platform.py b/Lib/platform.py index c272c40..9e9f3af 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -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()) @@ -798,7 +800,7 @@ class uname_result( @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)}' @@ -812,7 +814,7 @@ class uname_result( 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 9b2cd20..c9f2757 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -269,6 +269,14 @@ class PlatformTest(unittest.TestCase): 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): |