summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-07-09 14:22:12 -0400
committerBrett Cannon <brett@python.org>2012-07-09 14:22:12 -0400
commit2218bc0c7a4c4a2df3126cc840b3a2718b0be65e (patch)
tree893bad11e8e09ae912e1fcbab619a4cb7a931393 /Python/sysmodule.c
parent07ba56b984dd5933c2e30a6e8bb91c2b67bfcdb7 (diff)
downloadcpython-2218bc0c7a4c4a2df3126cc840b3a2718b0be65e.tar.gz
Issue #15242: Have PyImport_GetMagicTag() return a const char *
defined in sysmodule.c instead of straight out of a Unicode object. Thanks to Amaury Forgeot d'Arc for noticing the bug and Eric Snow for writing the patch.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ce5e8258d1..20bfa555b3 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1478,6 +1478,22 @@ make_version_info(void)
return version_info;
}
+/* sys.implementation values */
+#define NAME "cpython"
+const char *_PySys_ImplName = NAME;
+#define QUOTE(arg) #arg
+#define STRIFY(name) QUOTE(name)
+#define MAJOR STRIFY(PY_MAJOR_VERSION)
+#define MINOR STRIFY(PY_MINOR_VERSION)
+#define TAG NAME "-" MAJOR MINOR;
+const char *_PySys_ImplCacheTag = TAG;
+#undef NAME
+#undef QUOTE
+#undef STRIFY
+#undef MAJOR
+#undef MINOR
+#undef TAG
+
static PyObject *
make_impl_info(PyObject *version_info)
{
@@ -1490,13 +1506,7 @@ make_impl_info(PyObject *version_info)
/* populate the dict */
-#define NAME "cpython"
-#define QUOTE(arg) #arg
-#define STRIFY(name) QUOTE(name)
-#define MAJOR STRIFY(PY_MAJOR_VERSION)
-#define MINOR STRIFY(PY_MINOR_VERSION)
-#define TAG NAME "-" MAJOR MINOR
- value = PyUnicode_FromString(NAME);
+ value = PyUnicode_FromString(_PySys_ImplName);
if (value == NULL)
goto error;
res = PyDict_SetItemString(impl_info, "name", value);
@@ -1504,19 +1514,13 @@ make_impl_info(PyObject *version_info)
if (res < 0)
goto error;
- value = PyUnicode_FromString(TAG);
+ value = PyUnicode_FromString(_PySys_ImplCacheTag);
if (value == NULL)
goto error;
res = PyDict_SetItemString(impl_info, "cache_tag", value);
Py_DECREF(value);
if (res < 0)
goto error;
-#undef NAME
-#undef QUOTE
-#undef STRIFY
-#undef MAJOR
-#undef MINOR
-#undef TAG
res = PyDict_SetItemString(impl_info, "version", version_info);
if (res < 0)