summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2014-03-15 16:12:27 +0100
committerStefan Behnel <stefan_ml@behnel.de>2014-03-15 16:12:27 +0100
commit98a170cdadd8e871741b97abefffd4debb0a44b0 (patch)
treea0f696dd53d941df61723ec87bb76c09412dfb06 /src
parent34a18baaa6cda233cd2aac12d69a313e3d32971c (diff)
downloadpython-lxml-98a170cdadd8e871741b97abefffd4debb0a44b0.tar.gz
use slightly better _isString() subtype check in Py2
Diffstat (limited to 'src')
-rw-r--r--src/lxml/includes/etree_defs.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lxml/includes/etree_defs.h b/src/lxml/includes/etree_defs.h
index 33cd948d..2d78b6b5 100644
--- a/src/lxml/includes/etree_defs.h
+++ b/src/lxml/includes/etree_defs.h
@@ -213,8 +213,10 @@ long _ftol2( double dblSource ) { return _ftol( dblSource ); }
#if PY_MAJOR_VERSION < 3
#define _isString(obj) (PyString_CheckExact(obj) || \
PyUnicode_CheckExact(obj) || \
- PyObject_TypeCheck(obj, &PyBaseString_Type))
+ PyType_IsSubtype(Py_TYPE(obj), &PyBaseString_Type))
#else
+/* builtin subtype type checks are almost as fast as exact checks in Py2.7+
+ * and Unicode is more common in Py3 */
#define _isString(obj) (PyUnicode_Check(obj) || PyBytes_Check(obj))
#endif