blob: 18bb9867aead58baef7d68f9054a68fb46f56d02 [file] [log] [blame]
Johnny Chenf307cf72011-07-26 19:09:03 +00001%wrapper %{
2
3// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
4// and is used when a script command is attached to a breakpoint for execution.
5
6SWIGEXPORT bool
7LLDBSwigPythonBreakpointCallbackFunction
8(
9 const char *python_function_name,
10 const char *session_dictionary_name,
11 const lldb::StackFrameSP& frame_sp,
12 const lldb::BreakpointLocationSP& bp_loc_sp
13)
14{
15 lldb::SBFrame sb_frame (frame_sp);
16 lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
17
18 bool stop_at_breakpoint = true;
19 PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0);
20 PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0);
21
22 if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL)
23 return stop_at_breakpoint;
24
25 if (!python_function_name || !session_dictionary_name)
26 return stop_at_breakpoint;
27
28 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
29 PyObject *pargs, *pvalue;
30
31 pmodule = PyImport_AddModule ("__main__");
32 if (pmodule != NULL)
33 {
34 main_dict = PyModule_GetDict (pmodule);
35 if (main_dict != NULL)
36 {
37 PyObject *key, *value;
38 Py_ssize_t pos = 0;
39
40 // Find the current session's dictionary in the main module's dictionary.
41
42 if (PyDict_Check (main_dict))
43 {
44 session_dict = NULL;
45 while (PyDict_Next (main_dict, &pos, &key, &value))
46 {
47 // We have stolen references to the key and value objects in the dictionary; we need to increment
48 // them now so that Python's garbage collector doesn't collect them out from under us.
49 Py_INCREF (key);
50 Py_INCREF (value);
51 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
52 {
53 session_dict = value;
54 break;
55 }
56 }
57 }
58
59 if (!session_dict || !PyDict_Check (session_dict))
60 return stop_at_breakpoint;
61
62 // Find the function we need to call in the current session's dictionary.
63
64 pos = 0;
65 pfunc = NULL;
66 while (PyDict_Next (session_dict, &pos, &key, &value))
67 {
68 if (PyString_Check (key))
69 {
70 // We have stolen references to the key and value objects in the dictionary; we need to increment
71 // them now so that Python's garbage collector doesn't collect them out from under us.
72 Py_INCREF (key);
73 Py_INCREF (value);
74 if (strcmp (PyString_AsString (key), python_function_name) == 0)
75 {
76 pfunc = value;
77 break;
78 }
79 }
80 }
81
82 // Set up the arguments and call the function.
83
84 if (pfunc && PyCallable_Check (pfunc))
85 {
86 pargs = PyTuple_New (3);
87 if (pargs == NULL)
88 {
89 if (PyErr_Occurred())
90 PyErr_Clear();
91 return stop_at_breakpoint;
92 }
93
94 PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj
95 PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj
96 PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict
97 pvalue = PyObject_CallObject (pfunc, pargs);
98 Py_DECREF (pargs);
99
100 if (pvalue != NULL)
101 {
102 Py_DECREF (pvalue);
103 }
104 else if (PyErr_Occurred ())
105 {
106 PyErr_Clear();
107 }
108 Py_INCREF (session_dict);
109 }
110 else if (PyErr_Occurred())
111 {
112 PyErr_Clear();
113 }
114 }
115 else if (PyErr_Occurred())
116 {
117 PyErr_Clear();
118 }
119 }
120 else if (PyErr_Occurred ())
121 {
122 PyErr_Clear ();
123 }
124 return stop_at_breakpoint;
125}
126
127SWIGEXPORT std::string
128LLDBSwigPythonCallTypeScript
129(
130 const char *python_function_name,
131 const char *session_dictionary_name,
132 const lldb::ValueObjectSP& valobj_sp
133)
134{
135 lldb::SBValue sb_value (valobj_sp);
136
137 std::string retval = "";
138
Enrico Granata3370f0c2011-08-19 23:56:34 +0000139 PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &sb_value, SWIGTYPE_p_lldb__SBValue, 0);
Johnny Chenf307cf72011-07-26 19:09:03 +0000140
141 if (ValObj_PyObj == NULL)
142 return retval;
143
144 if (!python_function_name || !session_dictionary_name)
145 return retval;
146
147 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
148 PyObject *pargs, *pvalue;
149
150 pmodule = PyImport_AddModule ("__main__");
151 if (pmodule != NULL)
152 {
153 main_dict = PyModule_GetDict (pmodule);
154 if (main_dict != NULL)
155 {
156 PyObject *key, *value;
157 Py_ssize_t pos = 0;
158
159 // Find the current session's dictionary in the main module's dictionary.
160
161 if (PyDict_Check (main_dict))
162 {
163 session_dict = NULL;
164 while (PyDict_Next (main_dict, &pos, &key, &value))
165 {
166 // We have stolen references to the key and value objects in the dictionary; we need to increment
167 // them now so that Python's garbage collector doesn't collect them out from under us.
168 Py_INCREF (key);
169 Py_INCREF (value);
170 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
171 {
172 session_dict = value;
173 break;
174 }
175 }
176 }
177
178 if (!session_dict || !PyDict_Check (session_dict))
179 return retval;
180
181 // Find the function we need to call in the current session's dictionary.
182
183 pos = 0;
184 pfunc = NULL;
185 while (PyDict_Next (session_dict, &pos, &key, &value))
186 {
187 if (PyString_Check (key))
188 {
189 // We have stolen references to the key and value objects in the dictionary; we need to increment
190 // them now so that Python's garbage collector doesn't collect them out from under us.
191 Py_INCREF (key);
192 Py_INCREF (value);
193 if (strcmp (PyString_AsString (key), python_function_name) == 0)
194 {
195 pfunc = value;
196 break;
197 }
198 }
199 }
200
201 // Set up the arguments and call the function.
202
203 if (pfunc && PyCallable_Check (pfunc))
204 {
205 pargs = PyTuple_New (2);
206 if (pargs == NULL)
207 {
208 if (PyErr_Occurred())
209 PyErr_Clear();
210 return retval;
211 }
212
213 PyTuple_SetItem (pargs, 0, ValObj_PyObj); // This "steals" a reference to ValObj_PyObj
214 PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
215 pvalue = PyObject_CallObject (pfunc, pargs);
216 Py_DECREF (pargs);
217
218 if (pvalue != NULL)
219 {
220 if (pvalue != Py_None)
221 retval = std::string(PyString_AsString(pvalue));
222 else
223 retval = "None";
224 Py_DECREF (pvalue);
225 }
226 else if (PyErr_Occurred ())
227 {
228 PyErr_Print();
229 PyErr_Clear();
230 }
231 Py_INCREF (session_dict);
232 }
233 else if (PyErr_Occurred())
234 {
235 PyErr_Print();
236 PyErr_Clear();
237 }
238 }
239 else if (PyErr_Occurred())
240 {
241 PyErr_Print();
242 PyErr_Clear();
243 }
244 }
245 else if (PyErr_Occurred ())
246 {
247 PyErr_Print();
248 PyErr_Clear ();
249 }
250 return retval;
251}
252
253SWIGEXPORT void*
254LLDBSwigPythonCreateSyntheticProvider
255(
256 const std::string python_class_name,
257 const char *session_dictionary_name,
258 const lldb::ValueObjectSP& valobj_sp
259)
260{
261 PyObject* retval = NULL;
262
263 if (python_class_name.empty() || !session_dictionary_name)
264 Py_RETURN_NONE;
265
Enrico Granata3370f0c2011-08-19 23:56:34 +0000266 // I do not want the SBValue to be deallocated when going out of scope because python
267 // has ownership of it and will manage memory for this object by itself
268 lldb::SBValue *valobj_sb = new lldb::SBValue(valobj_sp);
Johnny Chenf307cf72011-07-26 19:09:03 +0000269
Enrico Granata3370f0c2011-08-19 23:56:34 +0000270 PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *)valobj_sb, SWIGTYPE_p_lldb__SBValue, SWIG_POINTER_OWN);
Johnny Chenf307cf72011-07-26 19:09:03 +0000271
272 if (ValObj_PyObj == NULL)
273 Py_RETURN_NONE;
274
275 const char* python_function_name = python_class_name.c_str();
276
277 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
278 PyObject *pvalue;
279
280 pmodule = PyImport_AddModule ("__main__");
281 if (pmodule != NULL)
282 {
283 main_dict = PyModule_GetDict (pmodule);
284 if (main_dict != NULL)
285 {
286 PyObject *key, *value;
287 Py_ssize_t pos = 0;
288
289 // Find the current session's dictionary in the main module's dictionary.
290
291 if (PyDict_Check (main_dict))
292 {
293 session_dict = NULL;
294 while (PyDict_Next (main_dict, &pos, &key, &value))
295 {
296 // We have stolen references to the key and value objects in the dictionary; we need to increment
297 // them now so that Python's garbage collector doesn't collect them out from under us.
298 Py_INCREF (key);
299 Py_INCREF (value);
300 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
301 {
302 session_dict = value;
303 break;
304 }
305 }
306 }
307
308 if (!session_dict || !PyDict_Check (session_dict))
309 return retval;
310
311 // Find the function we need to call in the current session's dictionary.
312
313 pos = 0;
314 pfunc = NULL;
315 while (PyDict_Next (session_dict, &pos, &key, &value))
316 {
317 if (PyString_Check (key))
318 {
319 // We have stolen references to the key and value objects in the dictionary; we need to increment
320 // them now so that Python's garbage collector doesn't collect them out from under us.
321 Py_INCREF (key);
322 Py_INCREF (value);
323 if (strcmp (PyString_AsString (key), python_function_name) == 0)
324 {
325 pfunc = value;
326 break;
327 }
328 }
329 }
330
331 // Set up the arguments and call the function.
332
333 if (pfunc && PyCallable_Check (pfunc))
334 {
335 PyObject *argList = Py_BuildValue("SS", ValObj_PyObj, session_dict);
336
337 if (PyErr_Occurred ())
338 {
339 PyErr_Print();
340 PyErr_Clear();
341 return retval;
342 }
343
344 if (argList == NULL)
345 {
346 return retval;
347 }
348
349 Py_INCREF(ValObj_PyObj);
350
351 pvalue = PyObject_CallObject(pfunc, argList);
352
353 Py_DECREF(argList);
354
355 if (pvalue != NULL)
356 {
357 if (pvalue != Py_None)
358 retval = pvalue;
359 else
360 {
361 retval = Py_None;
362 Py_INCREF(retval);
363 }
364 }
365 else if (PyErr_Occurred ())
366 {
367 PyErr_Print();
368 PyErr_Clear();
369 }
370 Py_INCREF (session_dict);
371 }
372 else if (PyErr_Occurred())
373 {
374 PyErr_Print();
375 PyErr_Clear();
376 }
377 }
378 else if (PyErr_Occurred())
379 {
380 PyErr_Print();
381 PyErr_Clear();
382 }
383 }
384 else if (PyErr_Occurred ())
385 {
386 PyErr_Print();
387 PyErr_Clear ();
388 }
389 if (retval)
390 return retval;
391 else
392 Py_RETURN_NONE;
393}
394
395/*
396these four calls below are meant to support
397Python-based synthetic children providers
398they essentially mimic the four pure virtual
399method calls provided by the frontend class
400*/
401
402SWIGEXPORT uint32_t
403LLDBSwigPython_CalculateNumChildren
404(
405 PyObject *implementor
406)
407{
408
409 static char callee_name[] = "num_children";
410
411 if (implementor == NULL || implementor == Py_None)
412 return 0;
413 PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
414 if (PyErr_Occurred())
415 {
416 PyErr_Print();
417 PyErr_Clear();
418 }
419
420 if (py_return == NULL || py_return == Py_None)
421 {
422 Py_XDECREF(py_return);
423 return UINT32_MAX;
424 }
425 long retval = PyInt_AsLong(py_return);
426 Py_DECREF(py_return);
427 if (retval >= 0)
428 return (uint32_t)retval;
429 if (PyErr_Occurred())
430 {
431 PyErr_Print();
432 PyErr_Clear();
433 }
434 return 0;
435}
436
437SWIGEXPORT PyObject*
438LLDBSwigPython_GetChildAtIndex
439(
440 PyObject *implementor,
441 uint32_t idx
442)
443{
444
445 static char callee_name[] = "get_child_at_index";
446 static char param_format[] = "i";
447
448 if (implementor == NULL || implementor == Py_None)
449 return NULL;
450 PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, idx);
451 if (PyErr_Occurred())
452 {
453 PyErr_Print();
454 PyErr_Clear();
455 }
456
457 if (py_return == NULL || py_return == Py_None)
458 {
459 Py_XDECREF(py_return);
460 return NULL;
461 }
462
463 lldb::SBValue* sbvalue_ptr = NULL;
464
465 if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
466 {
467 Py_DECREF(py_return);
468 return NULL;
469 }
470
471 if (sbvalue_ptr == NULL)
472 return NULL;
473
474 return py_return;
475}
476
477SWIGEXPORT int
478LLDBSwigPython_GetIndexOfChildWithName
479(
480 PyObject *implementor,
481 const char* child_name
482)
483{
484 static char callee_name[] = "get_child_index";
485 static char param_format[] = "s";
486
487 if (implementor == NULL || implementor == Py_None)
488 return 0;
489 PyObject* py_return = PyObject_CallMethod(implementor, callee_name, param_format, child_name);
490 if (PyErr_Occurred())
491 {
492 PyErr_Print();
493 PyErr_Clear();
494 }
495
496 if (py_return == NULL || py_return == Py_None)
497 {
498 Py_XDECREF(py_return);
499 return UINT32_MAX;
500 }
501 long retval = PyInt_AsLong(py_return);
502 Py_DECREF(py_return);
503 if (retval >= 0)
504 return (uint32_t)retval;
505 if (PyErr_Occurred())
506 {
507 PyErr_Print();
508 PyErr_Clear();
509 }
510 return 0;
511}
512
Enrico Granata6a319e42011-07-26 21:02:56 +0000513SWIGEXPORT void
514LLDBSwigPython_UpdateSynthProviderInstance
515(
516 PyObject *implementor
517)
518{
519 static char callee_name[] = "update";
520
521 if (implementor == NULL || implementor == Py_None)
522 return;
523
524 // all this code is here because update is optional, so we don't want to bother trying to call it unless it's been def:ined for us
525 // other synth provider calls are mandatory, so we want to fail in a very obvious way if they are missing!
526 PyObject* pmeth = PyObject_GetAttrString(implementor, callee_name);
527
Enrico Granata1239c1a2011-08-11 19:20:44 +0000528 if (PyErr_Occurred())
529 {
530 PyErr_Clear();
531 }
532
Enrico Granata6a319e42011-07-26 21:02:56 +0000533 if (pmeth == NULL || pmeth == Py_None)
534 {
535 Py_XDECREF(pmeth);
536 return;
537 }
538
539 if (PyCallable_Check(pmeth) == 0)
540 {
Enrico Granata1239c1a2011-08-11 19:20:44 +0000541 if (PyErr_Occurred())
542 {
543 PyErr_Clear();
544 }
545
Enrico Granata6a319e42011-07-26 21:02:56 +0000546 Py_XDECREF(pmeth);
547 return;
548 }
549
Enrico Granata1239c1a2011-08-11 19:20:44 +0000550 if (PyErr_Occurred())
551 {
552 PyErr_Clear();
553 }
554
Enrico Granata6a319e42011-07-26 21:02:56 +0000555 Py_XDECREF(pmeth);
556
557 // right now we know this function exists and is callable..
558 PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
559
560 // if it fails, print the error but otherwise go on
561 if (PyErr_Occurred())
562 {
563 PyErr_Print();
564 PyErr_Clear();
565 }
566
567 Py_XDECREF(py_return);
568
569}
570
Johnny Chenf307cf72011-07-26 19:09:03 +0000571SWIGEXPORT lldb::SBValue*
572LLDBSWIGPython_CastPyObjectToSBValue
573(
574 PyObject* data
575)
576{
577 lldb::SBValue* sb_ptr = NULL;
578
579 int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0);
580
581 if (valid_cast == -1)
582 return NULL;
583
584 return sb_ptr;
585}
586
Enrico Granata872959b2011-08-20 00:26:17 +0000587// Currently, SBCommandReturnObjectReleaser wraps an std::auto_ptr to an
588// lldb_private::CommandReturnObject. This means that the destructor for the
589// SB object will deallocate its contained CommandReturnObject. Because that
590// object is used as the real return object for Python-based commands, we want
591// it to stay around. Thus, we release the auto_ptr before returning from
592// LLDBSwigPythonCallCommand, and to guarantee that the release will occur no
593// matter how we exit from the function, we have a releaser object whose
594// destructor does the right thing for us
595class SBCommandReturnObjectReleaser
596{
597public:
598 SBCommandReturnObjectReleaser (lldb::SBCommandReturnObject &obj) :
599 m_command_return_object_ref (obj)
600 {
601 }
602
603 ~SBCommandReturnObjectReleaser ()
604 {
605 m_command_return_object_ref.Release();
606 }
607private:
608 lldb::SBCommandReturnObject &m_command_return_object_ref;
609};
Enrico Granata3370f0c2011-08-19 23:56:34 +0000610
Enrico Granatac2a28252011-08-16 16:49:25 +0000611SWIGEXPORT bool
612LLDBSwigPythonCallCommand
613(
614 const char *python_function_name,
615 const char *session_dictionary_name,
616 lldb::DebuggerSP& debugger,
617 const char* args,
618 std::string& err_msg,
Enrico Granata3370f0c2011-08-19 23:56:34 +0000619 lldb_private::CommandReturnObject& cmd_retobj
Enrico Granatac2a28252011-08-16 16:49:25 +0000620)
621{
622
Enrico Granata3370f0c2011-08-19 23:56:34 +0000623 lldb::SBCommandReturnObject cmd_retobj_sb(&cmd_retobj);
Enrico Granata872959b2011-08-20 00:26:17 +0000624 SBCommandReturnObjectReleaser cmd_retobj_sb_releaser(cmd_retobj_sb);
Enrico Granata3370f0c2011-08-19 23:56:34 +0000625 lldb::SBDebugger debugger_sb(debugger);
Enrico Granata6b1596d2011-08-16 23:24:13 +0000626
Enrico Granatac2a28252011-08-16 16:49:25 +0000627 bool retval = false;
628
Enrico Granata3370f0c2011-08-19 23:56:34 +0000629 PyObject *DebuggerObj_PyObj = SWIG_NewPointerObj((void *) &debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0);
630 PyObject *CmdRetObj_PyObj = SWIG_NewPointerObj((void *) &cmd_retobj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0);
Enrico Granatac2a28252011-08-16 16:49:25 +0000631
632 if (DebuggerObj_PyObj == NULL)
Enrico Granata872959b2011-08-20 00:26:17 +0000633 return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000634
Enrico Granata6b1596d2011-08-16 23:24:13 +0000635 if (CmdRetObj_PyObj == NULL)
Enrico Granata872959b2011-08-20 00:26:17 +0000636 return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000637
638 if (!python_function_name || !session_dictionary_name)
Enrico Granata872959b2011-08-20 00:26:17 +0000639 return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000640
641 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
642 PyObject *pargs, *pvalue;
643
644 pmodule = PyImport_AddModule ("__main__");
645 if (pmodule != NULL)
646 {
647 main_dict = PyModule_GetDict (pmodule);
648 if (main_dict != NULL)
649 {
650 PyObject *key, *value;
651 Py_ssize_t pos = 0;
652
653 // Find the current session's dictionary in the main module's dictionary.
654
655 if (PyDict_Check (main_dict))
656 {
657 session_dict = NULL;
658 while (PyDict_Next (main_dict, &pos, &key, &value))
659 {
660 // We have stolen references to the key and value objects in the dictionary; we need to increment
661 // them now so that Python's garbage collector doesn't collect them out from under us.
662 Py_INCREF (key);
663 Py_INCREF (value);
664 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
665 {
666 session_dict = value;
667 break;
668 }
669 }
670 }
671
672 if (!session_dict || !PyDict_Check (session_dict))
Enrico Granata872959b2011-08-20 00:26:17 +0000673 return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000674
675 // Find the function we need to call in the current session's dictionary.
676
677 pos = 0;
678 pfunc = NULL;
679 while (PyDict_Next (session_dict, &pos, &key, &value))
680 {
681 if (PyString_Check (key))
682 {
683 // We have stolen references to the key and value objects in the dictionary; we need to increment
684 // them now so that Python's garbage collector doesn't collect them out from under us.
685 Py_INCREF (key);
686 Py_INCREF (value);
687 if (strcmp (PyString_AsString (key), python_function_name) == 0)
688 {
689 pfunc = value;
690 break;
691 }
692 }
693 }
694
695 // Set up the arguments and call the function.
696
697 if (pfunc && PyCallable_Check (pfunc))
698 {
699 pargs = PyTuple_New (4);
700 if (pargs == NULL)
701 {
702 if (PyErr_Occurred())
703 PyErr_Clear();
Enrico Granata872959b2011-08-20 00:26:17 +0000704 return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000705 }
706
707 PyTuple_SetItem (pargs, 0, DebuggerObj_PyObj); // This "steals" a reference to DebuggerObj_PyObj
708 PyTuple_SetItem (pargs, 1, PyString_FromString(args));
Enrico Granata6b1596d2011-08-16 23:24:13 +0000709 PyTuple_SetItem (pargs, 2, CmdRetObj_PyObj); // This "steals" a reference to CmdRetObj_PyObj
Enrico Granatac2a28252011-08-16 16:49:25 +0000710 PyTuple_SetItem (pargs, 3, session_dict); // This "steals" a reference to session_dict
711 pvalue = PyObject_CallObject (pfunc, pargs);
712 Py_DECREF (pargs);
713
714 if (pvalue != NULL)
715 {
716 if (pvalue == Py_None) // no error
717 {
718 err_msg.clear();
719 retval = true;
720 }
721 else // return value is an error string
722 {
723 err_msg.assign(PyString_AsString(pvalue));
724 retval = false;
725 }
726 Py_DECREF (pvalue);
727 }
728 else if (PyErr_Occurred ())
729 {
730 PyErr_Print();
731 PyErr_Clear();
732 }
733 Py_INCREF (session_dict);
734 }
735 else if (PyErr_Occurred())
736 {
737 PyErr_Print();
738 PyErr_Clear();
739 }
740 }
741 else if (PyErr_Occurred())
742 {
743 PyErr_Print();
744 PyErr_Clear();
745 }
746 }
747 else if (PyErr_Occurred ())
748 {
749 PyErr_Print();
750 PyErr_Clear ();
751 }
Enrico Granata872959b2011-08-20 00:26:17 +0000752return retval;
Enrico Granatac2a28252011-08-16 16:49:25 +0000753}
754
Enrico Granata3370f0c2011-08-19 23:56:34 +0000755#undef RETURN_RETVAL
756
Johnny Chenf307cf72011-07-26 19:09:03 +0000757%}