Skip to content

Instantly share code, notes, and snippets.

@swtaarrs
Created April 25, 2023 17:36
Show Gist options
  • Save swtaarrs/1fcac0647bfd90797608c12005076bbd to your computer and use it in GitHub Desktop.
Save swtaarrs/1fcac0647bfd90797608c12005076bbd to your computer and use it in GitHub Desktop.
diff --git a/Lib/test/test_compiler/test_static/primitives.py b/Lib/test/test_compiler/test_static/primitives.py
index 2f3d71e61c..936df3e405 100644
--- a/Lib/test/test_compiler/test_static/primitives.py
+++ b/Lib/test/test_compiler/test_static/primitives.py
@@ -3681,3 +3681,15 @@ def f():
"""
with self.in_module(codestr) as mod:
self.assertInBytecode(mod.f, "CONVERT_PRIMITIVE")
+
+ def test_overflow_while_unboxing(self):
+ codestr = """
+ from __static__ import int8, int64, box, unbox
+
+ def f(x: int64) -> int8:
+ y: int8 = unbox(box(x))
+ return y
+ """
+ with self.in_module(codestr) as mod:
+ with self.assertRaises(OverflowError):
+ mod.f(128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment