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