@@ -1124,8 +1124,9 @@ def preparse_numeric_literals(code, extract=False, quotes="'"):
1124
1124
name-construction pairs
1125
1125
1126
1126
- ``quotes`` -- string (default: ``"'"``); used to surround string
1127
- arguments to RealNumber and ComplexNumber. If ``None``, will rebuild
1128
- the string using a list of its Unicode code-points.
1127
+ arguments to RealNumber and ComplexNumber, and Integer when the
1128
+ number is longer than 4300 digits. If ``None``, will rebuild the
1129
+ string using a list of its Unicode code-points.
1129
1130
1130
1131
OUTPUT:
1131
1132
@@ -1188,6 +1189,12 @@ def preparse_numeric_literals(code, extract=False, quotes="'"):
1188
1189
'Integer(42)'
1189
1190
sage: preparse_numeric_literals('000042')
1190
1191
'Integer(42)'
1192
+ sage: preparse_numeric_literals("1" * 4300) == f"Integer({"1" * 4300})"
1193
+ True
1194
+ sage: preparse_numeric_literals("1" * 4301) == f"Integer({"1" * 4301})"
1195
+ False
1196
+ sage: preparse_numeric_literals("1" * 4301) == f"Integer('{"1" * 4301}')"
1197
+ True
1191
1198
1192
1199
Test underscores as digit separators (PEP 515,
1193
1200
https://www.python.org/dev/peps/pep-0515/)::
@@ -1253,6 +1260,10 @@ def preparse_numeric_literals(code, extract=False, quotes="'"):
1253
1260
'RealNumber(str().join(map(chr, [51, 46, 49, 52])))'
1254
1261
sage: preparse_numeric_literals('5j', quotes=None)
1255
1262
'ComplexNumber(0, str().join(map(chr, [53])))'
1263
+ sage: preparse_numeric_literals("1" * 4301, quotes=None) == f'Integer(str().join(map(chr, {[49] * 4301})))'
1264
+ True
1265
+ sage: preparse_numeric_literals("1" * 4301, quotes="'''") == f"Integer('''{"1" * 4301}''')"
1266
+ True
1256
1267
"""
1257
1268
literals = {}
1258
1269
last = 0
0 commit comments