[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.60,2.61

Greg Stein gstein@lyra.org
Thu, 13 Apr 2000 12:09:02 -0700 (PDT)


It's great that you made this change! I hadn't got through my mail, but
was going to recommend it... :-)

One comment:

On Thu, 13 Apr 2000, Fred Drake wrote:
>...
> --- 409,433 ----
>   			     v = PyInt_FromLong(PY_VERSION_HEX));
>   	Py_XDECREF(v);
> + 	/*
> + 	 * These release level checks are mutually exclusive and cover
> + 	 * the field, so don't get too fancy with the pre-processor!
> + 	 */
> + #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_ALPHA
> + 	v = PyString_FromString("alpha");
> + #endif
> + #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_BETA
> + 	v = PyString_FromString("beta");
> + #endif
> + #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_GAMMA
> + 	v = PyString_FromString("candidate");
> + #endif
>   #if PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
> ! 	v = PyString_FromString("final");
> ! #endif
>   	PyDict_SetItemString(sysdict, "version_info",
> ! 			     v = Py_BuildValue("iiiNi", PY_MAJOR_VERSION,
>   					       PY_MINOR_VERSION,
> ! 					       PY_MICRO_VERSION, v,
> ! 					       PY_RELEASE_SERIAL));
>   	Py_XDECREF(v);
>   	PyDict_SetItemString(sysdict, "copyright",

I would recommend using the "s" format code in Py_BuildValue. It
simplifies the code, and it is quite a bit easier for a human to process.
When I first saw the code, I thought "the level string leaks!" Then I saw
the "N" code, went and looked it up, and realized what is going on.

So... to avoid that, the "s" code would be great.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/