This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow
Date 2014-04-19.22:17:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Py_GetVersion() (in Python/getversion.c) builds the version string returned by sys.version:

  PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s",
            PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler());

In turn, Py_GetBuildInfo() (in Modules/getbuildinfo.c) returns the "build" portion of Python's version string.  When available, the tag returned by "hg id -t" constitutes part of that build string.

The problem is that when using mqueue the result of "hg id -t" can be pretty long.  For example:

  issue21226-fix-PyImport_ExecCodeModuleObject.diff qbase qtip tip

That's 74 characters for just part of a build string that may be well over 100 characters.  However, Py_GetVersion() truncates it to 80 characters.

The consequence is that this value of sys.version causes platform._sys_version() to fail since the version string does not match the expected pattern.

So either Py_GetVersion() should relax (-1) or Py_GetBuildInfo() should restrict the length of the resulting build string (+1).  Would it work to truncate just the hgid part so that the whole string returned by Py_GetBuildInfo() is no more than length 80?  E.g.

-    PyOS_snprintf(buildinfo, sizeof(buildinfo),
-                  "%s%s%s, %.20s, %.9s", hgid, sep, revision, DATE, TIME);
+    PyOS_snprintf(buildinfo, 80,
+                  "%.43s%.1s%.13s, %.20s, %.9s", hgid, sep, revision, DATE, TIME);
Date User Action Args
2014-04-19 22:17:18eric.snowsetrecipients: + eric.snow
2014-04-19 22:17:18eric.snowsetmessageid: <>
2014-04-19 22:17:18eric.snowlinkissue21313 messages
2014-04-19 22:17:18eric.snowcreate