ns = run_code("x: [y for y in range(10)]")
self.assertEqual(ns["__annotate__"](1), {"x": list(range(10))})
+ def test_class_annotation_dunder_classdict(self):
+ ns = run_code("""
+ class C:
+ __classdict__: int
+ """)
+ self.assertEqual(ns["C"].__annotations__, {"__classdict__": int})
+
def test_future_annotations(self):
code = """
from __future__ import annotations
--- /dev/null
+Fix a :exc:`SystemError` when compiling a compiling ``__classdict__`` class
+annotation. Found by OSS-Fuzz in :oss-fuzz:`512907042`.
int future_annotations = st->st_future->ff_features & CO_FUTURE_ANNOTATIONS;
if (current_type == ClassBlock && !future_annotations) {
st->st_cur->ste_can_see_class_scope = 1;
+ parent_ste->ste_needs_classdict = 1;
if (!symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(annotation))) {
return 0;
}