Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 801c08d

Browse files
committed
Define version_info to be a tuple (major, minor, micro, level); level
is a string "a2", "b1", "c1", or '' for a final release. Added version_info and hexversion to the module docstring.
1 parent 3155db3 commit 801c08d

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Python/sysmodule.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ Static objects:\n\
352352
\n\
353353
maxint -- the largest supported integer (the smallest is -maxint-1)\n\
354354
builtin_module_names -- tuple of module names built into this intepreter\n\
355-
version -- the version of this interpreter\n\
355+
version -- the version of this interpreter as a string\n\
356+
version_info -- version information as a tuple\n\
357+
hexversion -- version information encoded as a single integer\n\
356358
copyright -- copyright notice pertaining to this interpreter\n\
357359
platform -- platform identifier\n\
358360
executable -- pathname of this Python interpreter\n\
@@ -406,6 +408,22 @@ _PySys_Init()
406408
PyDict_SetItemString(sysdict, "hexversion",
407409
v = PyInt_FromLong(PY_VERSION_HEX));
408410
Py_XDECREF(v);
411+
#if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
412+
v = PyString_FromStringAndSize(NULL, 0);
413+
#else
414+
{
415+
char buff[3];
416+
buff[0] = PY_RELEASE_LEVEL - PY_RELEASE_LEVEL_ALPHA + 'a';
417+
buff[1] = PY_RELEASE_SERIAL + '0';
418+
buff[2] = '\0';
419+
v = PyString_FromString(buff);
420+
}
421+
#endif /* PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL */
422+
PyDict_SetItemString(sysdict, "version_info",
423+
v = Py_BuildValue("iiiN", PY_MAJOR_VERSION,
424+
PY_MINOR_VERSION,
425+
PY_MICRO_VERSION, v));
426+
Py_XDECREF(v);
409427
PyDict_SetItemString(sysdict, "copyright",
410428
v = PyString_FromString(Py_GetCopyright()));
411429
Py_XDECREF(v);

0 commit comments

Comments
 (0)