Created
December 19, 2011 08:07
Debugging dict refcount issue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Objects/dictobject.c b/Objects/dictobject.c | |
index 5cf9ad1..d6b9c8d 100644 | |
--- a/Objects/dictobject.c | |
+++ b/Objects/dictobject.c | |
@@ -8,6 +8,7 @@ | |
*/ | |
#include "Python.h" | |
+#include "frameobject.h" | |
/* Set a key error with the specified argument, wrapping it in a | |
@@ -266,6 +267,19 @@ PyDict_New(void) | |
++created; | |
#endif | |
_PyObject_GC_TRACK(mp); | |
+ | |
+ printf("New dict: %#012x\n", mp); | |
+ PyInterpreterState *interp = PyThreadState_GET()->interp; | |
+ PyThreadState *thread_state = interp->tstate_head; | |
+ PyFrameObject *frame = thread_state->frame; | |
+ if ( frame == NULL ) { | |
+ printf(" (no frame)\n"); | |
+ } else { | |
+ PyCodeObject *current_code = frame->f_code; | |
+ printf(" %s:%i\n", PyString_AsString(current_code->co_filename), current_code->co_firstlineno); | |
+ } | |
+ | |
+ | |
return (PyObject *)mp; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment