-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
While merging #115321 I've noticed a similar issue to #115320:
Lines 1661 to 1699 in 207030f
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwMajorVersion)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwMinorVersion)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwBuildNumber)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.dwPlatformId)); | |
PyStructSequence_SET_ITEM(version, pos++, PyUnicode_FromWideChar(ver.szCSDVersion, -1)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wServicePackMajor)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wServicePackMinor)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wSuiteMask)); | |
PyStructSequence_SET_ITEM(version, pos++, PyLong_FromLong(ver.wProductType)); | |
// GetVersion will lie if we are running in a compatibility mode. | |
// We need to read the version info from a system file resource | |
// to accurately identify the OS version. If we fail for any reason, | |
// just return whatever GetVersion said. | |
PyObject *realVersion = _sys_getwindowsversion_from_kernel32(); | |
if (!realVersion) { | |
PyErr_Clear(); | |
realVersion = Py_BuildValue("(kkk)", | |
ver.dwMajorVersion, | |
ver.dwMinorVersion, | |
ver.dwBuildNumber | |
); | |
} | |
if (realVersion) { | |
PyStructSequence_SET_ITEM(version, pos++, realVersion); | |
} | |
if (PyErr_Occurred()) { | |
Py_DECREF(version); | |
return NULL; | |
} | |
if (PyObject_SetAttrString(module, "_cached_windows_version", version) < 0) { | |
Py_DECREF(version); | |
return NULL; | |
} | |
return version; |
It can also overwrite errors, I will send a PR similar to #115321 to fix this as well.
Linked PRs
Eclips4
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error