2019-11-22 00:18:25 -05:00
|
|
|
# Test interning qstrs that go over the limit of the maximum qstr length
|
|
|
|
# (which is 255 bytes for the default configuration)
|
|
|
|
|
2020-03-22 22:26:08 -04:00
|
|
|
|
|
|
|
def make_id(n, base="a"):
|
|
|
|
return "".join(chr(ord(base) + i % 26) for i in range(n))
|
|
|
|
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# identifiers in parser
|
|
|
|
for l in range(254, 259):
|
|
|
|
g = {}
|
|
|
|
var = make_id(l)
|
|
|
|
try:
|
2020-03-22 22:26:08 -04:00
|
|
|
exec(var + "=1", g)
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
continue
|
|
|
|
print(var in g)
|
|
|
|
|
|
|
|
# calling a function with kwarg
|
|
|
|
def f(**k):
|
|
|
|
print(k)
|
2020-03-22 22:26:08 -04:00
|
|
|
|
|
|
|
|
2019-11-22 00:18:25 -05:00
|
|
|
for l in range(254, 259):
|
|
|
|
try:
|
2020-03-22 22:26:08 -04:00
|
|
|
exec("f({}=1)".format(make_id(l)))
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# type construction
|
|
|
|
for l in range(254, 259):
|
|
|
|
id = make_id(l)
|
|
|
|
try:
|
|
|
|
print(type(id, (), {}).__name__)
|
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# hasattr, setattr, getattr
|
|
|
|
class A:
|
|
|
|
pass
|
2020-03-22 22:26:08 -04:00
|
|
|
|
|
|
|
|
2019-11-22 00:18:25 -05:00
|
|
|
for l in range(254, 259):
|
|
|
|
id = make_id(l)
|
|
|
|
a = A()
|
|
|
|
try:
|
|
|
|
setattr(a, id, 123)
|
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
try:
|
|
|
|
print(hasattr(a, id), getattr(a, id))
|
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# format with keys
|
|
|
|
for l in range(254, 259):
|
|
|
|
id = make_id(l)
|
|
|
|
try:
|
2020-03-22 22:26:08 -04:00
|
|
|
print(("{" + id + "}").format(**{id: l}))
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# modulo format with keys
|
|
|
|
for l in range(254, 259):
|
|
|
|
id = make_id(l)
|
|
|
|
try:
|
2020-03-22 22:26:08 -04:00
|
|
|
print(("%(" + id + ")d") % {id: l})
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# import module
|
2019-12-12 22:49:16 -05:00
|
|
|
# (different OS's have different results so only run those that are consistent)
|
|
|
|
for l in (100, 101, 256, 257, 258):
|
2019-11-22 00:18:25 -05:00
|
|
|
try:
|
|
|
|
__import__(make_id(l))
|
|
|
|
except ImportError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("ok", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
|
|
|
|
# import package
|
2019-12-12 22:49:16 -05:00
|
|
|
for l in (100, 101, 102, 128, 129):
|
2019-11-22 00:18:25 -05:00
|
|
|
try:
|
2020-03-22 22:26:08 -04:00
|
|
|
exec("import " + make_id(l) + "." + make_id(l, "A"))
|
2019-11-22 00:18:25 -05:00
|
|
|
except ImportError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("ok", l)
|
2019-11-22 00:18:25 -05:00
|
|
|
except RuntimeError:
|
2020-03-22 22:26:08 -04:00
|
|
|
print("RuntimeError", l)
|