@@ -152,7 +152,7 @@ def __call__(self, *args, **kwargs):
152152 switch = getattr (self .libinstance , 'switch_' + identifier )
153153 try :
154154 switch (sname )
155- except hcls .SessionError as exc :
155+ except hcls .SessionError :
156156 error = sys .exc_info ()
157157 # don't switch any more sessions
158158 break
@@ -175,7 +175,7 @@ def __call__(self, *args, **kwargs):
175175 'switch_' + identifier )
176176 try :
177177 switch (ctxname )
178- except hcls .ContextError as exc :
178+ except hcls .ContextError :
179179 error = sys .exc_info ()
180180 # don't switch any more contexts
181181 break
@@ -194,7 +194,10 @@ def __call__(self, *args, **kwargs):
194194 func = context_func
195195 # Does the keyword support **kwargs?
196196 if self .func .argspec .keywords or not kwargs :
197- result = func (self .libinstance , * args , ** kwargs )
197+ try :
198+ result = func (self .libinstance , * args , ** kwargs )
199+ except Exception :
200+ error = sys .exc_info ()
198201 else :
199202 # resolve **kwargs to positional args...
200203 posargs = []
@@ -206,10 +209,13 @@ def __call__(self, *args, **kwargs):
206209 varargs = ['%s=%s' % (key , kwargs .pop (key ))
207210 for key in list (kwargs )
208211 if key not in self .func .argspec .args ]
209- result = func (self .libinstance ,
210- * chain (args , posargs , varargs ),
211- # if **kwargs left ==> TypeError from Python
212- ** kwargs )
212+ try :
213+ result = func (self .libinstance ,
214+ * chain (args , posargs , varargs ),
215+ # if **kwargs left ==> TypeError from Python
216+ ** kwargs )
217+ except :
218+ error = sys .exc_info ()
213219 # Switch back contexts and sessions (reverse order):
214220 for identifier , ctxname in dictitems (current_contexts ):
215221 getattr (self .libinstance , 'switch_' + identifier )(ctxname )
0 commit comments