equal
deleted
inserted
replaced
173 n = PyTuple_GET_SIZE(obj->keys); |
173 n = PyTuple_GET_SIZE(obj->keys); |
174 for (i = 0; i < n; i++) { |
174 for (i = 0; i < n; i++) { |
175 const char* item_name = NULL; |
175 const char* item_name = NULL; |
176 PyObject* key = PyTuple_GET_ITEM(obj->keys, i); |
176 PyObject* key = PyTuple_GET_ITEM(obj->keys, i); |
177 |
177 |
178 item_name = PyBytes_AsString(key); |
178 if (PyUnicode_Check(key)) { |
|
179 #if PY_MAJOR_VERSION >= 3 |
|
180 item_name = PyUnicode_AsUTF8(key); |
|
181 #else |
|
182 PyObject* utf = PyUnicode_AsEncodedString(key, "utf-8", "ignore"); |
|
183 if (utf == NULL) { |
|
184 goto bail; |
|
185 } |
|
186 item_name = PyBytes_AsString(utf); |
|
187 #endif |
|
188 } else { |
|
189 item_name = PyBytes_AsString(key); |
|
190 } |
|
191 if (item_name == NULL) { |
|
192 goto bail; |
|
193 } |
179 if (!strcmp(item_name, namestr)) { |
194 if (!strcmp(item_name, namestr)) { |
180 ret = PySequence_GetItem(obj->values, i); |
195 ret = PySequence_GetItem(obj->values, i); |
181 goto bail; |
196 goto bail; |
182 } |
197 } |
183 } |
198 } |