Attached is a tiny patch for the python bindings. I've been plagued by spurious python exceptions in otherwise good python code sometime after making calls to urjtag. This fixes it by cleaning up an exception object left in the python runtime after trying multiple ways to parse python arguments into C.

Thanks again everyone for urjtag!
Steve
From 603949b3c6dfcdb1998e3fc019581a8bec1212e6 Mon Sep 17 00:00:00 2001
From: Steve Tell <t...@telltronics.org>
Date: Wed, 19 Sep 2012 22:34:33 -0400
Subject: [PATCH] call PyErr_Clear after failed PyArg_ParseTuple to avoid
 spurious exception some time after succeeding in parsing
 for the alternate type of argument to set_dr_in() and
 friends.

---
 urjtag/bindings/python/chain.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/urjtag/bindings/python/chain.c b/urjtag/bindings/python/chain.c
index 4a67162..cb15872 100644
--- a/urjtag/bindings/python/chain.c
+++ b/urjtag/bindings/python/chain.c
@@ -475,8 +475,11 @@ urj_pyc_set_dr (urj_pychain_t *self, int in, PyObject 
*args)
     int msb = -1;
 
     if (!PyArg_ParseTuple (args, "s|ii", &newstr, &msb, &lsb))
+    {
+        PyErr_Clear();
         if (!PyArg_ParseTuple (args, "L|ii", &newval, &msb, &lsb))
             return NULL;
+    }
 
     if (!urj_pyc_precheck (urc, UPRC_CBL))
         return NULL;
-- 
1.7.7.6

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
UrJTAG-development mailing list
UrJTAG-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/urjtag-development

Reply via email to