Re-implement Python -fastproxy option.

The previous implementation failed with Python 3 and abstract base clases.
The new implementation replaces the Python 2 implementation using new.instancemethod with C API PyMethod_New to match the equivalent Python 3 implementation which uses PyInstanceMethod_New.

Closes #1310
This commit is contained in:
William S Fulton 2018-08-17 23:34:29 +01:00
commit c9cac931c7
6 changed files with 144 additions and 32 deletions

View file

@ -13,15 +13,20 @@ def check(got, expected, expected_builtin=None, skip=False):
def is_new_style_class(cls):
return hasattr(cls, "__class__")
def is_fastproxy(module):
return "new_instancemethod" in module
def is_fastproxy():
fastproxy = True
try:
from autodoc import _swig_new_instance_method
except ImportError:
fastproxy = False
return fastproxy
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
if is_fastproxy(dir()):
if is_fastproxy():
# Detect when -fastproxy is specified and skip test as it changes the function names making it
# hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved
sys.exit(0)