summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2007-06-11 16:36:59 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2007-06-11 16:36:59 (GMT)
commitd7fb7644da4a79cf153045536c1e81da5ee706a0 (patch)
tree5845faa89fa78d864344ea7cbe66bb93d2e51b3e /Objects/unicodeobject.c
parent3ef72bb0a9b2e648537f0334a0d86fea0a21af04 (diff)
downloadcpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.zip
cpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.tar.gz
cpython-d7fb7644da4a79cf153045536c1e81da5ee706a0.tar.bz2
Add a format specifier %V to PyUnicode_FromFormat(), that works similar to %U,
but requires an additional char * that will be used if the unicode object is NULL. Use %V in descrobject.c and classobject.c.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 87c5c99..39b7462 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -631,6 +631,18 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
n += PyUnicode_GET_SIZE(obj);
break;
}
+ case 'V':
+ {
+ PyObject *obj = va_arg(count, PyObject *);
+ const char *str = va_arg(count, const char *);
+ assert(obj || str);
+ assert(!obj || PyUnicode_Check(obj));
+ if (obj)
+ n += PyUnicode_GET_SIZE(obj);
+ else
+ n += strlen(str);
+ break;
+ }
case 'S':
{
PyObject *obj = va_arg(count, PyObject *);
@@ -775,6 +787,19 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
s += size;
break;
}
+ case 'V':
+ {
+ PyObject *obj = va_arg(vargs, PyObject *);
+ const char *str = va_arg(vargs, const char *);
+ if (obj) {
+ Py_ssize_t size = PyUnicode_GET_SIZE(obj);
+ Py_UNICODE_COPY(s, PyUnicode_AS_UNICODE(obj), size);
+ s += size;
+ } else {
+ appendstring(str);
+ }
+ break;
+ }
case 'S':
case 'R':
{