summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2012-07-10 17:05:05 +0000
committerelie <elie>2012-07-10 17:05:05 +0000
commitbc65170b6894f963155c88ade4d3965692d2edcf (patch)
tree004947de191519cbffa2558dec6a31bdf4bcc71a
parente5b26420ac36b9cd5dc561a513049600ed04a056 (diff)
downloadpyasn1-bc65170b6894f963155c88ade4d3965692d2edcf.tar.gz
catch possible exception on integer coersion at Integer.prettyPrint()
-rw-r--r--pyasn1/type/univ.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index 81a5637..9cd16f8 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -69,13 +69,18 @@ class Integer(base.AbstractSimpleAsn1Item):
def prettyIn(self, value):
if not isinstance(value, str):
- return int(value)
+ try:
+ return int(value)
+ except:
+ raise error.PyAsn1Error(
+ 'Can\'t coerce %s into integer: %s' % (value, sys.exc_info()[1])
+ )
r = self.__namedValues.getValue(value)
if r is not None:
return r
try:
return int(value)
- except ValueError:
+ except:
raise error.PyAsn1Error(
'Can\'t coerce %s into integer: %s' % (value, sys.exc_info()[1])
)