diff -Naur Python-2.3.3.orig/Doc/api/utilities.tex Python-2.3.3/Doc/api/utilities.tex --- Python-2.3.3.orig/Doc/api/utilities.tex 2003-09-22 11:37:38.000000000 -0400 +++ Python-2.3.3/Doc/api/utilities.tex 2004-01-21 12:55:46.000000000 -0500 @@ -436,6 +436,10 @@ is responsible for calling \cfunction{PyMem_Free()} to free the allocated buffer after use. + \item[\samp{ez} (string, Unicode object, character buffer + compatible object, or None) {[const char *encoding, char **buffer]}] + This is to \samp{es} as \samp{z} is to \samp{s}. + \item[\samp{et} (string, Unicode object or character buffer compatible object) {[const char *encoding, char **buffer]}] Same as \samp{es} except that 8-bit string objects are passed @@ -478,6 +482,11 @@ In both cases, \var{*buffer_length} is set to the length of the encoded data without the trailing NUL byte. + \item[\samp{ez\#} (string, Unicode object, character buffer + compatible object, or None) {[const char *encoding, char **buffer, + int *buffer_length]}] + This is to \samp{es\#} as \samp{z} is to \samp{s}. + \item[\samp{et\#} (string, Unicode object or character buffer compatible object) {[const char *encoding, char **buffer]}] Same as \samp{es\#} except that string objects are passed through diff -Naur Python-2.3.3.orig/Python/getargs.c Python-2.3.3/Python/getargs.c --- Python-2.3.3.orig/Python/getargs.c 2003-05-03 06:00:22.000000000 -0400 +++ Python-2.3.3/Python/getargs.c 2004-01-21 12:30:37.000000000 -0500 @@ -793,7 +793,7 @@ char **buffer; const char *encoding; PyObject *s; - int size, recode_strings; + int size, recode_strings, return_null = 0; /* Get 'e' parameter: the encoding name */ encoding = (const char *)va_arg(*p_va, const char *); @@ -804,10 +804,16 @@ /* Get output buffer parameter: 's' (recode all objects via Unicode) or + 'z' (same as 's', but may be NULL (None)) or 't' (only recode non-string objects) */ if (*format == 's') recode_strings = 1; + else if (*format == 'z') { + recode_strings = 1; + if (arg == Py_None) + return_null = 1; + } else if (*format == 't') recode_strings = 0; else @@ -825,6 +831,9 @@ s = arg; Py_INCREF(s); } + else if (return_null) { + *buffer = 0; + } else { #ifdef Py_USING_UNICODE PyObject *u; @@ -888,6 +897,10 @@ "(buffer_len is NULL)", arg, msgbuf, bufsize); } + if (return_null) { + *buffer_len = 0; + break; + } if (*buffer == NULL) { *buffer = PyMem_NEW(char, size + 1); if (*buffer == NULL) { @@ -928,6 +941,8 @@ PyMem_Free()ing it after usage */ + if (return_null) + break; if ((int)strlen(PyString_AS_STRING(s)) != size) { Py_DECREF(s); return converterr(