summaryrefslogtreecommitdiff
path: root/pyasn1/type
diff options
context:
space:
mode:
Diffstat (limited to 'pyasn1/type')
-rw-r--r--pyasn1/type/base.py53
-rw-r--r--pyasn1/type/univ.py26
-rw-r--r--pyasn1/type/useful.py12
3 files changed, 36 insertions, 55 deletions
diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py
index 994f1c9..f0ef270 100644
--- a/pyasn1/type/base.py
+++ b/pyasn1/type/base.py
@@ -7,7 +7,6 @@
import sys
from pyasn1 import error
-from pyasn1.compat import calling
from pyasn1.type import constraint
from pyasn1.type import tag
from pyasn1.type import tagmap
@@ -179,31 +178,31 @@ class NoValue(object):
Any operation attempted on the *noValue* object will raise the
*PyAsn1Error* exception.
"""
- skipMethods = set(
- ('__slots__',
- # attributes
- '__getattribute__',
- '__getattr__',
- '__setattr__',
- '__delattr__',
- # class instance
- '__class__',
- '__init__',
- '__del__',
- '__new__',
- '__repr__',
- '__qualname__',
- '__objclass__',
- 'im_class',
- '__sizeof__',
- # pickle protocol
- '__reduce__',
- '__reduce_ex__',
- '__getnewargs__',
- '__getinitargs__',
- '__getstate__',
- '__setstate__')
- )
+ skipMethods = {
+ '__slots__',
+ # attributes
+ '__getattribute__',
+ '__getattr__',
+ '__setattr__',
+ '__delattr__',
+ # class instance
+ '__class__',
+ '__init__',
+ '__del__',
+ '__new__',
+ '__repr__',
+ '__qualname__',
+ '__objclass__',
+ 'im_class',
+ '__sizeof__',
+ # pickle protocol
+ '__reduce__',
+ '__reduce_ex__',
+ '__getnewargs__',
+ '__getinitargs__',
+ '__getstate__',
+ '__setstate__',
+ }
_instance = None
@@ -220,7 +219,7 @@ class NoValue(object):
if (name not in cls.skipMethods and
name.startswith('__') and
name.endswith('__') and
- calling.callable(getattr(typ, name)))]
+ callable(getattr(typ, name)))]
for name in set(op_names):
setattr(cls, name, getPlug(name))
diff --git a/pyasn1/type/univ.py b/pyasn1/type/univ.py
index aa688b2..05fa677 100644
--- a/pyasn1/type/univ.py
+++ b/pyasn1/type/univ.py
@@ -9,7 +9,6 @@ import sys
from pyasn1 import error
from pyasn1.codec.ber import eoo
-from pyasn1.compat import binary
from pyasn1.compat import integer
from pyasn1.compat import octets
from pyasn1.type import base
@@ -231,9 +230,8 @@ class Integer(base.SimpleAsn1Type):
def __ceil__(self):
return math.ceil(self._value)
- if sys.version_info[0:2] > (2, 5):
- def __trunc__(self):
- return self.clone(math.trunc(self._value))
+ def __trunc__(self):
+ return self.clone(math.trunc(self._value))
def __lt__(self, value):
return self._value < value
@@ -586,7 +584,7 @@ class BitString(base.SimpleAsn1Type):
def asBinary(self):
"""Get |ASN.1| value as a text string of bits.
"""
- binString = binary.bin(self._value)[2:]
+ binString = bin(self._value)[2:]
return '0' * (len(self._value) - len(binString)) + binString
@classmethod
@@ -719,19 +717,6 @@ class BitString(base.SimpleAsn1Type):
)
-try:
- # noinspection PyStatementEffect
- all
-
-except NameError: # Python 2.4
- # noinspection PyShadowingBuiltins
- def all(iterable):
- for element in iterable:
- if not element:
- return False
- return True
-
-
class OctetString(base.SimpleAsn1Type):
"""Create |ASN.1| schema or value object.
@@ -1499,9 +1484,8 @@ class Real(base.SimpleAsn1Type):
def __ceil__(self):
return self.clone(math.ceil(float(self)))
- if sys.version_info[0:2] > (2, 5):
- def __trunc__(self):
- return self.clone(math.trunc(float(self)))
+ def __trunc__(self):
+ return self.clone(math.trunc(float(self)))
def __lt__(self, value):
return float(self) < value
diff --git a/pyasn1/type/useful.py b/pyasn1/type/useful.py
index 7536b95..a9a0287 100644
--- a/pyasn1/type/useful.py
+++ b/pyasn1/type/useful.py
@@ -7,8 +7,6 @@
import datetime
from pyasn1 import error
-from pyasn1.compat import dateandtime
-from pyasn1.compat import string
from pyasn1.type import char
from pyasn1.type import tag
from pyasn1.type import univ
@@ -74,9 +72,9 @@ class TimeMixIn(object):
elif '-' in text or '+' in text:
if '+' in text:
- text, plusminus, tz = string.partition(text, '+')
+ text, plusminus, tz = text.partition('+')
else:
- text, plusminus, tz = string.partition(text, '-')
+ text, plusminus, tz = text.partition('-')
if self._shortTZ and len(tz) == 2:
tz += '00'
@@ -99,9 +97,9 @@ class TimeMixIn(object):
if '.' in text or ',' in text:
if '.' in text:
- text, _, ms = string.partition(text, '.')
+ text, _, ms = text.partition('.')
else:
- text, _, ms = string.partition(text, ',')
+ text, _, ms = text.partition(',')
try:
ms = int(ms) * 1000
@@ -118,7 +116,7 @@ class TimeMixIn(object):
text += '00'
try:
- dt = dateandtime.strptime(text, self._yearsDigits == 4 and '%Y%m%d%H%M%S' or '%y%m%d%H%M%S')
+ dt = datetime.datetime.strptime(text, self._yearsDigits == 4 and '%Y%m%d%H%M%S' or '%y%m%d%H%M%S')
except ValueError:
raise error.PyAsn1Error('malformed datetime format %s' % self)