From a864c8d6ed6030afdc11d33e1d2a64a9afd300f9 Mon Sep 17 00:00:00 2001 From: "roberto@mrspurr" Date: Sat, 31 Mar 2012 18:06:03 +0200 Subject: [PATCH] fix pypy when no app is loaded --- plugins/python/profiler.c | 4 ++-- plugins/python/python_plugin.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/python/profiler.c b/plugins/python/profiler.c index 774204ea..4ae9e4ed 100644 --- a/plugins/python/profiler.c +++ b/plugins/python/profiler.c @@ -15,11 +15,11 @@ int PyFrame_GetLineNumber(PyFrameObject *frame) { int uwsgi_python_profiler_call(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { +#ifndef UWSGI_PYPY static uint64_t last_ts = 0; uint64_t now = uwsgi_micros(); uint64_t delta = 0; -#ifndef UWSGI_PYPY switch(what) { case PyTrace_CALL: if (last_ts == 0) delta = 0; @@ -49,11 +49,11 @@ int uwsgi_python_profiler_call(PyObject *obj, PyFrameObject *frame, int what, Py int uwsgi_python_tracer(PyObject *obj, PyFrameObject *frame, int what, PyObject *arg) { +#ifndef UWSGI_PYPY static uint64_t last_ts = 0; uint64_t now = uwsgi_micros(); uint64_t delta = 0; -#ifndef UWSGI_PYPY if (what == PyTrace_LINE) { if (last_ts == 0) { delta = 0; diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 44f5030d..b5df8670 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -246,6 +246,10 @@ void uwsgi_python_reset_random_seed() { random_seed = PyDict_GetItemString(random_dict, "seed"); if (random_seed) { PyObject *random_args = PyTuple_New(1); + Py_INCREF(random_args); +#ifdef UWSGI_PYPY + Py_INCREF(Py_None); +#endif // pass no args PyTuple_SetItem(random_args, 0, Py_None); PyEval_CallObject(random_seed, random_args);