summaryrefslogtreecommitdiffstats
path: root/Python/getargs.c
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-07-06 12:22:00 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-07-06 12:22:00 (GMT)
commitd50338fbd9928527f6d53ade8974619591982b2e (patch)
treed197233ef38d1df130fa134d88a371dcd641a030 /Python/getargs.c
parent63f3d1741824b61eae886e4b29ae2b22a79f2419 (diff)
downloadcpython-d50338fbd9928527f6d53ade8974619591982b2e.zip
cpython-d50338fbd9928527f6d53ade8974619591982b2e.tar.gz
cpython-d50338fbd9928527f6d53ade8974619591982b2e.tar.bz2
Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Py_BuildValue.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r--Python/getargs.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/Python/getargs.c b/Python/getargs.c
index b213ba2..a28354d 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -489,6 +489,27 @@ convertsimple1(arg, p_format, p_va)
break;
}
+ case 'H': /* unsigned short int */
+ {
+ unsigned short *p = va_arg(*p_va, unsigned short *);
+ long ival = PyInt_AsLong(arg);
+ if (ival == -1 && PyErr_Occurred())
+ return "integer<H>";
+ else if (ival < 0) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned short integer is less than minimum");
+ return "integer<H>";
+ }
+ else if (ival > USHRT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "unsigned short integer is greater than maximum");
+ return "integer<H>";
+ }
+ else
+ *p = (unsigned short) ival;
+ break;
+ }
+
case 'i': /* signed int */
{
int *p = va_arg(*p_va, int *);
@@ -509,7 +530,6 @@ convertsimple1(arg, p_format, p_va)
*p = ival;
break;
}
-
case 'l': /* long int */
{
long *p = va_arg(*p_va, long *);
@@ -1207,6 +1227,12 @@ skipitem(p_format, p_va)
break;
}
+ case 'H': /* unsigned short int */
+ {
+ (void) va_arg(*p_va, unsigned short *);
+ break;
+ }
+
case 'i': /* int */
{
(void) va_arg(*p_va, int *);