1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

add string_types to _compat

This commit is contained in:
Keerthan Jaic 2015-02-01 18:44:22 -05:00
parent 9e756bfbf9
commit 9887ad3427
3 changed files with 6 additions and 6 deletions

View File

@ -4,10 +4,12 @@ PY2 = sys.version_info[0] == 2
if not PY2:
string_types = (str, unicode)
integer_types = (int,)
long = int
import builtins
else:
str_types = (str,)
integer_types = (int, long)
long = long
import __builtin__ as builtins

View File

@ -23,10 +23,9 @@
from __future__ import absolute_import
from types import StringType
from myhdl._bin import bin
from myhdl._Signal import _Signal
from myhdl._compat import string_types
class EnumType(object):
def __init__(self):
@ -53,7 +52,7 @@ def enum(*names, **kwargs):
codedict = {}
i = 0
for name in names:
if not isinstance(name, StringType):
if not isinstance(name, string_types):
raise TypeError()
if codedict.has_key(name):
raise ValueError("enum literals should be unique")

View File

@ -22,10 +22,9 @@ from __future__ import absolute_import
import sys
maxint = sys.maxint
from types import StringType
import operator
from myhdl._compat import long, integer_types
from myhdl._compat import long, integer_types, string_types
from myhdl._compat.builtins import max as maxfunc
from myhdl._bin import bin
@ -51,7 +50,7 @@ class intbv(object):
_nrbits = maxfunc(len(bin(max-1))+1, len(bin(min)))
if isinstance(val, integer_types):
self._val = val
elif isinstance(val, StringType):
elif isinstance(val, string_types):
mval = val.replace('_', '')
self._val = long(mval, 2)
_nrbits = len(mval)