@@ -165,7 +165,7 @@ def column_set_from_json(json, columns):
class TableSchema(object):
- def __init__(self, name, columns, mutable=True, max_rows=sys.maxint,
+ def __init__(self, name, columns, mutable=True, max_rows=sys.maxsize,
is_root=True, indexes=[]):
self.name = name
self.columns = columns
@@ -185,7 +185,7 @@ class TableSchema(object):
parser.finish()
if max_rows is None:
- max_rows = sys.maxint
+ max_rows = sys.maxsize
elif max_rows <= 0:
raise error.Error("maxRows must be at least 1", json)
@@ -236,7 +236,7 @@ class TableSchema(object):
if not column.name.startswith("_"):
columns[column.name] = column.to_json()
- if self.max_rows != sys.maxint:
+ if self.max_rows != sys.maxsize:
json["maxRows"] = self.max_rows
if self.indexes:
@@ -119,7 +119,7 @@ def returnUnchanged(x):
class BaseType(object):
def __init__(self, type_, enum=None, min=None, max=None,
- min_length=0, max_length=sys.maxint, ref_table_name=None):
+ min_length=0, max_length=sys.maxsize, ref_table_name=None):
assert isinstance(type_, AtomicType)
self.type = type_
self.enum = enum
@@ -194,7 +194,7 @@ class BaseType(object):
elif base.type == StringType:
base.min_length = BaseType.__parse_uint(parser, "minLength", 0)
base.max_length = BaseType.__parse_uint(parser, "maxLength",
- sys.maxint)
+ sys.maxsize)
if base.min_length > base.max_length:
raise error.Error("minLength exceeds maxLength", json)
elif base.type == UuidType:
@@ -232,7 +232,7 @@ class BaseType(object):
elif self.type == StringType:
if self.min_length != 0:
json['minLength'] = self.min_length
- if self.max_length != sys.maxint:
+ if self.max_length != sys.maxsize:
json['maxLength'] = self.max_length
elif self.type == UuidType:
if self.ref_table_name:
@@ -260,7 +260,7 @@ class BaseType(object):
def has_constraints(self):
return (self.enum is not None or self.min is not None or
self.max is not None or
- self.min_length != 0 or self.max_length != sys.maxint or
+ self.min_length != 0 or self.max_length != sys.maxsize or
self.ref_table_name is not None)
def without_constraints(self):
@@ -270,7 +270,7 @@ class BaseType(object):
def get_enum_type(atomic_type):
"""Returns the type of the 'enum' member for a BaseType whose
'type' is 'atomic_type'."""
- return Type(BaseType(atomic_type), None, 1, sys.maxint)
+ return Type(BaseType(atomic_type), None, 1, sys.maxsize)
def is_ref(self):
return self.type == UuidType and self.ref_table_name is not None
@@ -322,7 +322,7 @@ class BaseType(object):
english = 'at most %s' % escapeNumber(commafy(self.max))
else:
english = 'at most %s' % escapeNumber("%g" % self.max)
- elif self.min_length != 0 and self.max_length != sys.maxint:
+ elif self.min_length != 0 and self.max_length != sys.maxsize:
if self.min_length == self.max_length:
english = ('exactly %s characters long'
% commafy(self.min_length))
@@ -332,7 +332,7 @@ class BaseType(object):
commafy(self.max_length)))
elif self.min_length != 0:
return 'at least %s characters long' % commafy(self.min_length)
- elif self.max_length != sys.maxint:
+ elif self.max_length != sys.maxsize:
english = 'at most %s characters long' % commafy(self.max_length)
else:
english = ''
@@ -407,7 +407,7 @@ class BaseType(object):
if self.min_length is not None:
stmts.append('%s.u.string.minLen = %d;'
% (var, self.min_length))
- if self.max_length != sys.maxint:
+ if self.max_length != sys.maxsize:
stmts.append('%s.u.string.maxLen = %d;'
% (var, self.max_length))
elif self.type == UuidType:
@@ -482,7 +482,7 @@ class Type(object):
def __n_from_json(json, default):
if json is None:
return default
- elif type(json) == int and 0 <= json <= sys.maxint:
+ elif isinstance(json, int) and 0 <= json <= sys.maxsize:
return json
else:
raise error.Error("bad min or max value", json)
@@ -512,7 +512,7 @@ class Type(object):
n_min = Type.__n_from_json(min_json, Type.DEFAULT_MIN)
if max_json == 'unlimited':
- n_max = sys.maxint
+ n_max = sys.maxsize
else:
n_max = Type.__n_from_json(max_json, Type.DEFAULT_MAX)
@@ -530,7 +530,7 @@ class Type(object):
json["value"] = self.value.to_json()
if self.n_min != Type.DEFAULT_MIN:
json["min"] = self.n_min
- if self.n_max == sys.maxint:
+ if self.n_max == sys.maxsize:
json["max"] = "unlimited"
elif self.n_max != Type.DEFAULT_MAX:
json["max"] = self.n_max
@@ -549,7 +549,7 @@ class Type(object):
else:
return "optional %s" % keyName
else:
- if self.n_max == sys.maxint:
+ if self.n_max == sys.maxsize:
if self.n_min:
quantity = "%s or more " % commafy(self.n_min)
else:
@@ -602,7 +602,7 @@ class Type(object):
initValue = ('%sovsdb_base_type_init(&%s.value, '
'OVSDB_TYPE_VOID);' % (indent, var))
initMin = "%s%s.n_min = %s;" % (indent, var, self.n_min)
- if self.n_max == sys.maxint:
+ if self.n_max == sys.maxsize:
n_max = "UINT_MAX"
else:
n_max = self.n_max
@@ -254,7 +254,7 @@ class Parser(object):
if m:
sign, integer, fraction, exp = m.groups()
if (exp is not None and
- (int(exp) > sys.maxint or int(exp) < -sys.maxint - 1)):
+ (int(exp) > sys.maxsize or int(exp) < -sys.maxsize - 1)):
self.__error("exponent outside valid range")
return
@@ -241,7 +241,7 @@ class Vlog(object):
ovs.unixctl.command_register("vlog/reopen", "", 0, 0,
Vlog._unixctl_vlog_reopen, None)
- ovs.unixctl.command_register("vlog/set", "spec", 1, sys.maxint,
+ ovs.unixctl.command_register("vlog/set", "spec", 1, sys.maxsize,
Vlog._unixctl_vlog_set, None)
ovs.unixctl.command_register("vlog/list", "", 0, 0,
Vlog._unixctl_vlog_list, None)
sys.maxint does not exist in Python 3, as an int does not have a max value anymore (except as limited by implementation details and system resources). sys.maxsize works as a reasonable substitute as it's the same as sys.maxint. The Python 3.0 release notes have this to say: The sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. It conforms to the implementation’s “natural” integer size and is typically the same as sys.maxint in previous releases on the same platform (assuming the same build options). sys.maxsize is documented as: An integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform. This is also the final change needed to make the Python 3.4 test environment pass successfully (tox -e py34). Signed-off-by: Russell Bryant <russell@ovn.org> --- python/ovs/db/schema.py | 6 +++--- python/ovs/db/types.py | 26 +++++++++++++------------- python/ovs/json.py | 2 +- python/ovs/vlog.py | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-)