Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,7 @@ def test_implementation(self):
self.assertTrue(hasattr(sys.implementation, 'version'))
self.assertTrue(hasattr(sys.implementation, 'hexversion'))
self.assertTrue(hasattr(sys.implementation, 'cache_tag'))
self.assertTrue(hasattr(sys.implementation, '_architecture'))

version = sys.implementation.version
self.assertEqual(version[:2], (version.major, version.minor))
Expand All @@ -1032,6 +1033,8 @@ def test_implementation(self):
self.assertEqual(sys.implementation.name,
sys.implementation.name.lower())

self.assertEqual(sys.implementation._architecture, sys.platform)

@test.support.cpython_only
def test_debugmallocstats(self):
# Test sys._debugmallocstats()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added ``_architecture`` attribute to :data:`sys.implementation`
to describe the current system platform.
8 changes: 8 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3358,6 +3358,14 @@ make_impl_info(PyObject *version_info)
if (res < 0)
goto error;

value = PyUnicode_FromString(Py_GetPlatform());
if (value == NULL)
goto error;
res = PyDict_SetItemString(impl_info, "_architecture", value);
Py_DECREF(value);
if (res < 0)
goto error;

#ifdef MULTIARCH
value = PyUnicode_FromString(MULTIARCH);
if (value == NULL)
Expand Down
Loading