Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,13 @@ always available.
``cache_tag`` is set to ``None``, it indicates that module caching should
be disabled.

*arch* The build architecture of the current interpreter is determined by the
platform for which it was built (which may be different from the current hardware).

.. versionadded:: 3.14

.. availability:: Windows.

:data:`sys.implementation` may contain additional attributes specific to
the Python implementation. These non-standard attributes must start with
an underscore, and are not described here. Regardless of its contents,
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,10 @@ def test_implementation(self):
self.assertEqual(sys.implementation.name,
sys.implementation.name.lower())

if hasattr(sys.implementation, 'arch'):
self.assertIn(sys.implementation.arch,
['win32', 'amd64', 'arm32', 'arm64', ''])

@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 ``arch`` attribute to :data:`sys.implementation`
to describe the current system platform.
6 changes: 5 additions & 1 deletion PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,11 @@
<ClCompile Include="..\Python\structmember.c" />
<ClCompile Include="..\Python\symtable.c" />
<ClCompile Include="..\Python\sysmodule.c">
<PreprocessorDefinitions>VPATH="$(PyVPath)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>
ARCH_NAME="$(ArchName)";
VPATH="$(PyVPath)";
%(PreprocessorDefinitions)
</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\Python\thread.c" />
<ClCompile Include="..\Python\traceback.c" />
Expand Down
12 changes: 12 additions & 0 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3358,6 +3358,18 @@ make_impl_info(PyObject *version_info)
if (res < 0)
goto error;

#ifdef ARCH_NAME
value = PyUnicode_FromString(ARCH_NAME);
if (value == NULL) {
goto error;
}
res = PyDict_SetItemString(impl_info, "arch", value);
Py_DECREF(value);
if (res < 0) {
goto error;
}
#endif

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