cls = ns["outer"]()
self.assertEqual(cls.Alias.__value__, "class")
+ def test_nested_free(self):
+ ns = run_code("""
+ def f():
+ T = str
+ class C:
+ T = int
+ class D[U](T):
+ x = T
+ return C
+ """)
+ C = ns["f"]()
+ self.assertIn(int, C.D.__bases__)
+ self.assertIs(C.D.x, str)
class TypeParamsManglingTest(unittest.TestCase):
def test_mangling(self):
the class that has the same name as a local
or global in the class scope.
*/
- if (classflag &&
- PyLong_AS_LONG(v) & (DEF_BOUND | DEF_GLOBAL)) {
+ if (classflag) {
long flags = PyLong_AS_LONG(v) | DEF_FREE_CLASS;
v_new = PyLong_FromLong(flags);
if (!v_new) {
goto error;
/* Records the results of the analysis in the symbol table entry */
if (!update_symbols(ste->ste_symbols, scopes, bound, newfree, inlined_cells,
- ste->ste_type == ClassBlock))
+ (ste->ste_type == ClassBlock) || ste->ste_can_see_class_scope))
goto error;
temp = PyNumber_InPlaceOr(free, newfree);