Ticket #596 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Closures for class methods and nested classes

Reported by: vitja Owned by: vitja
Priority: major Milestone: 0.14
Component: Python Semantics Keywords:
Cc:

Description

Support class definition in functions and in class body:

def foo():
    class Bar:
        pass
    return Bar

class Foo:
    class Meta:
        pass

Attachments

class-closure.patch Download (6.4 KB) - added by vitja 4 years ago.
Try #2
runtests-check-threads.patch Download (1.7 KB) - added by vitja 4 years ago.
check threads at exit

Change History

Changed 4 years ago by scoder

  • owner changed from somebody to vitja
  • component changed from Code Generation to Python Semantics
  • milestone changed from wishlist to 0.13.1

Thanks! Looks good to me. Pushed to cython-devel. Let's see what the CPython regression tests make of it.

 http://hg.cython.org/cython-devel/rev/df32f9fa0072

Changed 4 years ago by scoder

Reverted, there seem to be issues when running the CPython regression tests. "test_call" doesn't terminate in Py2.7, several tests fail at C compilation time, e.g.

test_isinstance.c:6505: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_I’
test_isinstance.c:6506: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_I’
test_isinstance.c:6508: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_self’
test_isinstance.c:6509: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_self’
test_isinstance.c:6511: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_C’
test_isinstance.c:6512: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_C’
test_isinstance.c:6514: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_S’
test_isinstance.c:6515: error: ‘struct __pyx_obj_15test_isinstance___pyx_scope_struct_test_dont_mask_non_attribute_error’ has no member named ‘__pyx_v_S’

Changed 4 years ago by scoder

The patch has enabled a couple of pyregr tests that don't work at all in Cython when run but didn't even make it across the compilation barrier before, so not all newly occurring failures are relevant.

However, I think "test/test_isinstance.py" is actually a fairly good test for this feature.

Changed 4 years ago by scoder

I included your test module in cython-devel but disabled it. You can run it by passing "-T596" to the test runner.

Changed 4 years ago by vitja

Try #2

Changed 4 years ago by vitja

New patch solves error #537, which caused all this "has no member errors" Also this patch disables test_socket and test_threading CPython tests.

Changed 4 years ago by vitja

Ooops. After tests are run python interpreter doesn't exit it seems there are unfinished threads.

Changed 4 years ago by vitja

check threads at exit

Changed 4 years ago by scoder

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.