Allow parsing boolean both upper and lowercase

Reportedly useful on H2 databases.

Close #965
This commit is contained in:
Daniele Varrazzo 2019-10-19 16:28:10 +01:00
parent 5e9572aff8
commit 96156727c0

View File

@ -114,16 +114,27 @@ typecast_UNICODE_cast(const char *s, Py_ssize_t len, PyObject *curs)
static PyObject *
typecast_BOOLEAN_cast(const char *s, Py_ssize_t len, PyObject *curs)
{
PyObject *res;
PyObject *res = NULL;
if (s == NULL) { Py_RETURN_NONE; }
if (s[0] == 't')
switch (s[0]) {
case 't':
case 'T':
res = Py_True;
else
res = Py_False;
break;
Py_INCREF(res);
case 'f':
case 'F':
res = Py_False;
break;
default:
PyErr_Format(InterfaceError, "can't parse boolean: '%s'", s);
break;
}
Py_XINCREF(res);
return res;
}