summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorCharlie Zhao <zhaoyu_hit@qq.com>2023-07-30 08:28:54 (GMT)
committerGitHub <noreply@github.com>2023-07-30 08:28:54 (GMT)
commit3979150a0d406707f6d253d7c15fb32c1e005a77 (patch)
tree229ea5e859a0c08788d81da41d1e80474f5b3c9b /Lib
parent5113ed7a2b92e8beabebe5fe2f6e856c52fbe1a0 (diff)
downloadcpython-3979150a0d406707f6d253d7c15fb32c1e005a77.zip
cpython-3979150a0d406707f6d253d7c15fb32c1e005a77.tar.gz
cpython-3979150a0d406707f6d253d7c15fb32c1e005a77.tar.bz2
gh-106263: Fix segfault in `signaldict_repr` in `_decimal` module (#106270)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_decimal.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index db67f37..fc66a30 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -5701,6 +5701,36 @@ class CWhitebox(unittest.TestCase):
ContextManager = type(C.localcontext())
check_disallow_instantiation(self, ContextManager)
+ def test_c_signaldict_segfault(self):
+ # See gh-106263 for details.
+ SignalDict = type(C.Context().flags)
+ sd = SignalDict()
+ err_msg = "invalid signal dict"
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ len(sd)
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ iter(sd)
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ repr(sd)
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ sd[C.InvalidOperation] = True
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ sd[C.InvalidOperation]
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ sd == C.Context().flags
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ C.Context().flags == sd
+
+ with self.assertRaisesRegex(ValueError, err_msg):
+ sd.copy()
+
@requires_docstrings
@requires_cdecimal
class SignatureTest(unittest.TestCase):