[Python-Dev] 's' vs 'z' format (was: CVS: python/dist/src/Modules readline.c,2.18,2.19)

Greg Stein gstein@lyra.org
Thu, 6 Jul 2000 15:49:57 -0700


On Thu, Jul 06, 2000 at 11:55:14AM -0700, Skip Montanaro wrote:
>...
> + /* Exported function to load a readline history file */
> + 
> + static PyObject *
> + read_history_file(self, args)
> + 	PyObject *self;
> + 	PyObject *args;
> + {
> + 	char *s = NULL;
> + 	if (!PyArg_ParseTuple(args, "|z:read_history_file", &s))

This allows somebody to pass read_history_file(None). That doesn't feel
right. I'd suggest using the 's' format code.

(if they want the default, then pass nothing at all)

>...
> + static PyObject *
> + write_history_file(self, args)
> + 	PyObject *self;
> + 	PyObject *args;
> + {
> + 	char *s = NULL;
> + 	if (!PyArg_ParseTuple(args, "|z:write_history_file", &s))
> + 		return NULL;

Same here.

Cheers,
-g

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