| 834 | @support.cpython_only |
| 835 | @requires_subinterpreters |
| 836 | def test_subinterp_intern_singleton(self): |
| 837 | # Implementation detail: singletons are used for 0- and 1-character |
| 838 | # latin1 strings. |
| 839 | for s in '', '\n', '_', 'x', '\0', '\N{CEDILLA}', '\xff': |
| 840 | with self.subTest(s=s): |
| 841 | interp = interpreters.create() |
| 842 | interp.exec(textwrap.dedent(f''' |
| 843 | import sys |
| 844 | |
| 845 | # set `s`, avoid parser interning & constant folding |
| 846 | s = str({s.encode()!r}, 'utf-8') |
| 847 | |
| 848 | assert id(s) == {id(s)} |
| 849 | t = sys.intern(s) |
| 850 | ''')) |
| 851 | self.assertTrue(sys._is_interned(s)) |
| 852 | |
| 853 | def test_sys_flags(self): |
| 854 | self.assertTrue(sys.flags) |