diff options
author | elie <elie> | 2013-09-11 20:56:25 +0000 |
---|---|---|
committer | elie <elie> | 2013-09-11 20:56:25 +0000 |
commit | c3c3e08cfb4cf12bcceb2f12d7eb492a2777b7ed (patch) | |
tree | ce88c5f0259ddc834c44ed47bba3f4cb6811fc11 | |
parent | a6a5538d76b6d716bcf1161515ae29061706419b (diff) | |
download | pyasn1-c3c3e08cfb4cf12bcceb2f12d7eb492a2777b7ed.tar.gz |
minor rewriting of Real.prettyIn()
-rw-r--r-- | pyasn1/type/univ.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py index edd6f42..7364a0c 100644 --- a/pyasn1/type/univ.py +++ b/pyasn1/type/univ.py @@ -444,7 +444,9 @@ class Null(OctetString): if sys.version_info[0] <= 2: intTypes = (int, long) else: - intTypes = int + intTypes = (int,) + +numericTypes = intTypes + (float,) class ObjectIdentifier(base.AbstractSimpleAsn1Item): tagSet = baseTagSet = tag.initTagSet( @@ -541,11 +543,10 @@ class Real(base.AbstractSimpleAsn1Item): def prettyIn(self, value): if isinstance(value, tuple) and len(value) == 3: - if not ((isinstance(value[0], intTypes) or \ - isinstance(value[0], float)) and \ - isinstance(value[1], intTypes) and \ - isinstance(value[2], intTypes)): - raise error.PyAsn1Error('Lame Real value syntax: %s' % (value,)) + if not isinstance(value[0], numericTypes) or \ + not isinstance(value[1], intTypes) or \ + not isinstance(value[2], intTypes): + raise error.PyAsn1Error('Lame Real value syntax: %s' % (value,)) if isinstance(value[0], float) and \ self._inf and value[0] in self._inf: return value[0] |