Skip to content

Commit 0d8377c

Browse files
committed
Py2: allow unicode topic (etc) strings in Admin API
1 parent 7204b84 commit 0d8377c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

confluent_kafka/src/confluent_kafka.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,9 @@ int cfl_PyObject_SetInt (PyObject *o, const char *name, int val) {
20042004
* @brief Get attribute \p attr_name from \p object and verify it is
20052005
* of type \p py_type.
20062006
*
2007+
* @param py_type the value type of \p attr_name must match \p py_type, unless
2008+
* \p py_type is NULL.
2009+
*
20072010
* @returns 1 if \p valp was updated with the object (new reference) or NULL
20082011
* if not matched and not required, or
20092012
* 0 if an exception was raised.
@@ -2025,7 +2028,7 @@ int cfl_PyObject_GetAttr (PyObject *object, const char *attr_name,
20252028
return 0;
20262029
}
20272030

2028-
if (Py_TYPE(o) != py_type) {
2031+
if (py_type && Py_TYPE(o) != py_type) {
20292032
Py_DECREF(o);
20302033
PyErr_Format(PyExc_TypeError,
20312034
"Expected .%s to be %s type, not %s",
@@ -2109,7 +2112,10 @@ int cfl_PyObject_GetString (PyObject *object, const char *attr_name,
21092112
#ifdef PY3
21102113
&PyUnicode_Type,
21112114
#else
2112-
&PyString_Type,
2115+
/* Python 2: support both str and unicode
2116+
* let PyObject_Unistr() do the
2117+
* proper conversion below. */
2118+
NULL,
21132119
#endif
21142120
required))
21152121
return 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy