bpo-35168: Make shlex.punctuation_chars read-only (#11631)
* bpo-35168: Documentation about shlex.punctuation_chars now states that it should be set in __init__.py
* bpo-35168: Convert shlex.punctuation_chars to read-only property
* Add NEWS.d entry
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py
index 376c5e8..a21ccd2 100644
--- a/Lib/test/test_shlex.py
+++ b/Lib/test/test_shlex.py
@@ -353,6 +353,13 @@
resplit = shlex.split(joined)
self.assertEqual(split_command, resplit)
+ def testPunctuationCharsReadOnly(self):
+ punctuation_chars = "/|$%^"
+ shlex_instance = shlex.shlex(punctuation_chars=punctuation_chars)
+ self.assertEqual(shlex_instance.punctuation_chars, punctuation_chars)
+ with self.assertRaises(AttributeError):
+ shlex_instance.punctuation_chars = False
+
# Allow this test to be used with old shlex.py
if not getattr(shlex, "split", None):