Drop is_python_modern() in testcase

Python is always "modern" since e4fceee12f.
This commit is contained in:
Olly Betts 2022-01-26 12:30:44 +13:00
commit 6db66bc350

View file

@ -1,9 +1,5 @@
import python_nondynamic import python_nondynamic
def is_python_modern():
"""Return True if SWIG is generating Python code using -modern. Works only if %python_nondynamic has been used."""
return hasattr(python_nondynamic, "_swig_setattr_nondynamic_class_variable")
def debug_print(s): def debug_print(s):
show_debug = False show_debug = False
if show_debug: if show_debug:
@ -66,7 +62,7 @@ except AttributeError as e:
cc = python_nondynamic.C() cc = python_nondynamic.C()
cc.d = 3 cc.d = 3
# An inconsistency between builtin and (non-builtin/modern). # An inconsistency between builtin and non-builtin.
# Class variables cannot be set on builtin types, like other Python builtins, eg list.classvar=111 fails # Class variables cannot be set on builtin types, like other Python builtins, eg list.classvar=111 fails
if python_nondynamic.is_python_builtin(): if python_nondynamic.is_python_builtin():
try: try:
@ -78,8 +74,8 @@ if python_nondynamic.is_python_builtin():
else: else:
python_nondynamic.C.classvar = 111 python_nondynamic.C.classvar = 111
if is_python_modern() and not python_nondynamic.is_python_builtin(): if not python_nondynamic.is_python_builtin():
# Not working with builtin or non-modern :( # Not working with builtin :(
try: try:
B.a = 10 B.a = 10
raise RuntimeError("B should not allow adding a class variable by setting it as an instance variable") raise RuntimeError("B should not allow adding a class variable by setting it as an instance variable")