File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -428,12 +428,13 @@ static int _load_python_objects(PyObject* module) {
428
428
*
429
429
* Return the type marker, 0 if there is no marker, or -1 on failure.
430
430
*/
431
+ static PyObject * TYPEMARKERSTR ;
431
432
static long _type_marker (PyObject * object ) {
432
433
PyObject * type_marker = NULL ;
433
434
long type = 0 ;
434
435
435
- if (PyObject_HasAttrString (object , "_type_marker" )) {
436
- type_marker = PyObject_GetAttrString (object , "_type_marker" );
436
+ if (PyObject_HasAttr (object , TYPEMARKERSTR )) {
437
+ type_marker = PyObject_GetAttr (object , TYPEMARKERSTR );
437
438
if (type_marker == NULL ) {
438
439
return -1 ;
439
440
}
@@ -450,13 +451,6 @@ static long _type_marker(PyObject* object) {
450
451
if (type_marker && PyLong_CheckExact (type_marker )) {
451
452
type = PyLong_AsLong (type_marker );
452
453
Py_DECREF (type_marker );
453
- /*
454
- * Py(Long|Int)_AsLong returns -1 for error but -1 is a valid value
455
- * so we call PyErr_Occurred to differentiate.
456
- */
457
- if (type == -1 && PyErr_Occurred ()) {
458
- return -1 ;
459
- }
460
454
} else {
461
455
Py_XDECREF (type_marker );
462
456
}
@@ -3031,5 +3025,7 @@ PyInit__cbson(void)
3031
3025
INITERROR ;
3032
3026
}
3033
3027
3028
+ TYPEMARKERSTR = PyUnicode_FromString ("_type_marker" );
3029
+
3034
3030
return m ;
3035
3031
}
You can’t perform that action at this time.
0 commit comments