# constant handling at code generation time
def get_int_const(self, str_value, longness=False):
- longness = bool(longness or Utils.long_literal(str_value))
+ longness = bool(longness)
try:
c = self.int_const_index[(str_value, longness)]
except KeyError:
decls_writer.putln("static PyObject *%s;" % cname)
if longness:
function = '%s = PyLong_FromString((char *)"%s", 0, 0); %s;'
+ elif Utils.long_literal(value):
+ function = '%s = PyInt_FromString((char *)"%s", 0, 0); %s;'
else:
function = "%s = PyInt_FromLong(%s); %s;"
init_globals = self.parts['init_globals']
def py_longs():
return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000
+
+def large_literal():
+ """
+ >>> type(large_literal()) is int
+ True
+ """
+ if sys.version_info[0] >= 3 or sys.maxint > 0xFFFFFFFFFFFF:
+ return 0xFFFFFFFFFFFF
+ else:
+ return 0xFFFFFFF