@@ -63,7 +63,7 @@ import_cf( Value** arg_list, int count ) {
6363 // Step 5: import the module
6464 if ( module_name ) {
6565 PyObject* module = PyImport_ImportModule ( module_name );
66- PY_CLEARERRORS ();
66+ PY_ERROR_PROPAGATE_MXS_CLEANUP ();
6767
6868 vl.mxs_return = ( module ) ? ObjectWrapper::intern ( module ) : &undefined;
6969 }
@@ -81,16 +81,17 @@ reload_cf( Value** arg_list, int count ) {
8181 check_arg_count ( python.reload , 1 , count );
8282
8383 // Step 2: evaluate the input item
84- Value* mxs_check = NULL ;
85- MXS_EVAL ( arg_list[0 ], mxs_check );
84+ MXS_PROTECT ( one_value_local ( mxs_check)) ;
85+ MXS_EVAL ( arg_list[0 ], vl. mxs_check );
8686
8787 // Step 3: make sure the item is a proper type
88- if ( is_objectwrapper (mxs_check) ) {
89- PyImport_ReloadModule ( ((ObjectWrapper*) mxs_check)->object () );
90- PY_CLEARERRORS ();
88+ if ( is_objectwrapper (vl. mxs_check ) ) {
89+ PyImport_ReloadModule ( ((ObjectWrapper*) vl. mxs_check )->object () );
90+ PY_ERROR_PROPAGATE_MXS_CLEANUP ();
9191 }
9292 else { mprintf ( " python.reload() error: you need to supply a valid python module to reload\n " ); }
9393
94+ MXS_CLEANUP ();
9495 return &ok;
9596}
9697
@@ -116,7 +117,7 @@ run_cf( Value** arg_list, int count ) {
116117
117118 // Step 4: run the file
118119 PyRun_SimpleFile ( PyFile_AsFile (py_file), filename );
119- PY_CLEARERRORS ();
120+ PY_ERROR_PROPAGATE_MXS_CLEANUP ();
120121
121122 // Step 5: cleanup the memory
122123 Py_XDECREF ( py_file );
@@ -148,7 +149,7 @@ exec_cf( Value** arg_list, int count ) {
148149
149150 // Step 4: run the command
150151 PyRun_SimpleString ( command );
151- PY_CLEARERRORS ();
152+ PY_ERROR_PROPAGATE_MXS_CLEANUP ();
152153
153154 // Step 5: cleanup the memory
154155 MXS_CLEANUP ();
@@ -164,6 +165,8 @@ PyExcRuntimeError::PyExcRuntimeError( char * _error )
164165PyExcRuntimeError::~PyExcRuntimeError ()
165166{
166167 delete error;
168+ // Hopefully this is safe and keeps RuntimeError from double deleting our copy of the string
169+ desc1 = 0 ;
167170}
168171
169172// Returns a new string
0 commit comments