Turn on Python annotations testing again

Testing is skipped where there is no support for it, that is,
using -builtin or -fastproxy. How to add this support in needs
determining, it's not clear how to do so.
This commit is contained in:
William S Fulton 2022-02-28 19:40:35 +00:00
commit afc915f490
2 changed files with 36 additions and 19 deletions

View file

@ -1,9 +1,12 @@
import sys import sys
# Disable as no __annotations__ support with -fastproxy and -builtin atm if sys.version_info[0:2] >= (3, 2):
if False: # sys.version_info[0:2] >= (3, 2):
from python_annotations_c import * from python_annotations_c import *
# No __annotations__ support with -builtin or -fastproxy
annotations_supported = not(is_python_builtin() or is_python_fastproxy())
if annotations_supported:
anno = MakeShort.__annotations__ anno = MakeShort.__annotations__
if anno != {'x': 'int', 'return': 'Space::Template< short >'}: if anno != {'x': 'int', 'return': 'Space::Template< short >'}:
raise RuntimeError("annotations mismatch: {}".format(anno)) raise RuntimeError("annotations mismatch: {}".format(anno))

View file

@ -24,3 +24,17 @@ int *no_annotations(int &ri, const char *c) { return NULL; }
%} %}
%template(TemplateShort) Space::Template<short>; %template(TemplateShort) Space::Template<short>;
%template(MakeShort) makeT<short>; %template(MakeShort) makeT<short>;
%inline %{
#ifdef SWIGPYTHON_BUILTIN
int is_python_builtin() { return 1; }
#else
int is_python_builtin() { return 0; }
#endif
#if defined SWIGPYTHON_FASTPROXY
int is_python_fastproxy() { return 1; }
#else
int is_python_fastproxy() { return 0; }
#endif
%}