summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/stress/qstr_limit.py42
-rw-r--r--tests/stress/qstr_limit.py.exp55
-rw-r--r--tests/stress/qstr_limit_str_modulo.py21
-rw-r--r--tests/stress/qstr_limit_str_modulo.py.exp5
4 files changed, 68 insertions, 55 deletions
diff --git a/tests/stress/qstr_limit.py b/tests/stress/qstr_limit.py
index 08b10a039..c7bd437f3 100644
--- a/tests/stress/qstr_limit.py
+++ b/tests/stress/qstr_limit.py
@@ -12,8 +12,8 @@ for l in range(254, 259):
var = make_id(l)
try:
exec(var + "=1", g)
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
continue
print(var in g)
@@ -26,16 +26,16 @@ def f(**k):
for l in range(254, 259):
try:
exec("f({}=1)".format(make_id(l)))
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
# type construction
for l in range(254, 259):
id = make_id(l)
try:
- print(type(id, (), {}).__name__)
- except RuntimeError:
- print("RuntimeError", l)
+ print(type(id, (), {}))
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
# hasattr, setattr, getattr
@@ -48,28 +48,20 @@ for l in range(254, 259):
a = A()
try:
setattr(a, id, 123)
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
try:
print(hasattr(a, id), getattr(a, id))
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
# format with keys
for l in range(254, 259):
id = make_id(l)
try:
print(("{" + id + "}").format(**{id: l}))
- except RuntimeError:
- print("RuntimeError", l)
-
-# modulo format with keys
-for l in range(254, 259):
- id = make_id(l)
- try:
- print(("%(" + id + ")d") % {id: l})
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
# import module
# (different OS's have different results so only run those that are consistent)
@@ -78,8 +70,8 @@ for l in (100, 101, 256, 257, 258):
__import__(make_id(l))
except ImportError:
print("ok", l)
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
# import package
for l in (100, 101, 102, 128, 129):
@@ -87,5 +79,5 @@ for l in (100, 101, 102, 128, 129):
exec("import " + make_id(l) + "." + make_id(l, "A"))
except ImportError:
print("ok", l)
- except RuntimeError:
- print("RuntimeError", l)
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
diff --git a/tests/stress/qstr_limit.py.exp b/tests/stress/qstr_limit.py.exp
index 455761bc7..2349adf22 100644
--- a/tests/stress/qstr_limit.py.exp
+++ b/tests/stress/qstr_limit.py.exp
@@ -1,43 +1,38 @@
True
True
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258
{'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst': 1}
{'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu': 1}
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
-abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst
-abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258
+<class 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst'>
+<class 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu'>
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258
True 123
True 123
-RuntimeError 256
-RuntimeError 256
-RuntimeError 257
-RuntimeError 257
-RuntimeError 258
-RuntimeError 258
+RuntimeError name too long 256
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 257
+RuntimeError name too long 258
+RuntimeError name too long 258
254
255
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
-254
-255
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258
ok 100
ok 101
-RuntimeError 256
-RuntimeError 257
-RuntimeError 258
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258
ok 100
ok 101
ok 102
-RuntimeError 128
-RuntimeError 129
+RuntimeError name too long 128
+RuntimeError name too long 129
diff --git a/tests/stress/qstr_limit_str_modulo.py b/tests/stress/qstr_limit_str_modulo.py
new file mode 100644
index 000000000..90b9f4364
--- /dev/null
+++ b/tests/stress/qstr_limit_str_modulo.py
@@ -0,0 +1,21 @@
+# Test interning qstrs that go over the qstr length limit (255 bytes in default configuration).
+# The tests here are specifically for str formatting with %.
+
+try:
+ "" % ()
+except TypeError:
+ print("SKIP")
+ raise SystemExit
+
+
+def make_id(n, base="a"):
+ return "".join(chr(ord(base) + i % 26) for i in range(n))
+
+
+# modulo format with keys
+for l in range(254, 259):
+ id = make_id(l)
+ try:
+ print(("%(" + id + ")d") % {id: l})
+ except RuntimeError as er:
+ print("RuntimeError", er, l)
diff --git a/tests/stress/qstr_limit_str_modulo.py.exp b/tests/stress/qstr_limit_str_modulo.py.exp
new file mode 100644
index 000000000..3632c85bf
--- /dev/null
+++ b/tests/stress/qstr_limit_str_modulo.py.exp
@@ -0,0 +1,5 @@
+254
+255
+RuntimeError name too long 256
+RuntimeError name too long 257
+RuntimeError name too long 258