diff options
203 files changed, 396 insertions, 378 deletions
diff --git a/.gitignore b/.gitignore index fd5461a8c..9da27c0f1 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,6 @@ MANIFEST # Komodo EDIT/IDE project files /*.komodoproject + +# Visual Studio Code files +.vscode diff --git a/.travis.yml b/.travis.yml index 6eb4db4fa..bb3aa5a94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -140,7 +140,7 @@ before_install: install: - python -c 'import sys; print("Python %s" % (sys.version,))' - if [ -z "${TRAVIS_PYTHON_VERSION##2.7}" ]; then [ "$TRAVIS_OS_NAME" == "osx" -a "$PY" == "3" ] || pip install -r test-requirements-27.txt ; fi - - if [ -n "${TRAVIS_PYTHON_VERSION##*-dev}" -a -n "${TRAVIS_PYTHON_VERSION##2.7}" ]; then pip install -r test-requirements.txt $( [ -z "${TRAVIS_PYTHON_VERSION##pypy*}" -o -z "${TRAVIS_PYTHON_VERSION##3.[4789]*}" ] || echo " -r test-requirements-cpython.txt" ) ; fi + - if [ -n "${TRAVIS_PYTHON_VERSION##*-dev}" -a -n "${TRAVIS_PYTHON_VERSION##2.7}" ]; then pip install -r test-requirements.txt $( [ -z "${TRAVIS_PYTHON_VERSION##pypy*}" -o -z "${TRAVIS_PYTHON_VERSION##3.[47891]*}" ] || echo " -r test-requirements-cpython.txt" ) ; fi # - CFLAGS="-O2 -ggdb -Wall -Wextra $(python -c 'import sys; print("-fno-strict-aliasing" if sys.version_info[0] == 2 else "")')" python setup.py build before_script: ccache -s || true diff --git a/CHANGES.rst b/CHANGES.rst index 8c76bf793..41becd976 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -359,6 +359,8 @@ Features added * Preliminary support for the CPython's ``Py_LIMITED_API`` (stable ABI) is available by setting the ``CYTHON_LIMITED_API`` C macro. Note that the support is currently in an early stage and many features do not yet work. + You currently still have to define ``Py_LIMITED_API`` externally in order + to restrict the API usage. This will change when the feature stabilises. Patches by Eddie Elizondo and David Woods. (Github issues :issue:`3223`, :issue:`3311`, :issue:`3501`) @@ -575,14 +577,25 @@ Other changes .. _`PEP-563`: https://www.python.org/dev/peps/pep-0563 .. _`PEP-479`: https://www.python.org/dev/peps/pep-0479 -0.29.23 (2021-??-??) + +0.29.23 (2021-04-14) ==================== Bugs fixed ---------- * Some problems with Python 3.10 were resolved. - Patches by Victor Stinner and David Woods. (Github issues #3919, #4046) + Patches by Victor Stinner and David Woods. (Github issues #4046, #4100) + +* An incorrect "optimisation" was removed that allowed changes to a keyword + dict to leak into keyword arguments passed into a function. + Patch by Peng Weikang. (Github issue #3227) + +* Multiplied str constants could end up as bytes constants with language_level=2. + Patch by Alphadelta14 and David Woods. (Github issue #3951) + +* ``PY_SSIZE_T_CLEAN`` does not get defined any more if it is already defined. + Patch by Andrew Jones. (Github issue #4104) 0.29.22 (2021-02-20) diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py index 8a268c173..46a763c37 100644 --- a/Cython/Build/Dependencies.py +++ b/Cython/Build/Dependencies.py @@ -613,10 +613,10 @@ class DependencyTree(object): @cached_method def immediate_dependencies(self, filename): - all = set([filename]) - all.update(self.cimported_files(filename)) - all.update(self.included_files(filename)) - return all + all_deps = {filename} + all_deps.update(self.cimported_files(filename)) + all_deps.update(self.included_files(filename)) + return all_deps def all_dependencies(self, filename): return self.transitive_merge(filename, self.immediate_dependencies, set.union) @@ -759,7 +759,7 @@ def create_extension_list(patterns, exclude=None, ctx=None, aliases=None, quiet= return [], {} elif isinstance(patterns, basestring) or not isinstance(patterns, Iterable): patterns = [patterns] - explicit_modules = set([m.name for m in patterns if isinstance(m, Extension)]) + explicit_modules = {m.name for m in patterns if isinstance(m, Extension)} seen = set() deps = create_dependency_tree(ctx, quiet=quiet) to_exclude = set() diff --git a/Cython/Compiler/Annotate.py b/Cython/Compiler/Annotate.py index 67e4662a8..48e73f853 100644 --- a/Cython/Compiler/Annotate.py +++ b/Cython/Compiler/Annotate.py @@ -87,7 +87,7 @@ class AnnotationCCodeWriter(CCodeWriter): body.cython { font-family: courier; font-size: 12; } .cython.tag { } - .cython.line { margin: 0em } + .cython.line { color: #000000; margin: 0em } .cython.code { font-size: 9; color: #444444; display: none; margin: 0px 0px 0px 8px; border-left: 8px none; } .cython.line .run { background-color: #B0FFB0; } diff --git a/Cython/Compiler/Builtin.py b/Cython/Compiler/Builtin.py index abfb3f0b9..4e606b2d9 100644 --- a/Cython/Compiler/Builtin.py +++ b/Cython/Compiler/Builtin.py @@ -346,15 +346,15 @@ builtin_types_table = [ ] -types_that_construct_their_instance = set([ +types_that_construct_their_instance = frozenset({ # some builtin types do not always return an instance of # themselves - these do: 'type', 'bool', 'long', 'float', 'complex', 'bytes', 'unicode', 'bytearray', - 'tuple', 'list', 'dict', 'set', 'frozenset' + 'tuple', 'list', 'dict', 'set', 'frozenset', # 'str', # only in Py3.x # 'file', # only in Py2.x -]) +}) builtin_structs_table = [ diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 7f77963b5..c7ee4d82d 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -100,12 +100,12 @@ uncachable_builtins = [ '_', # e.g. used by gettext ] -special_py_methods = set([ +special_py_methods = cython.declare(frozenset, frozenset(( '__cinit__', '__dealloc__', '__richcmp__', '__next__', '__await__', '__aiter__', '__anext__', '__getreadbuffer__', '__getwritebuffer__', '__getsegcount__', - '__getcharbuffer__', '__getbuffer__', '__releasebuffer__' -]) + '__getcharbuffer__', '__getbuffer__', '__releasebuffer__', +))) modifier_output_mapper = { 'inline': 'CYTHON_INLINE' @@ -382,7 +382,7 @@ class UtilityCodeBase(object): elif name == 'substitute': # don't want to pass "naming" or "tempita" to the constructor # since these will have been handled - values = values - set(['naming', 'tempita']) + values = values - {'naming', 'tempita'} if not values: continue elif not values: diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 938658d15..2714d3e4d 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -183,7 +183,7 @@ def infer_sequence_item_type(env, seq_node, index_node=None, seq_type=None): else: return item.infer_type(env) # if we're lucky, all items have the same type - item_types = set([item.infer_type(env) for item in seq_node.args]) + item_types = {item.infer_type(env) for item in seq_node.args} if len(item_types) == 1: return item_types.pop() return None @@ -6535,8 +6535,10 @@ class GeneralCallNode(CallNode): len(pos_args))) return None - matched_args = set([ arg.name for arg in declared_args[:len(pos_args)] - if arg.name ]) + matched_args = { + arg.name for arg in declared_args[:len(pos_args)] + if arg.name + } unmatched_args = declared_args[len(pos_args):] matched_kwargs_count = 0 args = list(pos_args) @@ -6754,22 +6756,13 @@ class MergedDictNode(ExprNode): return dict_type def analyse_types(self, env): - args = [ + self.keyword_args = [ arg.analyse_types(env).coerce_to_pyobject(env).as_none_safe_node( # FIXME: CPython's error message starts with the runtime function name 'argument after ** must be a mapping, not NoneType') for arg in self.keyword_args ] - if len(args) == 1 and args[0].type is dict_type: - # strip this intermediate node and use the bare dict - arg = args[0] - if arg.is_name and arg.entry.is_arg and len(arg.entry.cf_assignments) == 1: - # passing **kwargs through to function call => allow NULL - arg.allow_null = True - return arg - - self.keyword_args = args return self def may_be_none(self): @@ -8760,7 +8753,7 @@ class SetNode(ExprNode): return False def calculate_constant_result(self): - self.constant_result = set([arg.constant_result for arg in self.args]) + self.constant_result = {arg.constant_result for arg in self.args} def compile_time_value(self, denv): values = [arg.compile_time_value(denv) for arg in self.args] @@ -11810,10 +11803,10 @@ _find_formatting_types = re.compile( br")").findall # These format conversion types can never trigger a Unicode string conversion in Py2. -_safe_bytes_formats = set([ +_safe_bytes_formats = frozenset({ # Excludes 's' and 'r', which can generate non-bytes strings. b'd', b'i', b'o', b'u', b'x', b'X', b'e', b'E', b'f', b'F', b'g', b'G', b'c', b'b', b'a', -]) +}) class ModNode(DivNode): diff --git a/Cython/Compiler/FlowControl.py b/Cython/Compiler/FlowControl.py index 97fd8314f..5b51be0db 100644 --- a/Cython/Compiler/FlowControl.py +++ b/Cython/Compiler/FlowControl.py @@ -52,7 +52,7 @@ class ControlBlock(object): stats = [Assignment(a), NameReference(a), NameReference(c), Assignment(b)] gen = {Entry(a): Assignment(a), Entry(b): Assignment(b)} - bounded = set([Entry(a), Entry(c)]) + bounded = {Entry(a), Entry(c)} """ @@ -203,7 +203,7 @@ class ControlFlow(object): def normalize(self): """Delete unreachable and orphan blocks.""" - queue = set([self.entry_point]) + queue = {self.entry_point} visited = set() while queue: root = queue.pop() diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 2c47e98fd..77a92368c 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -705,7 +705,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("END: Cython Metadata */") code.putln("") + code.putln("#ifndef PY_SSIZE_T_CLEAN") code.putln("#define PY_SSIZE_T_CLEAN") + code.putln("#endif /* PY_SSIZE_T_CLEAN */") self._put_setup_code(code, "InitLimitedAPI") for inc in sorted(env.c_includes.values(), key=IncludeCode.sortkey): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 0d56a541c..5f935360f 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -115,9 +115,11 @@ class VerboseCodeWriter(type): class CheckAnalysers(type): """Metaclass to check that type analysis functions return a node. """ - methods = set(['analyse_types', - 'analyse_expressions', - 'analyse_target_types']) + methods = frozenset({ + 'analyse_types', + 'analyse_expressions', + 'analyse_target_types', + }) def __new__(cls, name, bases, attrs): from types import FunctionType diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 59e979b8b..25d654330 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -1236,7 +1236,7 @@ class SwitchTransform(Visitor.EnvTransform): # integers on iteration, whereas Py2 returns 1-char byte # strings characters = string_literal.value - characters = list(set([ characters[i:i+1] for i in range(len(characters)) ])) + characters = list({ characters[i:i+1] for i in range(len(characters)) }) characters.sort() return [ ExprNodes.CharNode(string_literal.pos, value=charval, constant_result=charval) @@ -1248,7 +1248,8 @@ class SwitchTransform(Visitor.EnvTransform): return self.NO_MATCH elif common_var is not None and not is_common_value(var, common_var): return self.NO_MATCH - elif not (var.type.is_int or var.type.is_enum) or sum([not (cond.type.is_int or cond.type.is_enum) for cond in conditions]): + elif not (var.type.is_int or var.type.is_enum) or any( + [not (cond.type.is_int or cond.type.is_enum) for cond in conditions]): return self.NO_MATCH return not_in, var, conditions @@ -2750,7 +2751,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin, Builtin.dict_type: "PyDict_Size", }.get - _ext_types_with_pysize = set(["cpython.array.array"]) + _ext_types_with_pysize = {"cpython.array.array"} def _handle_simple_function_len(self, node, function, pos_args): """Replace len(char*) by the equivalent call to strlen(), @@ -4425,6 +4426,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): string_node.unicode_value = encoded_string( string_node.unicode_value * multiplier, string_node.unicode_value.encoding) + build_string = encoded_string if string_node.value.is_unicode else bytes_literal elif isinstance(string_node, ExprNodes.UnicodeNode): if string_node.bytes_value is not None: string_node.bytes_value = bytes_literal( @@ -4432,9 +4434,14 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): string_node.bytes_value.encoding) else: assert False, "unknown string node type: %s" % type(string_node) - string_node.constant_result = string_node.value = build_string( + string_node.value = build_string( string_node.value * multiplier, string_node.value.encoding) + # follow constant-folding and use unicode_value in preference + if isinstance(string_node, ExprNodes.StringNode) and string_node.unicode_value is not None: + string_node.constant_result = string_node.unicode_value + else: + string_node.constant_result = string_node.value return string_node def _calculate_constant_seq(self, node, sequence_node, factor): diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 9ed29830c..330208840 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -685,17 +685,19 @@ class InterpretCompilerDirectives(CythonTransform): 'operator.comma' : ExprNodes.c_binop_constructor(','), } - special_methods = set(['declare', 'union', 'struct', 'typedef', - 'sizeof', 'cast', 'pointer', 'compiled', - 'NULL', 'fused_type', 'parallel']) + special_methods = { + 'declare', 'union', 'struct', 'typedef', + 'sizeof', 'cast', 'pointer', 'compiled', + 'NULL', 'fused_type', 'parallel', + } special_methods.update(unop_method_nodes) - valid_parallel_directives = set([ + valid_parallel_directives = { "parallel", "prange", "threadid", #"threadsavailable", - ]) + } def __init__(self, context, compilation_directive_defaults): super(InterpretCompilerDirectives, self).__init__(context) diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 45ee29ce1..45641a7d3 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -257,10 +257,10 @@ def p_cmp_op(s): op = '!=' return op -comparison_ops = cython.declare(set, set([ +comparison_ops = cython.declare(frozenset, frozenset(( '<', '>', '==', '>=', '<=', '<>', '!=', 'in', 'is', 'not' -])) +))) #expr: xor_expr ('|' xor_expr)* @@ -829,7 +829,7 @@ def p_cat_string_literal(s): continue elif next_kind != kind: # concatenating f strings and normal strings is allowed and leads to an f string - if set([kind, next_kind]) in (set(['f', 'u']), set(['f', ''])): + if {kind, next_kind} in ({'f', 'u'}, {'f', ''}): kind = 'f' else: error(pos, "Cannot mix string literals of different types, expected %s'', got %s''" % ( @@ -1486,8 +1486,8 @@ def p_genexp(s, expr): expr.pos, expr = ExprNodes.YieldExprNode(expr.pos, arg=expr))) return ExprNodes.GeneratorExpressionNode(expr.pos, loop=loop) -expr_terminators = cython.declare(set, set([ - ')', ']', '}', ':', '=', 'NEWLINE'])) +expr_terminators = cython.declare(frozenset, frozenset(( + ')', ']', '}', ':', '=', 'NEWLINE'))) #------------------------------------------------------- @@ -1792,7 +1792,8 @@ def p_from_import_statement(s, first_statement = 0): items = items) -imported_name_kinds = cython.declare(set, set(['class', 'struct', 'union'])) +imported_name_kinds = cython.declare(frozenset, frozenset(( + 'class', 'struct', 'union'))) def p_imported_name(s, is_cimport): pos = s.position() @@ -1839,7 +1840,8 @@ def p_assert_statement(s): return Nodes.AssertStatNode(pos, condition=cond, value=value) -statement_terminators = cython.declare(set, set([';', 'NEWLINE', 'EOF'])) +statement_terminators = cython.declare(frozenset, frozenset(( + ';', 'NEWLINE', 'EOF'))) def p_if_statement(s): # s.sy == 'if' @@ -1949,7 +1951,8 @@ def p_for_from_step(s): else: return None -inequality_relations = cython.declare(set, set(['<', '<=', '>', '>='])) +inequality_relations = cython.declare(frozenset, frozenset(( + '<', '<=', '>', '>='))) def p_target(s, terminator): pos = s.position() @@ -2463,8 +2466,8 @@ def p_calling_convention(s): return "" -calling_convention_words = cython.declare( - set, set(["__stdcall", "__cdecl", "__fastcall"])) +calling_convention_words = cython.declare(frozenset, frozenset(( + "__stdcall", "__cdecl", "__fastcall"))) def p_c_complex_base_type(s, templates = None): @@ -2743,8 +2746,8 @@ def looking_at_call(s): s.start_line, s.start_col = position return result -basic_c_type_names = cython.declare( - set, set(["void", "char", "int", "float", "double", "bint"])) +basic_c_type_names = cython.declare(frozenset, frozenset(( + "void", "char", "int", "float", "double", "bint"))) special_basic_c_types = cython.declare(dict, { # name : (signed, longness) @@ -2758,8 +2761,8 @@ special_basic_c_types = cython.declare(dict, { "Py_tss_t" : (1, 0), }) -sign_and_longness_words = cython.declare( - set, set(["short", "long", "signed", "unsigned"])) +sign_and_longness_words = cython.declare(frozenset, frozenset(( + "short", "long", "signed", "unsigned"))) base_type_start_words = cython.declare( set, @@ -2767,8 +2770,8 @@ base_type_start_words = cython.declare( | sign_and_longness_words | set(special_basic_c_types)) -struct_enum_union = cython.declare( - set, set(["struct", "union", "enum", "packed"])) +struct_enum_union = cython.declare(frozenset, frozenset(( + "struct", "union", "enum", "packed"))) def p_sign_and_longness(s): signed = 1 @@ -2853,13 +2856,13 @@ def p_c_func_declarator(s, pos, ctx, base, cmethod_flag): exception_value = exc_val, exception_check = exc_check, nogil = nogil or ctx.nogil or with_gil, with_gil = with_gil) -supported_overloaded_operators = cython.declare(set, set([ +supported_overloaded_operators = cython.declare(frozenset, frozenset(( '+', '-', '*', '/', '%', '++', '--', '~', '|', '&', '^', '<<', '>>', ',', '==', '!=', '>=', '>', '<=', '<', '[]', '()', '!', '=', 'bool', -])) +))) def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag, assignable, nonempty): @@ -2981,7 +2984,8 @@ def p_exception_value_clause(s): exc_val = p_test(s) return exc_val, exc_check -c_arg_list_terminators = cython.declare(set, set(['*', '**', '.', ')', ':', '/'])) +c_arg_list_terminators = cython.declare(frozenset, frozenset(( + '*', '**', '.', ')', ':', '/'))) def p_c_arg_list(s, ctx = Ctx(), in_pyfunc = 0, cmethod_flag = 0, nonempty_declarators = 0, kw_only = 0, annotated = 1): diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 030c8d3a6..7e7154c00 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1339,14 +1339,14 @@ class PyObjectType(PyrexType): return cname -builtin_types_that_cannot_create_refcycles = set([ +builtin_types_that_cannot_create_refcycles = frozenset({ 'object', 'bool', 'int', 'long', 'float', 'complex', - 'bytearray', 'bytes', 'unicode', 'str', 'basestring' -]) + 'bytearray', 'bytes', 'unicode', 'str', 'basestring', +}) -builtin_types_with_trashcan = set([ +builtin_types_with_trashcan = frozenset({ 'dict', 'list', 'set', 'frozenset', 'tuple', 'type', -]) +}) class BuiltinObjectType(PyObjectType): diff --git a/Cython/Compiler/TreePath.py b/Cython/Compiler/TreePath.py index 272570a03..858590555 100644 --- a/Cython/Compiler/TreePath.py +++ b/Cython/Compiler/TreePath.py @@ -10,6 +10,12 @@ from __future__ import absolute_import import re import operator +import sys + +if sys.version_info[0] >= 3: + _unicode = str +else: + _unicode = unicode path_tokenizer = re.compile( r"(" @@ -167,6 +173,11 @@ def handle_attribute(next, token): continue if attr_value == value: yield attr_value + elif (isinstance(attr_value, bytes) and isinstance(value, _unicode) and + attr_value == value.encode()): + # allow a bytes-to-string comparison too + yield attr_value + return select diff --git a/Cython/Compiler/Visitor.py b/Cython/Compiler/Visitor.py index 368c38058..0cf5ee1eb 100644 --- a/Cython/Compiler/Visitor.py +++ b/Cython/Compiler/Visitor.py @@ -834,8 +834,8 @@ class PrintTree(TreeVisitor): result += "(name=\"%s\")" % node.name elif isinstance(node, ExprNodes.AttributeNode): result += "(type=%s, attribute=\"%s\")" % (repr(node.type), node.attribute) - elif isinstance(node, ExprNodes.ConstNode): - result += "(type=%s, value=\"%s\")" % (repr(node.type), node.value) + elif isinstance(node, (ExprNodes.ConstNode, ExprNodes.PyConstNode)): + result += "(type=%s, value=%r)" % (repr(node.type), node.value) elif isinstance(node, ExprNodes.ExprNode): t = node.type result += "(type=%s)" % repr(t) diff --git a/Cython/Debugger/Tests/test_libcython_in_gdb.py b/Cython/Debugger/Tests/test_libcython_in_gdb.py index be662d12b..bb06c2905 100644 --- a/Cython/Debugger/Tests/test_libcython_in_gdb.py +++ b/Cython/Debugger/Tests/test_libcython_in_gdb.py @@ -134,7 +134,7 @@ class TestDebugInformationClasses(DebugTestCase): self.assertEqual(self.spam_func.arguments, ['a']) self.assertEqual(self.spam_func.step_into_functions, - set(['puts', 'some_c_function'])) + {'puts', 'some_c_function'}) expected_lineno = test_libcython.source_to_lineno['def spam(a=0):'] self.assertEqual(self.spam_func.lineno, expected_lineno) diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index 9d6c0e48a..2354c00a8 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -784,10 +784,6 @@ static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif -#if CYTHON_COMPILING_IN_PYPY && !defined(Py_ISSPACE) - #define Py_ISSPACE(c) Py_UNICODE_ISSPACE(c) -#endif - // ("..." % x) must call PyNumber_Remainder() if x is a string subclass that implements "__rmod__()". #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) diff --git a/Cython/Utility/Optimize.c b/Cython/Utility/Optimize.c index 83c848a74..f9637b670 100644 --- a/Cython/Utility/Optimize.c +++ b/Cython/Utility/Optimize.c @@ -897,6 +897,12 @@ parse_failure: return -1.0; } +static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) { + // see Py_ISSPACE() in CPython + // https://github.com/python/cpython/blob/master/Python/pyctype.c + return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd)); +} + static CYTHON_UNUSED double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) { double value; Py_ssize_t i, digits; @@ -904,9 +910,9 @@ static CYTHON_UNUSED double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* s char *end; // strip spaces at start and end - while (Py_ISSPACE(*start)) + while (__Pyx__PyBytes_AsDouble_IsSpace(*start)) start++; - while (start < last - 1 && Py_ISSPACE(last[-1])) + while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1])) last--; length = last - start; if (unlikely(length <= 0)) goto fallback; diff --git a/appveyor/install.ps1 b/appveyor/install.ps1 index 6a8fc6ad9..6dc32f40a 100644 --- a/appveyor/install.ps1 +++ b/appveyor/install.ps1 @@ -48,12 +48,14 @@ function InstallPython ($python_version, $architecture, $python_home) { $installer_exe = ($py_major + $py_minor) -as [int] -ge 35 if ($installer_exe) { $arch_suffix = @{"32"="";"64"="-amd64"}[$architecture] - $filename = "python-" + $python_version + $arch_suffix + ".exe" + $dl_filename = "python-" + $python_version + $arch_suffix + ".exe" + $filename = "python-" + $py_major + "." + $py_minor + $arch_suffix + ".exe" } else { $arch_suffix = @{"32"="";"64"=".amd64"}[$architecture] - $filename = "python-" + $python_version + $arch_suffix + ".msi" + $dl_filename = "python-" + $python_version + $arch_suffix + ".msi" + $filename = "python-" + $py_major + "." + $py_minor + $arch_suffix + ".msi" } - $url = $PYTHON_BASE_URL + $python_version + "/" + $filename + $url = $PYTHON_BASE_URL + $python_version + "/" + $dl_filename $filepath = Download $url $filename $DOWNLOADS Write-Host "Installing" $filename "to" $python_home if ($installer_exe) { @@ -99,7 +101,8 @@ function InstallPipPackage ($python_home, $package) { } function main () { - InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON + $full_version = $env:PYTHON_VERSION + ".0" + InstallPython $full_version $env:PYTHON_ARCH $env:PYTHON InstallPip $env:PYTHON InstallPipPackage $env:PYTHON setuptools InstallPipPackage $env:PYTHON wheel diff --git a/runtests.py b/runtests.py index 2840aeabf..91f190951 100755 --- a/runtests.py +++ b/runtests.py @@ -445,6 +445,7 @@ VER_DEP_MODULES = { INCLUDE_DIRS = [ d for d in os.getenv('INCLUDE', '').split(os.pathsep) if d ] CFLAGS = os.getenv('CFLAGS', '').split() CCACHE = os.getenv('CYTHON_RUNTESTS_CCACHE', '').split() +CDEFS = [] TEST_SUPPORT_DIR = 'testsupport' BACKENDS = ['c', 'cpp'] @@ -610,7 +611,7 @@ class Stats(object): if not self.test_times: return lines = ['Times:\n'] - for metric, t in sorted(self.test_times.items()): + for metric, t in sorted(self.test_times.items(), key=operator.itemgetter(1), reverse=True): count = self.test_counts[metric] top = self.top_tests[metric] lines.append("%-12s: %8.2f sec (%4d, %6.3f / run) - slowest: %s\n" % ( @@ -1105,6 +1106,7 @@ class CythonCompileTestCase(unittest.TestCase): build_extension.compiler = COMPILER ext_compile_flags = CFLAGS[:] + ext_compile_defines = CDEFS[:] if build_extension.compiler == 'mingw32': ext_compile_flags.append('-Wno-format') @@ -1119,6 +1121,7 @@ class CythonCompileTestCase(unittest.TestCase): module, sources=self.source_files(workdir, module, related_files), extra_compile_args=ext_compile_flags, + define_macros=ext_compile_defines, **extra_extension_args ) @@ -2443,7 +2446,7 @@ def runtests(options, cmd_args, coverage=None): build_in_temp=True, pyxbuild_dir=os.path.join(WORKDIR, "support")) sys.path.insert(0, os.path.split(libpath)[0]) - CFLAGS.append("-DCYTHON_REFNANNY=1") + CDEFS.append(('CYTHON_REFNANNY', '1')) if options.limited_api: CFLAGS.append("-DCYTHON_LIMITED_API=1") diff --git a/tests/buffers/bufaccess.pyx b/tests/buffers/bufaccess.pyx index db36efe78..6b0b4ac30 100644 --- a/tests/buffers/bufaccess.pyx +++ b/tests/buffers/bufaccess.pyx @@ -13,8 +13,6 @@ from cpython.object cimport PyObject from cpython.ref cimport Py_INCREF, Py_DECREF cimport cython -__test__ = {} - import sys #import re exclude = []#re.compile('object').search] @@ -27,8 +25,7 @@ if getattr(sys, 'pypy_version_info', None) is not None: def testcase(func): for e in exclude: if e(func.__name__): - return func - __test__[func.__name__] = func.__doc__ + func.__doc__ = "" # disable the test return func diff --git a/tests/buffers/buffmt.pyx b/tests/buffers/buffmt.pyx index 0aa0cb325..0a9757270 100644 --- a/tests/buffers/buffmt.pyx +++ b/tests/buffers/buffmt.pyx @@ -3,10 +3,6 @@ import struct # Tests buffer format string parsing. -__test__ = {} -def testcase(func): - __test__[func.__name__] = func.__doc__ - return func from libc cimport stdlib @@ -56,7 +52,6 @@ cdef class MockBuffer: info.format = self.format info.itemsize = self.itemsize -@testcase def _int(fmt): """ >>> _int("i") @@ -78,14 +73,12 @@ def _int(fmt): """ cdef object[int] buf = MockBuffer(fmt, sizeof(int)) -@testcase def _ulong(fmt): """ >>> _ulong("L") """ cdef object[unsigned long] buf = MockBuffer(fmt, sizeof(unsigned long)) -@testcase def wrongsize(): """ >>> wrongsize() @@ -96,7 +89,6 @@ def wrongsize(): """ cdef object[float] buf = MockBuffer("f", 1) -@testcase def _obj(fmt): """ >>> _obj("O") @@ -151,7 +143,6 @@ cdef struct UnpackedStruct4: char d int e, f, g -@testcase def char3int(fmt): """ >>> char3int("ciii") @@ -185,7 +176,6 @@ def char3int(fmt): cdef object[Char3Int, ndim=1] buf = obj -@testcase def long_string(fmt): """ >>> long_string("90198s") @@ -194,7 +184,6 @@ def long_string(fmt): cdef object[LongString, ndim=1] buf = obj -@testcase def unpacked_struct(fmt): """ Native formats: @@ -218,7 +207,6 @@ def unpacked_struct(fmt): cdef struct ComplexTest: ComplexFloat a, b, c -@testcase def complex_test(fmt): """ >>> complex_test("ZfZfZf") @@ -236,7 +224,6 @@ def complex_test(fmt): cdef object[ComplexTest] buf1 = obj -@testcase def alignment_string(fmt, exc=None): """ >>> alignment_string("@i") @@ -258,7 +245,6 @@ def alignment_string(fmt, exc=None): print "fail" -@testcase def int_and_long_are_same(): """ >>> int_and_long_are_same() @@ -273,7 +259,6 @@ cdef struct MixedComplex: double real float imag -@testcase def mixed_complex_struct(): """ Triggering a specific execution path for this case. @@ -311,7 +296,6 @@ cdef packed struct PartiallyPackedStruct2: char b int c -@testcase def packed_struct(fmt): """ Assuming int is four bytes: @@ -334,7 +318,6 @@ def packed_struct(fmt): """ cdef object[PackedStruct] buf = MockBuffer(fmt, sizeof(PackedStruct)) -@testcase def partially_packed_struct(fmt): """ Assuming int is four bytes: @@ -362,7 +345,6 @@ def partially_packed_struct(fmt): cdef object[PartiallyPackedStruct] buf = MockBuffer( fmt, sizeof(PartiallyPackedStruct)) -@testcase def partially_packed_struct_2(fmt): """ Assuming int is four bytes: @@ -380,7 +362,7 @@ def partially_packed_struct_2(fmt): Traceback (most recent call last): ... ValueError: Buffer dtype mismatch; next field is at offset 8 but 5 expected - + >>> partially_packed_struct_2("ccici") Traceback (most recent call last): ... @@ -398,7 +380,6 @@ cdef packed struct PackedStructWithCharArrays: char[3] d -@testcase def packed_struct_with_strings(fmt): """ >>> packed_struct_with_strings("T{f:a:i:b:5s:c:3s:d:}") @@ -430,7 +411,6 @@ ctypedef struct PackedStructWithNDArrays: float d -@testcase def packed_struct_with_arrays(fmt): """ >>> packed_struct_with_arrays("T{(16)d:a:(16)d:b:d:c:}") @@ -440,7 +420,6 @@ def packed_struct_with_arrays(fmt): fmt, sizeof(PackedStructWithArrays)) -@testcase def unpacked_struct_with_arrays(fmt): """ >>> if struct.calcsize('P') == 8: # 64 bit @@ -453,7 +432,6 @@ def unpacked_struct_with_arrays(fmt): fmt, sizeof(UnpackedStructWithArrays)) -@testcase def packed_struct_with_ndarrays(fmt): """ >>> packed_struct_with_ndarrays("T{d:a:(2,2)d:b:f:c:f:d:}") diff --git a/tests/compile/cast_ctypedef_array_T518.pyx b/tests/compile/cast_ctypedef_array_T518.pyx index a62f4cf4c..6a52374c3 100644 --- a/tests/compile/cast_ctypedef_array_T518.pyx +++ b/tests/compile/cast_ctypedef_array_T518.pyx @@ -1,4 +1,4 @@ -# ticket: 518 +# ticket: t518 # mode: compile cdef extern from "cast_ctypedef_array_T518_helper.h": diff --git a/tests/compile/cimport_package_module_T4.pyx b/tests/compile/cimport_package_module_T4.pyx index 28403f122..717f0bf8f 100644 --- a/tests/compile/cimport_package_module_T4.pyx +++ b/tests/compile/cimport_package_module_T4.pyx @@ -1,4 +1,4 @@ -# ticket: 4 +# ticket: t4 # mode: compile from a cimport b diff --git a/tests/compile/cimportfrom_T248.pyx b/tests/compile/cimportfrom_T248.pyx index 13796baf1..1be252f3c 100644 --- a/tests/compile/cimportfrom_T248.pyx +++ b/tests/compile/cimportfrom_T248.pyx @@ -1,4 +1,4 @@ -# ticket: 248 +# ticket: t248 # mode: compile from ewing8 cimport (Foo, diff --git a/tests/compile/cpp_templates.pyx b/tests/compile/cpp_templates.pyx index cab981e38..7952a1610 100644 --- a/tests/compile/cpp_templates.pyx +++ b/tests/compile/cpp_templates.pyx @@ -1,6 +1,6 @@ # tag: cpp # mode: compile -# ticket: 767 +# ticket: t767 cdef extern from "templates.h": cdef cppclass TemplateTest1[T]: diff --git a/tests/compile/ctypedef_public_class_T355.pyx b/tests/compile/ctypedef_public_class_T355.pyx index 505f9d67f..ceb2d65e4 100644 --- a/tests/compile/ctypedef_public_class_T355.pyx +++ b/tests/compile/ctypedef_public_class_T355.pyx @@ -1,4 +1,4 @@ -# ticket: 355 +# ticket: t355 # mode: compile ctypedef public class Time [type MyTime_Type, object MyTimeObject]: diff --git a/tests/compile/ellipsis_T488.pyx b/tests/compile/ellipsis_T488.pyx index d90d21634..804b18497 100644 --- a/tests/compile/ellipsis_T488.pyx +++ b/tests/compile/ellipsis_T488.pyx @@ -1,4 +1,4 @@ -# ticket: 488 +# ticket: t488 # mode: compile #from ... import foo diff --git a/tests/compile/weakref_T276.pyx b/tests/compile/weakref_T276.pyx index d56f67303..7fbc52819 100644 --- a/tests/compile/weakref_T276.pyx +++ b/tests/compile/weakref_T276.pyx @@ -1,4 +1,4 @@ -# ticket: 276 +# ticket: t276 # mode: compile __doc__ = u""" diff --git a/tests/errors/bufaccess_noassignT444.pyx b/tests/errors/bufaccess_noassignT444.pyx index 44d2ebd0b..c618106fb 100644 --- a/tests/errors/bufaccess_noassignT444.pyx +++ b/tests/errors/bufaccess_noassignT444.pyx @@ -1,4 +1,4 @@ -# ticket: 444 +# ticket: t444 # mode: error def test(): diff --git a/tests/errors/buffertypedef_T117.pyx b/tests/errors/buffertypedef_T117.pyx index d88a3895b..cefa79939 100644 --- a/tests/errors/buffertypedef_T117.pyx +++ b/tests/errors/buffertypedef_T117.pyx @@ -1,4 +1,4 @@ -# ticket: 117 +# ticket: t117 # mode: error ctypedef object[float] mybuffer diff --git a/tests/errors/callingnonexisting_T307.pyx b/tests/errors/callingnonexisting_T307.pyx index e9409fcab..ac767e581 100644 --- a/tests/errors/callingnonexisting_T307.pyx +++ b/tests/errors/callingnonexisting_T307.pyx @@ -1,4 +1,4 @@ -# ticket: 307 +# ticket: t307 # mode: error nonexisting(3, with_kw_arg=4) diff --git a/tests/errors/cdef_class_properties_decorated.pyx b/tests/errors/cdef_class_properties_decorated.pyx index 7485d8891..f796b7128 100644 --- a/tests/errors/cdef_class_properties_decorated.pyx +++ b/tests/errors/cdef_class_properties_decorated.pyx @@ -1,5 +1,5 @@ # mode: error -# ticket: 264 +# ticket: t264 # tag: property, decorator diff --git a/tests/errors/cdef_members_T517.pyx b/tests/errors/cdef_members_T517.pyx index 9bd3b111c..34bfd79fd 100644 --- a/tests/errors/cdef_members_T517.pyx +++ b/tests/errors/cdef_members_T517.pyx @@ -1,4 +1,4 @@ -# ticket: 517 +# ticket: t517 # mode: error ctypedef void* VoidP diff --git a/tests/errors/compile_time_unraisable_T370.pyx b/tests/errors/compile_time_unraisable_T370.pyx index 963f280fb..d22f0c6c0 100644 --- a/tests/errors/compile_time_unraisable_T370.pyx +++ b/tests/errors/compile_time_unraisable_T370.pyx @@ -1,4 +1,4 @@ -# ticket: 370 +# ticket: t370 # mode: error cdef int raiseit(): diff --git a/tests/errors/declareafteruse_T158.pyx b/tests/errors/declareafteruse_T158.pyx index fb55d3dcb..a6ff6da13 100644 --- a/tests/errors/declareafteruse_T158.pyx +++ b/tests/errors/declareafteruse_T158.pyx @@ -1,4 +1,4 @@ -# ticket: 158 +# ticket: t158 # mode: error def mult_decl_test(): diff --git a/tests/errors/e2_packedstruct_T290.pyx b/tests/errors/e2_packedstruct_T290.pyx index 1a0f40f18..084b36d71 100644 --- a/tests/errors/e2_packedstruct_T290.pyx +++ b/tests/errors/e2_packedstruct_T290.pyx @@ -1,4 +1,4 @@ -# ticket: 290 +# ticket: t290 # mode: error cdef packed foo: diff --git a/tests/errors/e_cdef_keywords_T241.pyx b/tests/errors/e_cdef_keywords_T241.pyx index 87524ebdd..28a2783fe 100644 --- a/tests/errors/e_cdef_keywords_T241.pyx +++ b/tests/errors/e_cdef_keywords_T241.pyx @@ -1,4 +1,4 @@ -# ticket: 241 +# ticket: t241 # mode: error cdef some_function(x, y): diff --git a/tests/errors/e_tuple_args_T692.py b/tests/errors/e_tuple_args_T692.py index 6b8dc73d6..3ca30519b 100644 --- a/tests/errors/e_tuple_args_T692.py +++ b/tests/errors/e_tuple_args_T692.py @@ -1,4 +1,4 @@ -# ticket: 692 +# ticket: t692 # mode: error def func((a, b)): diff --git a/tests/errors/missing_baseclass_in_predecl_T262.pyx b/tests/errors/missing_baseclass_in_predecl_T262.pyx index ece07b155..907f072f5 100644 --- a/tests/errors/missing_baseclass_in_predecl_T262.pyx +++ b/tests/errors/missing_baseclass_in_predecl_T262.pyx @@ -1,4 +1,4 @@ -# ticket: 262 +# ticket: t262 # mode: error cdef class Album diff --git a/tests/errors/missing_self_in_cpdef_method_T156.pyx b/tests/errors/missing_self_in_cpdef_method_T156.pyx index 21241a221..e8b0c5369 100644 --- a/tests/errors/missing_self_in_cpdef_method_T156.pyx +++ b/tests/errors/missing_self_in_cpdef_method_T156.pyx @@ -1,4 +1,4 @@ -# ticket: 156 +# ticket: t156 # mode: error cdef class B: diff --git a/tests/errors/missing_self_in_cpdef_method_T165.pyx b/tests/errors/missing_self_in_cpdef_method_T165.pyx index 6a95922d5..89763cd2a 100644 --- a/tests/errors/missing_self_in_cpdef_method_T165.pyx +++ b/tests/errors/missing_self_in_cpdef_method_T165.pyx @@ -1,4 +1,4 @@ -# ticket: 165 +# ticket: t165 # mode: error cdef class A: diff --git a/tests/errors/notcimportedT418.pyx b/tests/errors/notcimportedT418.pyx index 980d66555..c2821fb83 100644 --- a/tests/errors/notcimportedT418.pyx +++ b/tests/errors/notcimportedT418.pyx @@ -1,4 +1,4 @@ -# ticket: 418 +# ticket: t418 # mode: error import somemod.child diff --git a/tests/errors/pxd_cdef_class_declaration_T286.pyx b/tests/errors/pxd_cdef_class_declaration_T286.pyx index 0c968f701..b1a8bc844 100644 --- a/tests/errors/pxd_cdef_class_declaration_T286.pyx +++ b/tests/errors/pxd_cdef_class_declaration_T286.pyx @@ -1,4 +1,4 @@ -# ticket: 286 +# ticket: t286 # mode: error cdef class A: diff --git a/tests/errors/pyobjcastdisallow_T313.pyx b/tests/errors/pyobjcastdisallow_T313.pyx index 5048719d8..30973380f 100644 --- a/tests/errors/pyobjcastdisallow_T313.pyx +++ b/tests/errors/pyobjcastdisallow_T313.pyx @@ -1,4 +1,4 @@ -# ticket: 313 +# ticket: t313 # mode: error a = 3 diff --git a/tests/errors/return_outside_function_T135.pyx b/tests/errors/return_outside_function_T135.pyx index d7432ca50..4788c2a72 100644 --- a/tests/errors/return_outside_function_T135.pyx +++ b/tests/errors/return_outside_function_T135.pyx @@ -1,5 +1,5 @@ # cython: remove_unreachable=False -# ticket: 135 +# ticket: t135 # mode: error def _runtime_True(): diff --git a/tests/errors/typoT304.pyx b/tests/errors/typoT304.pyx index 7c736c898..2de5573d4 100644 --- a/tests/errors/typoT304.pyx +++ b/tests/errors/typoT304.pyx @@ -1,4 +1,4 @@ -# ticket: 304 +# ticket: t304 # mode: error def f(): diff --git a/tests/errors/uninitialized_lhs.pyx b/tests/errors/uninitialized_lhs.pyx index 5d5ece854..8550761a4 100644 --- a/tests/errors/uninitialized_lhs.pyx +++ b/tests/errors/uninitialized_lhs.pyx @@ -1,7 +1,7 @@ # cython: warn.maybe_uninitialized=True # mode: error # tag: werror -# ticket: 739 +# ticket: t739 def index_lhs(a): cdef object idx diff --git a/tests/memoryview/memoryviewattrs.pyx b/tests/memoryview/memoryviewattrs.pyx index 66bc9da56..7322424c3 100644 --- a/tests/memoryview/memoryviewattrs.pyx +++ b/tests/memoryview/memoryviewattrs.pyx @@ -1,13 +1,6 @@ # mode: run # tag: numpy -__test__ = {} - -def testcase(func): - __test__[func.__name__] = func.__doc__ - return func - - cimport cython from cython.view cimport array @@ -15,7 +8,6 @@ import numpy as np cimport numpy as np -@testcase def test_shape_stride_suboffset(): u''' >>> test_shape_stride_suboffset() @@ -49,7 +41,6 @@ def test_shape_stride_suboffset(): print c_contig.suboffsets[0], c_contig.suboffsets[1], c_contig.suboffsets[2] -@testcase def test_copy_to(): u''' >>> test_copy_to() @@ -72,7 +63,6 @@ def test_copy_to(): print ' '.join(str(to_data[i]) for i in range(2*2*2)) -@testcase def test_overlapping_copy(): """ >>> test_overlapping_copy() @@ -88,7 +78,6 @@ def test_overlapping_copy(): assert slice[i] == 10 - 1 - i -@testcase def test_copy_return_type(): """ >>> test_copy_return_type() @@ -103,7 +92,6 @@ def test_copy_return_type(): print(f_contig[2, 2]) -@testcase def test_partly_overlapping(): """ >>> test_partly_overlapping() @@ -119,7 +107,6 @@ def test_partly_overlapping(): for i in range(5): assert slice2[i] == i + 4 -@testcase @cython.nonecheck(True) def test_nonecheck1(): u''' @@ -131,7 +118,6 @@ def test_nonecheck1(): cdef int[:,:,:] uninitialized print uninitialized.is_c_contig() -@testcase @cython.nonecheck(True) def test_nonecheck2(): u''' @@ -143,7 +129,6 @@ def test_nonecheck2(): cdef int[:,:,:] uninitialized print uninitialized.is_f_contig() -@testcase @cython.nonecheck(True) def test_nonecheck3(): u''' @@ -155,7 +140,6 @@ def test_nonecheck3(): cdef int[:,:,:] uninitialized uninitialized.copy() -@testcase @cython.nonecheck(True) def test_nonecheck4(): u''' @@ -167,7 +151,6 @@ def test_nonecheck4(): cdef int[:,:,:] uninitialized uninitialized.copy_fortran() -@testcase @cython.nonecheck(True) def test_nonecheck5(): u''' @@ -179,7 +162,6 @@ def test_nonecheck5(): cdef int[:,:,:] uninitialized uninitialized._data -@testcase def test_copy_mismatch(): u''' >>> test_copy_mismatch() @@ -193,7 +175,6 @@ def test_copy_mismatch(): mv1[...] = mv2 -@testcase def test_is_contiguous(): u""" >>> test_is_contiguous() @@ -222,7 +203,6 @@ def test_is_contiguous(): print 'strided', strided[::2].is_c_contig() -@testcase def call(): u''' >>> call() @@ -265,7 +245,6 @@ def call(): assert len(mv3) == 3 -@testcase def two_dee(): u''' >>> two_dee() @@ -313,7 +292,6 @@ def two_dee(): print (<long*>mv3._data)[0] , (<long*>mv3._data)[1] , (<long*>mv3._data)[2] , (<long*>mv3._data)[3] -@testcase def fort_two_dee(): u''' >>> fort_two_dee() diff --git a/tests/memoryview/numpy_memoryview.pyx b/tests/memoryview/numpy_memoryview.pyx index 0d6f9e12f..6860fafeb 100644 --- a/tests/memoryview/numpy_memoryview.pyx +++ b/tests/memoryview/numpy_memoryview.pyx @@ -17,6 +17,10 @@ include "../buffers/mockbuffers.pxi" ctypedef np.int32_t dtype_t +IS_PYPY = hasattr(sys, 'pypy_version_info') +NUMPY_VERSION = tuple(int(v) for v in np.__version__.split('.')[:2]) +print(NUMPY_VERSION) + def get_array(): # We need to type our array to get a __pyx_get_buffer() that typechecks # for np.ndarray and calls __getbuffer__ in numpy.pxd @@ -32,22 +36,13 @@ def ae(*args): if x != args[0]: raise AssertionError(args) -__test__ = {} - -def testcase(f): - __test__[f.__name__] = f.__doc__ - return f - -def testcase_numpy_1_5(f): - major, minor, *rest = np.__version__.split('.') - if (int(major), int(minor)) >= (1, 5): - __test__[f.__name__] = f.__doc__ +def testcase_no_pypy(f, _is_pypy=hasattr(sys, "pypy_version_info")): + if _is_pypy: + f.__doc__ = "" # disable the tests return f - def gc_collect_if_required(): - major, minor, *rest = np.__version__.split('.') - if (int(major), int(minor)) >= (1, 14): + if NUMPY_VERSION >= (1, 14) or IS_PYPY: import gc gc.collect() @@ -56,7 +51,6 @@ def gc_collect_if_required(): ### Test slicing memoryview slices # -@testcase def test_partial_slicing(array): """ >>> test_partial_slicing(a) @@ -72,7 +66,6 @@ def test_partial_slicing(array): ae(b.strides[0], c.strides[0], obj.strides[0]) ae(b.strides[1], c.strides[1], obj.strides[1]) -@testcase def test_ellipsis(array): """ >>> test_ellipsis(a) @@ -114,7 +107,6 @@ def test_ellipsis(array): # ### Test slicing memoryview objects # -@testcase def test_partial_slicing_memoryview(array): """ >>> test_partial_slicing_memoryview(a) @@ -131,7 +123,6 @@ def test_partial_slicing_memoryview(array): ae(b.strides[0], c.strides[0], obj.strides[0]) ae(b.strides[1], c.strides[1], obj.strides[1]) -@testcase def test_ellipsis_memoryview(array): """ >>> test_ellipsis_memoryview(a) @@ -172,7 +163,6 @@ def test_ellipsis_memoryview(array): ae(e.strides[0], e_obj.strides[0]) -@testcase def test_transpose(): """ >>> test_transpose() @@ -203,7 +193,6 @@ def test_transpose(): print a[3, 2], a.T[2, 3], a_obj[3, 2], a_obj.T[2, 3], numpy_obj[3, 2], numpy_obj.T[2, 3] -@testcase def test_transpose_type(a): """ >>> a = np.zeros((5, 10), dtype=np.float64) @@ -216,12 +205,8 @@ def test_transpose_type(a): print m_transpose[6, 4] -@testcase_numpy_1_5 def test_numpy_like_attributes(cyarray): """ - For some reason this fails in numpy 1.4, with shape () and strides (40, 8) - instead of 20, 4 on my machine. Investigate this. - >>> cyarray = create_array(shape=(8, 5), mode="c") >>> test_numpy_like_attributes(cyarray) >>> test_numpy_like_attributes(cyarray.memview) @@ -237,7 +222,6 @@ def test_numpy_like_attributes(cyarray): cdef int[:, :] mslice = numarray assert (<object> mslice).base is numarray -@testcase_numpy_1_5 def test_copy_and_contig_attributes(a): """ >>> a = np.arange(20, dtype=np.int32).reshape(5, 4) @@ -274,7 +258,7 @@ def build_numarray(array array): def index(array array): print build_numarray(array)[3, 2] -@testcase_numpy_1_5 +@testcase_no_pypy def test_coerce_to_numpy(): """ Test coercion to NumPy arrays, especially with automatically @@ -355,6 +339,7 @@ def test_coerce_to_numpy(): 'e': 800, } + smallstructs[idx] = { 'a': 600, 'b': 700 } nestedstructs[idx] = { @@ -412,7 +397,7 @@ def test_coerce_to_numpy(): index(<td_h_ushort[:4, :5]> <td_h_ushort *> h_ushorts) -@testcase_numpy_1_5 +@testcase_no_pypy def test_memslice_getbuffer(): """ >>> test_memslice_getbuffer(); gc_collect_if_required() @@ -451,7 +436,6 @@ cdef packed struct StructArray: int a[4] signed char b[5] -@testcase_numpy_1_5 def test_memslice_structarray(data, dtype): """ >>> def b(s): return s.encode('ascii') @@ -507,7 +491,6 @@ def test_memslice_structarray(data, dtype): print myslice[i].a[j] print myslice[i].b.decode('ASCII') -@testcase_numpy_1_5 def test_structarray_errors(StructArray[:] a): """ >>> dtype = np.dtype([('a', '4i'), ('b', '5b')]) @@ -554,7 +537,6 @@ def stringstructtest(StringStruct[:] view): def stringtest(String[:] view): pass -@testcase_numpy_1_5 def test_string_invalid_dims(): """ >>> def b(s): return s.encode('ascii') @@ -575,7 +557,6 @@ ctypedef struct AttributesStruct: float attrib2 StringStruct attrib3 -@testcase_numpy_1_5 def test_struct_attributes(): """ >>> test_struct_attributes() @@ -631,7 +612,6 @@ cdef class SuboffsetsNoStridesBuffer(Buffer): getbuffer(self, info) info.suboffsets = self._shape -@testcase def test_null_strides(Buffer buffer_obj): """ >>> test_null_strides(Buffer()) @@ -651,7 +631,6 @@ def test_null_strides(Buffer buffer_obj): assert m2[i, j] == buffer_obj.m[i, j], (i, j, m2[i, j], buffer_obj.m[i, j]) assert m3[i, j] == buffer_obj.m[i, j] -@testcase def test_null_strides_error(buffer_obj): """ >>> test_null_strides_error(Buffer()) @@ -725,7 +704,6 @@ ctypedef struct SameTypeAfterArraysStructSimple: double b[16] double c -@testcase def same_type_after_arrays_simple(): """ >>> same_type_after_arrays_simple() @@ -747,7 +725,6 @@ ctypedef struct SameTypeAfterArraysStructComposite: double h[4] int i -@testcase def same_type_after_arrays_composite(): """ >>> same_type_after_arrays_composite() if sys.version_info[:2] >= (3, 5) else None diff --git a/tests/run/always_allow_keywords_T295.pyx b/tests/run/always_allow_keywords_T295.pyx index aabae5b36..8e6e07739 100644 --- a/tests/run/always_allow_keywords_T295.pyx +++ b/tests/run/always_allow_keywords_T295.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 295 +# ticket: t295 cimport cython diff --git a/tests/run/args_unpacking_in_closure_T658.pyx b/tests/run/args_unpacking_in_closure_T658.pyx index 98b57743b..b52d689c9 100644 --- a/tests/run/args_unpacking_in_closure_T658.pyx +++ b/tests/run/args_unpacking_in_closure_T658.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 658 +# ticket: t658 def outer(int x, *args, **kwargs): """ diff --git a/tests/run/argument_unpacking_closure_T736.py b/tests/run/argument_unpacking_closure_T736.py index 6c83d7026..80c824417 100644 --- a/tests/run/argument_unpacking_closure_T736.py +++ b/tests/run/argument_unpacking_closure_T736.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 736 +# ticket: t736 # tag: default arguments, closure def default_args_for_closure(a=1, b=2): diff --git a/tests/run/arithmetic_analyse_types.pyx b/tests/run/arithmetic_analyse_types.pyx index 7d5e41666..c8c7f7ac8 100644 --- a/tests/run/arithmetic_analyse_types.pyx +++ b/tests/run/arithmetic_analyse_types.pyx @@ -1,4 +1,4 @@ -# ticket: 676 +# ticket: t676 # tag: cpp from cython cimport typeof diff --git a/tests/run/bad_c_struct_T252.pyx b/tests/run/bad_c_struct_T252.pyx index 247a55202..57b1155c2 100644 --- a/tests/run/bad_c_struct_T252.pyx +++ b/tests/run/bad_c_struct_T252.pyx @@ -1,4 +1,4 @@ -# ticket: 252 +# ticket: t252 cdef cf(default=None): return default diff --git a/tests/run/bint_binop_T145.pyx b/tests/run/bint_binop_T145.pyx index c6df52303..f0f0ef560 100644 --- a/tests/run/bint_binop_T145.pyx +++ b/tests/run/bint_binop_T145.pyx @@ -1,4 +1,4 @@ -# ticket: 145 +# ticket: t145 cimport cython diff --git a/tests/run/bint_property_T354.pyx b/tests/run/bint_property_T354.pyx index 5a461ac76..ef4c623ee 100644 --- a/tests/run/bint_property_T354.pyx +++ b/tests/run/bint_property_T354.pyx @@ -1,4 +1,4 @@ -# ticket: 354 +# ticket: t354 cdef class Test: """ diff --git a/tests/run/bound_builtin_methods_T589.pyx b/tests/run/bound_builtin_methods_T589.pyx index 18a517cbd..1d2fb9f66 100644 --- a/tests/run/bound_builtin_methods_T589.pyx +++ b/tests/run/bound_builtin_methods_T589.pyx @@ -1,4 +1,4 @@ -# ticket: 589 +# ticket: t589 cimport cython diff --git a/tests/run/builtin_abs.pyx b/tests/run/builtin_abs.pyx index 5b35eb886..59f3a93c4 100644 --- a/tests/run/builtin_abs.pyx +++ b/tests/run/builtin_abs.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 698 +# ticket: t698 # distutils: extra_compile_args=-fwrapv cdef extern from *: diff --git a/tests/run/builtin_methods_return_values.pyx b/tests/run/builtin_methods_return_values.pyx index 50f1427ca..09a25273c 100644 --- a/tests/run/builtin_methods_return_values.pyx +++ b/tests/run/builtin_methods_return_values.pyx @@ -1,6 +1,6 @@ # mode: run # tag: list, set, builtins -# ticket: 688 +# ticket: t688 _set = set diff --git a/tests/run/builtin_subtype_methods_T653.pyx b/tests/run/builtin_subtype_methods_T653.pyx index bcfda81f0..522cffff8 100644 --- a/tests/run/builtin_subtype_methods_T653.pyx +++ b/tests/run/builtin_subtype_methods_T653.pyx @@ -1,6 +1,6 @@ #cython: language_level=2 # mode: run -# ticket: 653 +# ticket: t653 cimport cython diff --git a/tests/run/builtin_subtype_methods_cy3.pyx b/tests/run/builtin_subtype_methods_cy3.pyx index 1cff75fb7..1f54ac598 100644 --- a/tests/run/builtin_subtype_methods_cy3.pyx +++ b/tests/run/builtin_subtype_methods_cy3.pyx @@ -1,6 +1,6 @@ # cython: language_level=3 # mode: run -# ticket: 653 +# ticket: t653 class DictPySubtype(dict): diff --git a/tests/run/builtin_type_inheritance_T608.pyx b/tests/run/builtin_type_inheritance_T608.pyx index 67e97ec1e..1214b6841 100644 --- a/tests/run/builtin_type_inheritance_T608.pyx +++ b/tests/run/builtin_type_inheritance_T608.pyx @@ -1,4 +1,4 @@ -# ticket: 608 +# ticket: t608 cdef class MyInt(int): """ diff --git a/tests/run/builtin_types_none_T166.pyx b/tests/run/builtin_types_none_T166.pyx index 33cabffa8..276f52724 100644 --- a/tests/run/builtin_types_none_T166.pyx +++ b/tests/run/builtin_types_none_T166.pyx @@ -1,4 +1,4 @@ -# ticket: 166 +# ticket: t166 __doc__ = u""" >>> l = None diff --git a/tests/run/c_int_types_T255.pyx b/tests/run/c_int_types_T255.pyx index a9224f500..58b7839d9 100644 --- a/tests/run/c_int_types_T255.pyx +++ b/tests/run/c_int_types_T255.pyx @@ -1,4 +1,4 @@ -# ticket: 255 +# ticket: t255 __doc__ = u"" diff --git a/tests/run/c_type_methods_T236.pyx b/tests/run/c_type_methods_T236.pyx index 53f20e661..b1ef5d023 100644 --- a/tests/run/c_type_methods_T236.pyx +++ b/tests/run/c_type_methods_T236.pyx @@ -1,4 +1,4 @@ -# ticket: 236 +# ticket: t236 import sys diff --git a/tests/run/cascaded_list_unpacking_T467.pyx b/tests/run/cascaded_list_unpacking_T467.pyx index 3008bddaf..fc0963d0d 100644 --- a/tests/run/cascaded_list_unpacking_T467.pyx +++ b/tests/run/cascaded_list_unpacking_T467.pyx @@ -1,4 +1,4 @@ -# ticket: 467 +# ticket: t467 def simple_parallel_assignment_from_call(): """ diff --git a/tests/run/cascaded_typed_assignments_T466.pyx b/tests/run/cascaded_typed_assignments_T466.pyx index eef9d5b7c..c2081bf91 100644 --- a/tests/run/cascaded_typed_assignments_T466.pyx +++ b/tests/run/cascaded_typed_assignments_T466.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 466 +# ticket: t466 # extension to T409 cimport cython diff --git a/tests/run/cdef_bool_T227.pyx b/tests/run/cdef_bool_T227.pyx index 889963951..be403e695 100644 --- a/tests/run/cdef_bool_T227.pyx +++ b/tests/run/cdef_bool_T227.pyx @@ -1,4 +1,4 @@ -# ticket: 227 +# ticket: t227 from cpython.bool cimport bool diff --git a/tests/run/cdef_class_field.pyx b/tests/run/cdef_class_field.pyx index 9fb745ecb..5012bab89 100644 --- a/tests/run/cdef_class_field.pyx +++ b/tests/run/cdef_class_field.pyx @@ -1,6 +1,6 @@ # mode: run # tag: exttype -# ticket: 677 +# ticket: t677 """ >>> str(Foo(4)) diff --git a/tests/run/cdef_class_property_decorator_T264.pyx b/tests/run/cdef_class_property_decorator_T264.pyx index 421f762bc..b53bd7ec1 100644 --- a/tests/run/cdef_class_property_decorator_T264.pyx +++ b/tests/run/cdef_class_property_decorator_T264.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 264 +# ticket: t264 # tag: property, decorator my_property = property diff --git a/tests/run/cdef_decorator_directives_T183.pyx b/tests/run/cdef_decorator_directives_T183.pyx index 84b05a8df..dc362b255 100644 --- a/tests/run/cdef_decorator_directives_T183.pyx +++ b/tests/run/cdef_decorator_directives_T183.pyx @@ -1,4 +1,4 @@ -# ticket: 183 +# ticket: t183 cimport cython diff --git a/tests/run/cdef_locals_decorator_T477.pyx b/tests/run/cdef_locals_decorator_T477.pyx index 2b40d05ad..5af71e748 100644 --- a/tests/run/cdef_locals_decorator_T477.pyx +++ b/tests/run/cdef_locals_decorator_T477.pyx @@ -1,4 +1,4 @@ -# ticket: 477 +# ticket: t477 import cython @cython.locals(x=double) diff --git a/tests/run/cdef_members_T517.pyx b/tests/run/cdef_members_T517.pyx index d69d72ca4..389879f67 100644 --- a/tests/run/cdef_members_T517.pyx +++ b/tests/run/cdef_members_T517.pyx @@ -1,4 +1,4 @@ -# ticket: 517 +# ticket: t517 #cython: embedsignature=True __doc__ = u""" diff --git a/tests/run/cdef_methods_T462.pyx b/tests/run/cdef_methods_T462.pyx index dde15adbc..80bfa4b6f 100644 --- a/tests/run/cdef_methods_T462.pyx +++ b/tests/run/cdef_methods_T462.pyx @@ -1,4 +1,4 @@ -# ticket: 462 +# ticket: t462 cimport cython diff --git a/tests/run/cdef_setitem_T284.pyx b/tests/run/cdef_setitem_T284.pyx index 2c885d5be..389b8c409 100644 --- a/tests/run/cdef_setitem_T284.pyx +++ b/tests/run/cdef_setitem_T284.pyx @@ -1,4 +1,4 @@ -# ticket: 284 +# ticket: t284 def no_cdef(): """ diff --git a/tests/run/cfunc_call_tuple_args_T408.pyx b/tests/run/cfunc_call_tuple_args_T408.pyx index 165329737..e32eb036c 100644 --- a/tests/run/cfunc_call_tuple_args_T408.pyx +++ b/tests/run/cfunc_call_tuple_args_T408.pyx @@ -1,4 +1,4 @@ -# ticket: 408 +# ticket: t408 __doc__ = """ >>> call_with_tuple(1, 1.2, 'test', [1,2,3]) diff --git a/tests/run/char_constants_T99.pyx b/tests/run/char_constants_T99.pyx index aa2550b52..241b461a1 100644 --- a/tests/run/char_constants_T99.pyx +++ b/tests/run/char_constants_T99.pyx @@ -1,4 +1,4 @@ -# ticket: 99 +# ticket: t99 cdef char c = 'c' cdef char* s = 'abcdef' diff --git a/tests/run/charcomparisonT412.pyx b/tests/run/charcomparisonT412.pyx index b9316a36c..97afb4769 100644 --- a/tests/run/charcomparisonT412.pyx +++ b/tests/run/charcomparisonT412.pyx @@ -1,4 +1,4 @@ -# ticket: 412 +# ticket: t412 def f(): """ diff --git a/tests/run/charptr_comparison_T582.pyx b/tests/run/charptr_comparison_T582.pyx index 3701921cf..1e5e43cd2 100644 --- a/tests/run/charptr_comparison_T582.pyx +++ b/tests/run/charptr_comparison_T582.pyx @@ -1,4 +1,4 @@ -# ticket: 582 +# ticket: t582 cimport cython diff --git a/tests/run/cimport_cython_T505.pyx b/tests/run/cimport_cython_T505.pyx index 20d2daf3a..69229856f 100644 --- a/tests/run/cimport_cython_T505.pyx +++ b/tests/run/cimport_cython_T505.pyx @@ -1,4 +1,4 @@ -# ticket: 505 +# ticket: t505 cimport cython diff --git a/tests/run/class_attribute_init_values_T18.pyx b/tests/run/class_attribute_init_values_T18.pyx index 5e12f665f..7887853df 100644 --- a/tests/run/class_attribute_init_values_T18.pyx +++ b/tests/run/class_attribute_init_values_T18.pyx @@ -1,4 +1,4 @@ -# ticket: 18 +# ticket: t18 __doc__ = u""" >>> f = PyFoo() diff --git a/tests/run/class_func_in_control_structures_T87.pyx b/tests/run/class_func_in_control_structures_T87.pyx index 5c23ceff9..14ee440a0 100644 --- a/tests/run/class_func_in_control_structures_T87.pyx +++ b/tests/run/class_func_in_control_structures_T87.pyx @@ -1,4 +1,4 @@ -# ticket: 87 +# ticket: t87 __doc__ = u""" >>> d = Defined() diff --git a/tests/run/class_scope_del_T684.py b/tests/run/class_scope_del_T684.py index 43368f333..f52b31864 100644 --- a/tests/run/class_scope_del_T684.py +++ b/tests/run/class_scope_del_T684.py @@ -1,6 +1,6 @@ # mode:run # tag: class, scope, del -# ticket: 684 +# ticket: t684 class DelInClass(object): """ diff --git a/tests/run/classdecorators_T336.pyx b/tests/run/classdecorators_T336.pyx index c29c1cbaa..b56e08c07 100644 --- a/tests/run/classdecorators_T336.pyx +++ b/tests/run/classdecorators_T336.pyx @@ -1,4 +1,4 @@ -# ticket: 336 +# ticket: t336 __doc__ = u""" >>> print('\\n'.join(calls)) diff --git a/tests/run/closure_class_T596.pyx b/tests/run/closure_class_T596.pyx index 6a92d9f82..7808a8d9e 100644 --- a/tests/run/closure_class_T596.pyx +++ b/tests/run/closure_class_T596.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 596 +# ticket: t596 def simple(a, b): """ diff --git a/tests/run/closure_decorators_T478.pyx b/tests/run/closure_decorators_T478.pyx index e1c5f4918..1bccdcc19 100644 --- a/tests/run/closure_decorators_T478.pyx +++ b/tests/run/closure_decorators_T478.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 478 +# ticket: t478 __doc__ = """ >>> Num(13).is_prime() diff --git a/tests/run/closure_inside_cdef_T554.pyx b/tests/run/closure_inside_cdef_T554.pyx index 3a112868d..3406259b5 100644 --- a/tests/run/closure_inside_cdef_T554.pyx +++ b/tests/run/closure_inside_cdef_T554.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 554 +# ticket: t554 def call_f(x): """ diff --git a/tests/run/closure_name_mangling_T537.pyx b/tests/run/closure_name_mangling_T537.pyx index 0324109ec..148f9f1ae 100644 --- a/tests/run/closure_name_mangling_T537.pyx +++ b/tests/run/closure_name_mangling_T537.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 537 +# ticket: t537 __doc__ = u""" >>> f1 = nested1() diff --git a/tests/run/closure_names.pyx b/tests/run/closure_names.pyx index b6d253983..0ceb320d5 100644 --- a/tests/run/closure_names.pyx +++ b/tests/run/closure_names.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: gh-1797 +# ticket: 1797 def func(): diff --git a/tests/run/closures_T82.pyx b/tests/run/closures_T82.pyx index 85ce9043e..c8a228a19 100644 --- a/tests/run/closures_T82.pyx +++ b/tests/run/closures_T82.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 82 +# ticket: t82 # preparse: id # preparse: def_to_cdef diff --git a/tests/run/cmethod_inline_T474.pyx b/tests/run/cmethod_inline_T474.pyx index ddc33a62b..d09db3bf4 100644 --- a/tests/run/cmethod_inline_T474.pyx +++ b/tests/run/cmethod_inline_T474.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 474 +# ticket: t474 cimport cython diff --git a/tests/run/complex_cast_T445.pyx b/tests/run/complex_cast_T445.pyx index 62709c9c1..b4069ec9d 100644 --- a/tests/run/complex_cast_T445.pyx +++ b/tests/run/complex_cast_T445.pyx @@ -1,4 +1,4 @@ -# ticket: 445 +# ticket: t445 def complex_double_cast(double x, double complex z): """ diff --git a/tests/run/complex_coercion_sideeffects_T693.pyx b/tests/run/complex_coercion_sideeffects_T693.pyx index 92b1f94a9..18a9575dc 100644 --- a/tests/run/complex_coercion_sideeffects_T693.pyx +++ b/tests/run/complex_coercion_sideeffects_T693.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 693 +# ticket: t693 cdef double complex func(double complex x): print "hello" diff --git a/tests/run/complex_int_T446.pyx b/tests/run/complex_int_T446.pyx index a26eaa546..16e991c7c 100644 --- a/tests/run/complex_int_T446.pyx +++ b/tests/run/complex_int_T446.pyx @@ -1,4 +1,4 @@ -# ticket: 446 +# ticket: t446 import cython diff --git a/tests/run/complex_numbers_T305.pyx b/tests/run/complex_numbers_T305.pyx index 310b7233e..acbc0a5fa 100644 --- a/tests/run/complex_numbers_T305.pyx +++ b/tests/run/complex_numbers_T305.pyx @@ -1,4 +1,4 @@ -# ticket: 305 +# ticket: t305 from cpython.object cimport Py_EQ, Py_NE diff --git a/tests/run/complex_numbers_T305_long_double.pyx b/tests/run/complex_numbers_T305_long_double.pyx index 891d44271..9bc1e73fb 100644 --- a/tests/run/complex_numbers_T305_long_double.pyx +++ b/tests/run/complex_numbers_T305_long_double.pyx @@ -1,4 +1,4 @@ -# ticket: 305 +# ticket: t305 cimport cython diff --git a/tests/run/complex_numbers_c89_T398.pyx b/tests/run/complex_numbers_c89_T398.pyx index 7d680a167..546d37c31 100644 --- a/tests/run/complex_numbers_c89_T398.pyx +++ b/tests/run/complex_numbers_c89_T398.pyx @@ -1,4 +1,4 @@ -# ticket: 398 +# ticket: t398 cdef extern from "complex_numbers_c89_T398.h": pass include "complex_numbers_T305.pyx" diff --git a/tests/run/complex_numbers_c89_T398_long_double.pyx b/tests/run/complex_numbers_c89_T398_long_double.pyx index 91450e22b..9ac1607e4 100644 --- a/tests/run/complex_numbers_c89_T398_long_double.pyx +++ b/tests/run/complex_numbers_c89_T398_long_double.pyx @@ -1,4 +1,4 @@ -# ticket: 398 +# ticket: t398 cdef extern from "complex_numbers_c89_T398.h": pass include "complex_numbers_T305_long_double.pyx" diff --git a/tests/run/complex_numbers_c99_T398.pyx b/tests/run/complex_numbers_c99_T398.pyx index 762c24b02..332029cab 100644 --- a/tests/run/complex_numbers_c99_T398.pyx +++ b/tests/run/complex_numbers_c99_T398.pyx @@ -1,4 +1,4 @@ -# ticket: 398 +# ticket: t398 cdef extern from "complex_numbers_c99_T398.h": pass include "complex_numbers_T305.pyx" diff --git a/tests/run/complex_numbers_cxx_T398.pyx b/tests/run/complex_numbers_cxx_T398.pyx index 9b9b69a73..f5e535ab7 100644 --- a/tests/run/complex_numbers_cxx_T398.pyx +++ b/tests/run/complex_numbers_cxx_T398.pyx @@ -1,4 +1,4 @@ -# ticket: 398 +# ticket: t398 cdef extern from "complex_numbers_cxx_T398.h": pass include "complex_numbers_T305.pyx" diff --git a/tests/run/contains_T455.pyx b/tests/run/contains_T455.pyx index 5caed0b86..8bb087acf 100644 --- a/tests/run/contains_T455.pyx +++ b/tests/run/contains_T455.pyx @@ -1,4 +1,4 @@ -# ticket: 455 +# ticket: t455 def in_sequence(x, seq): """ diff --git a/tests/run/cpdef_enums.pyx b/tests/run/cpdef_enums.pyx index 3e342bbb3..d93e19582 100644 --- a/tests/run/cpdef_enums.pyx +++ b/tests/run/cpdef_enums.pyx @@ -39,10 +39,10 @@ True Traceback (most recent call last): NameError: ...name 'RANK_3' is not defined ->>> set(PyxEnum) == set([TWO, THREE, FIVE]) +>>> set(PyxEnum) == {TWO, THREE, FIVE} True ->>> str(PyxEnum.TWO) -'PyxEnum.TWO' +>>> str(PyxEnum.TWO).split(".")[-1] # Py3.10 changed the output here +'TWO' >>> PyxEnum.TWO + PyxEnum.THREE == PyxEnum.FIVE True >>> PyxEnum(2) is PyxEnum["TWO"] is PyxEnum.TWO diff --git a/tests/run/cpdef_method_override.pyx b/tests/run/cpdef_method_override.pyx index 97aafe562..aadef67a6 100644 --- a/tests/run/cpdef_method_override.pyx +++ b/tests/run/cpdef_method_override.pyx @@ -1,6 +1,6 @@ # mode: run # tag: cpdef -# ticket: gh-1771 +# ticket: 1771 def _call_method(cls): obj = cls() diff --git a/tests/run/cpdef_temps_T411.pyx b/tests/run/cpdef_temps_T411.pyx index 061d9ef13..66f08331d 100644 --- a/tests/run/cpdef_temps_T411.pyx +++ b/tests/run/cpdef_temps_T411.pyx @@ -1,4 +1,4 @@ -# ticket: 411 +# ticket: t411 cdef class A: """ diff --git a/tests/run/crashT245.pyx b/tests/run/crashT245.pyx index 862deca37..0ef9cb447 100644 --- a/tests/run/crashT245.pyx +++ b/tests/run/crashT245.pyx @@ -1,4 +1,4 @@ -# ticket: 245 +# ticket: t245 cimport crashT245_pxd diff --git a/tests/run/cstringmul.pyx b/tests/run/cstringmul.pyx index 1c3b79302..1932e8d61 100644 --- a/tests/run/cstringmul.pyx +++ b/tests/run/cstringmul.pyx @@ -31,3 +31,15 @@ grail_long = 700 * "tomato" uspam = u"eggs" * 4 ugrail = 7 * u"tomato" ugrail_long = 700 * u"tomato" + +cimport cython + +@cython.test_assert_path_exists("//StringNode[@value = '-----']") +@cython.test_assert_path_exists("//StringNode[@unicode_value = '-----']") +def gh3951(): + """ + Bug occurs with language_level=2 and affects StringNode.value + >>> gh3951() + '-----' + """ + return "-"*5 diff --git a/tests/run/ctypedef_int_types_T333.pyx b/tests/run/ctypedef_int_types_T333.pyx index 3f1a99f69..b0a47d484 100644 --- a/tests/run/ctypedef_int_types_T333.pyx +++ b/tests/run/ctypedef_int_types_T333.pyx @@ -1,4 +1,4 @@ -# ticket: 333 +# ticket: t333 #cython: autotestdict=True # ------------------------------------------------------------------- diff --git a/tests/run/decorators_T593.pyx b/tests/run/decorators_T593.pyx index d63bcb704..824e5fb2a 100644 --- a/tests/run/decorators_T593.pyx +++ b/tests/run/decorators_T593.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 593 +# ticket: t593 # tag: property, decorator """ diff --git a/tests/run/decorators_py_T593.py b/tests/run/decorators_py_T593.py index 98cffa79f..339e575de 100644 --- a/tests/run/decorators_py_T593.py +++ b/tests/run/decorators_py_T593.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 593 +# ticket: t593 # tag: property, decorator """ diff --git a/tests/run/default_args_T674.py b/tests/run/default_args_T674.py index 1ca9381bc..7acf84048 100644 --- a/tests/run/default_args_T674.py +++ b/tests/run/default_args_T674.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 674 +# ticket: t674 def test_inner(a): """ diff --git a/tests/run/dict.pyx b/tests/run/dict.pyx index d51cef7da..691b78635 100644 --- a/tests/run/dict.pyx +++ b/tests/run/dict.pyx @@ -117,3 +117,22 @@ def item_creation_sideeffect(L, sideeffect, unhashable): [2, 4, 5] """ return {1:2, sideeffect(2): 3, 3: 4, unhashable(4): 5, sideeffect(5): 6} + + +def dict_unpacking_not_for_arg_create_a_copy(): + """ + >>> dict_unpacking_not_for_arg_create_a_copy() + [('a', 'modified'), ('b', 'original')] + [('a', 'original'), ('b', 'original')] + """ + data = {'a': 'original', 'b': 'original'} + + func = lambda: {**data} + + call_once = func() + call_once['a'] = 'modified' + + call_twice = func() + + print(sorted(call_once.items())) + print(sorted(call_twice.items())) diff --git a/tests/run/division_T384.pyx b/tests/run/division_T384.pyx index 301dc3a61..5da5475fd 100644 --- a/tests/run/division_T384.pyx +++ b/tests/run/division_T384.pyx @@ -1,4 +1,4 @@ -# ticket: 384 +# ticket: t384 """ >>> test(3) diff --git a/tests/run/duplicate_keyword_in_call.py b/tests/run/duplicate_keyword_in_call.py index e3d041d76..aba5772c3 100644 --- a/tests/run/duplicate_keyword_in_call.py +++ b/tests/run/duplicate_keyword_in_call.py @@ -1,6 +1,6 @@ # mode: run # tag: kwargs, call -# ticket: 717 +# ticket: t717 def f(**kwargs): return sorted(kwargs.items()) diff --git a/tests/run/dynamic_args.pyx b/tests/run/dynamic_args.pyx index 900671028..1205b06b0 100644 --- a/tests/run/dynamic_args.pyx +++ b/tests/run/dynamic_args.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 674 +# ticket: t674 cdef class Foo: cdef str name diff --git a/tests/run/ellipsis_T488.pyx b/tests/run/ellipsis_T488.pyx index e7892dbc9..ab04b317c 100644 --- a/tests/run/ellipsis_T488.pyx +++ b/tests/run/ellipsis_T488.pyx @@ -1,4 +1,4 @@ -# ticket: 488 +# ticket: t488 """ >>> test() diff --git a/tests/run/empty_for_loop_T208.pyx b/tests/run/empty_for_loop_T208.pyx index 88a134f25..70b3be512 100644 --- a/tests/run/empty_for_loop_T208.pyx +++ b/tests/run/empty_for_loop_T208.pyx @@ -1,4 +1,4 @@ -# ticket: 208 +# ticket: t208 def go_py_empty(): """ diff --git a/tests/run/enumerate_T316.pyx b/tests/run/enumerate_T316.pyx index f148e1a22..89755b76b 100644 --- a/tests/run/enumerate_T316.pyx +++ b/tests/run/enumerate_T316.pyx @@ -1,4 +1,4 @@ -# ticket: 316 +# ticket: t316 cimport cython diff --git a/tests/run/ext_instance_type_T232.pyx b/tests/run/ext_instance_type_T232.pyx index 9538a9b96..c089b1603 100644 --- a/tests/run/ext_instance_type_T232.pyx +++ b/tests/run/ext_instance_type_T232.pyx @@ -1,4 +1,4 @@ -# ticket: 232 +# ticket: t232 cdef class MyExt: cdef object attr diff --git a/tests/run/extended_unpacking_T235.pyx b/tests/run/extended_unpacking_T235.pyx index 2388e2587..8d38120a1 100644 --- a/tests/run/extended_unpacking_T235.pyx +++ b/tests/run/extended_unpacking_T235.pyx @@ -1,4 +1,4 @@ -# ticket: 235 +# ticket: t235 __doc__ = u""" >>> class FakeSeq(object): diff --git a/tests/run/extended_unpacking_T409.pyx b/tests/run/extended_unpacking_T409.pyx index 1198a15f3..7c3b71d51 100644 --- a/tests/run/extended_unpacking_T409.pyx +++ b/tests/run/extended_unpacking_T409.pyx @@ -1,4 +1,4 @@ -# ticket: 409 +# ticket: t409 def simple(): """ diff --git a/tests/run/extern_builtins_T258.pyx b/tests/run/extern_builtins_T258.pyx index d732931dd..1c6ea9843 100644 --- a/tests/run/extern_builtins_T258.pyx +++ b/tests/run/extern_builtins_T258.pyx @@ -1,4 +1,4 @@ -# ticket: 258 +# ticket: t258 cdef extern from "Python.h": diff --git a/tests/run/file_encoding_T740.py b/tests/run/file_encoding_T740.py index f61973353..a71b04be9 100644 --- a/tests/run/file_encoding_T740.py +++ b/tests/run/file_encoding_T740.py @@ -1,6 +1,6 @@ # encoding: koi8-r # mode: run -# ticket: 740 +# ticket: t740 """ >>> wtf 'wtf' diff --git a/tests/run/final_method_T586.pyx b/tests/run/final_method_T586.pyx index 8fa1ba25c..f50bb8aa8 100644 --- a/tests/run/final_method_T586.pyx +++ b/tests/run/final_method_T586.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 568 +# ticket: t568 cimport cython diff --git a/tests/run/float_floor_division_T260.pyx b/tests/run/float_floor_division_T260.pyx index 66f6f83f7..58d13a157 100644 --- a/tests/run/float_floor_division_T260.pyx +++ b/tests/run/float_floor_division_T260.pyx @@ -1,4 +1,4 @@ -# ticket: 260 +# ticket: t260 def floor_div_float(double a, double b): """ diff --git a/tests/run/float_len_T480.pyx b/tests/run/float_len_T480.pyx index efb456c54..4f623030a 100644 --- a/tests/run/float_len_T480.pyx +++ b/tests/run/float_len_T480.pyx @@ -1,4 +1,4 @@ -# ticket: 480 +# ticket: t480 def f(x): return x diff --git a/tests/run/for_from_float_T254.pyx b/tests/run/for_from_float_T254.pyx index 0ea153a9c..bf07f42b6 100644 --- a/tests/run/for_from_float_T254.pyx +++ b/tests/run/for_from_float_T254.pyx @@ -1,4 +1,4 @@ -# ticket: 254 +# ticket: t254 def double_target(a, b): """ diff --git a/tests/run/for_from_pyvar_loop_T601.pyx b/tests/run/for_from_pyvar_loop_T601.pyx index 2d5890d9b..949fcef06 100644 --- a/tests/run/for_from_pyvar_loop_T601.pyx +++ b/tests/run/for_from_pyvar_loop_T601.pyx @@ -1,4 +1,4 @@ -# ticket: 601 +# ticket: t601 cdef unsigned long size2(): return 3 diff --git a/tests/run/for_in_break_continue_T533.pyx b/tests/run/for_in_break_continue_T533.pyx index 0baa9fa49..32f646aaf 100644 --- a/tests/run/for_in_break_continue_T533.pyx +++ b/tests/run/for_in_break_continue_T533.pyx @@ -1,4 +1,4 @@ -# ticket: 533 +# ticket: t533 def for_in(): """ diff --git a/tests/run/for_in_range_T372.pyx b/tests/run/for_in_range_T372.pyx index bff686295..11ef4b592 100644 --- a/tests/run/for_in_range_T372.pyx +++ b/tests/run/for_in_range_T372.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 372 +# ticket: t372 cimport cython diff --git a/tests/run/funcexc_iter_T228.pyx b/tests/run/funcexc_iter_T228.pyx index 0c5bde250..4b81166f6 100644 --- a/tests/run/funcexc_iter_T228.pyx +++ b/tests/run/funcexc_iter_T228.pyx @@ -1,4 +1,4 @@ -# ticket: 228 +# ticket: t228 __doc__ = u""" >>> def py_iterator(): diff --git a/tests/run/function_as_method_T494.pyx b/tests/run/function_as_method_T494.pyx index 0c0307ea2..92deafc6d 100644 --- a/tests/run/function_as_method_T494.pyx +++ b/tests/run/function_as_method_T494.pyx @@ -1,4 +1,4 @@ -# ticket: 494 +# ticket: t494 # cython: binding=True __doc__ = """ diff --git a/tests/run/function_as_method_py_T494.py b/tests/run/function_as_method_py_T494.py index d94813784..5317d8848 100644 --- a/tests/run/function_as_method_py_T494.py +++ b/tests/run/function_as_method_py_T494.py @@ -1,4 +1,4 @@ -# ticket: 494 +# ticket: t494 __doc__ = """ >>> A.foo = foo diff --git a/tests/run/function_binding_T494.pyx b/tests/run/function_binding_T494.pyx index b41221e2c..86c64c9c0 100644 --- a/tests/run/function_binding_T494.pyx +++ b/tests/run/function_binding_T494.pyx @@ -1,4 +1,4 @@ -# ticket: 494 +# ticket: t494 cimport cython diff --git a/tests/run/fused_types.pyx b/tests/run/fused_types.pyx index b71e5c7c1..3a0009bdd 100644 --- a/tests/run/fused_types.pyx +++ b/tests/run/fused_types.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 1772 +# ticket: t1772 cimport cython from cython.view cimport array diff --git a/tests/run/generator_expressions_and_locals.pyx b/tests/run/generator_expressions_and_locals.pyx index 7a87164ff..a239f9b29 100644 --- a/tests/run/generator_expressions_and_locals.pyx +++ b/tests/run/generator_expressions_and_locals.pyx @@ -1,6 +1,6 @@ # mode: run # tag: genexpr, locals -# ticket: 715 +# ticket: t715 def genexpr_not_in_locals(): """ diff --git a/tests/run/generators_GH1731.pyx b/tests/run/generators_GH1731.pyx index 99cae90ca..77b0877f2 100644 --- a/tests/run/generators_GH1731.pyx +++ b/tests/run/generators_GH1731.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: gh1731 +# ticket: 1731 def cygen(): diff --git a/tests/run/genexpr_T491.pyx b/tests/run/genexpr_T491.pyx index 7fa6c1754..7640b3518 100644 --- a/tests/run/genexpr_T491.pyx +++ b/tests/run/genexpr_T491.pyx @@ -1,4 +1,4 @@ -# ticket: 491 +# ticket: t491 def test_genexpr(): """ diff --git a/tests/run/genexpr_T715.pyx b/tests/run/genexpr_T715.pyx index 2c6f5d6c8..028a93128 100644 --- a/tests/run/genexpr_T715.pyx +++ b/tests/run/genexpr_T715.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 715 +# ticket: t715 # tag: genexpr, comprehension def t715(*items): diff --git a/tests/run/genexpr_iterable_lookup_T600.pyx b/tests/run/genexpr_iterable_lookup_T600.pyx index 220098a1f..945652717 100644 --- a/tests/run/genexpr_iterable_lookup_T600.pyx +++ b/tests/run/genexpr_iterable_lookup_T600.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 600 +# ticket: t600 # tag: genexpr # cython: language_level=3 diff --git a/tests/run/hash_T326.pyx b/tests/run/hash_T326.pyx index 11184837f..bc9566879 100644 --- a/tests/run/hash_T326.pyx +++ b/tests/run/hash_T326.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 326 +# ticket: t326 # tag: hash diff --git a/tests/run/ifelseexpr_T267.pyx b/tests/run/ifelseexpr_T267.pyx index 24dabc442..973c1979a 100644 --- a/tests/run/ifelseexpr_T267.pyx +++ b/tests/run/ifelseexpr_T267.pyx @@ -1,6 +1,6 @@ # mode: run # tag: condexpr -# ticket: 267 +# ticket: t267 cimport cython diff --git a/tests/run/import_error_T734.py b/tests/run/import_error_T734.py index 4138fba1c..efcd79944 100644 --- a/tests/run/import_error_T734.py +++ b/tests/run/import_error_T734.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 734 +# ticket: t734 def test_import_error(): """ diff --git a/tests/run/in_list_with_side_effects_T544.pyx b/tests/run/in_list_with_side_effects_T544.pyx index 3bb3954c3..4a75f206a 100644 --- a/tests/run/in_list_with_side_effects_T544.pyx +++ b/tests/run/in_list_with_side_effects_T544.pyx @@ -1,4 +1,4 @@ -# ticket: 544 +# ticket: t544 def count(i=[0]): i[0] += 1 diff --git a/tests/run/int_float_builtins_as_casts_T400.pyx b/tests/run/int_float_builtins_as_casts_T400.pyx index 6d02eff36..99d1796ed 100644 --- a/tests/run/int_float_builtins_as_casts_T400.pyx +++ b/tests/run/int_float_builtins_as_casts_T400.pyx @@ -1,4 +1,4 @@ -# ticket: 400 +# ticket: t400 cimport cython diff --git a/tests/run/int_float_builtins_as_casts_T400_long_double.pyx b/tests/run/int_float_builtins_as_casts_T400_long_double.pyx index d7e61f43b..776434ee8 100644 --- a/tests/run/int_float_builtins_as_casts_T400_long_double.pyx +++ b/tests/run/int_float_builtins_as_casts_T400_long_double.pyx @@ -1,4 +1,4 @@ -# ticket: 400 +# ticket: t400 cimport cython diff --git a/tests/run/intern_T431.pyx b/tests/run/intern_T431.pyx index 5851d9741..6b7ef0516 100644 --- a/tests/run/intern_T431.pyx +++ b/tests/run/intern_T431.pyx @@ -1,4 +1,4 @@ -# ticket: 431 +# ticket: t431 __doc__ = u""" >>> s == s_interned diff --git a/tests/run/ipow_crash_T562.pyx b/tests/run/ipow_crash_T562.pyx index 6fea958b5..7b074ea5d 100644 --- a/tests/run/ipow_crash_T562.pyx +++ b/tests/run/ipow_crash_T562.pyx @@ -1,4 +1,4 @@ -# ticket: 562 +# ticket: t562 class IPOW: """ diff --git a/tests/run/kwargs_passthrough.pyx b/tests/run/kwargs_passthrough.pyx index 704638a55..c09b6cba4 100644 --- a/tests/run/kwargs_passthrough.pyx +++ b/tests/run/kwargs_passthrough.pyx @@ -1,7 +1,6 @@ -cimport cython +import cython - -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def wrap_passthrough(f): """ >>> def f(a=1): return a @@ -80,7 +79,7 @@ def wrap_passthrough_more(f): return wrapper -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def wrap_passthrough2(f): """ >>> def f(a=1): return a @@ -99,7 +98,7 @@ def wrap_passthrough2(f): return wrapper -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def wrap_modify(f): """ >>> def f(a=1, test=2): @@ -123,7 +122,7 @@ def wrap_modify(f): return wrapper -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def wrap_modify_mix(f): """ >>> def f(a=1, test=2): @@ -139,6 +138,18 @@ def wrap_modify_mix(f): >>> wrapped(a=2, test=3) CALLED (2, 1) + + >>> def py_modify(**kwargs): + ... print(sorted(kwargs.items())) + ... kwargs['new'] = len(kwargs) + ... return kwargs + + >>> wrapped_modify = wrap_modify_mix(py_modify) + >>> sorted(wrapped_modify(a=1).items()) + CALLED + [('a', 1)] + [('a', 1), ('test', 1)] + [('a', 1), ('new', 2), ('test', 1)] """ def wrapper(*args, **kwargs): print("CALLED") @@ -175,7 +186,21 @@ def wrap_modify_func(f): return wrapper -@cython.test_assert_path_exists('//MergedDictNode') +def modify_in_function(): + """ + >>> modify_in_function() + {'foo': 'bar'} + {'foo': 'bar'} + """ + def inner(**kwds): + kwds['foo'] = 'modified' + d = {'foo': 'bar'} + print(d) + inner(**d) + print(d) + + +#@cython.test_assert_path_exists('//MergedDictNode') def wrap_modify_func_mix(f): """ >>> def f(a=1, test=2): @@ -203,12 +228,11 @@ def wrap_modify_func_mix(f): return wrapper -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def wrap_reassign(f): """ >>> def f(a=1, test=2): ... return a, test - >>> wrapped = wrap_reassign(f) >>> wrapped(1) CALLED @@ -227,7 +251,7 @@ def wrap_reassign(f): return wrapper -@cython.test_fail_if_path_exists('//MergedDictNode') +#@cython.test_fail_if_path_exists('//MergedDictNode') def kwargs_metaclass(**kwargs): """ >>> K = kwargs_metaclass() diff --git a/tests/run/lambda_T195.pyx b/tests/run/lambda_T195.pyx index fdbde9982..bfae08fea 100644 --- a/tests/run/lambda_T195.pyx +++ b/tests/run/lambda_T195.pyx @@ -1,6 +1,6 @@ # mode: run # tag: lambda -# ticket: 195 +# ticket: t195 __doc__ = u""" #>>> py_identity = lambda x:x diff --git a/tests/run/lambda_T723.pyx b/tests/run/lambda_T723.pyx index e746a3f58..39ae66851 100644 --- a/tests/run/lambda_T723.pyx +++ b/tests/run/lambda_T723.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 723 +# ticket: t723 # tag: lambda def t723(a): diff --git a/tests/run/lambda_class_T605.pyx b/tests/run/lambda_class_T605.pyx index 82e1ff8a7..2efe77e7c 100644 --- a/tests/run/lambda_class_T605.pyx +++ b/tests/run/lambda_class_T605.pyx @@ -1,6 +1,6 @@ # mode: run # tag: lambda -# ticket: 605 +# ticket: t605 cdef int cdef_CONST = 123 CONST = 456 diff --git a/tests/run/lambda_module_T603.pyx b/tests/run/lambda_module_T603.pyx index 245f86937..c92fce5df 100644 --- a/tests/run/lambda_module_T603.pyx +++ b/tests/run/lambda_module_T603.pyx @@ -1,6 +1,6 @@ # mode: run # tag: lambda -# ticket: 603 +# ticket: t603 # Module scope lambda functions diff --git a/tests/run/large_consts_T237.pyx b/tests/run/large_consts_T237.pyx index f11a24541..7c448401f 100644 --- a/tests/run/large_consts_T237.pyx +++ b/tests/run/large_consts_T237.pyx @@ -1,4 +1,4 @@ -# ticket: 237 +# ticket: t237 #def add_large_c(): # cdef unsigned long long val = 2**30 + 2**30 # return val diff --git a/tests/run/letnode_T766.pyx b/tests/run/letnode_T766.pyx index 337808ee4..0f2d53e0b 100644 --- a/tests/run/letnode_T766.pyx +++ b/tests/run/letnode_T766.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 766 +# ticket: t766 # tag: letnode def test_letnode_range(int n): diff --git a/tests/run/list_comp_in_closure_T598.pyx b/tests/run/list_comp_in_closure_T598.pyx index 3f418add1..45b572ac0 100644 --- a/tests/run/list_comp_in_closure_T598.pyx +++ b/tests/run/list_comp_in_closure_T598.pyx @@ -1,6 +1,6 @@ # mode: run # tag: closures -# ticket: 598 +# ticket: t598 # cython: language_level=3 def list_comp_in_closure(): diff --git a/tests/run/locals_T732.pyx b/tests/run/locals_T732.pyx index 6b3307523..6ce8c7447 100644 --- a/tests/run/locals_T732.pyx +++ b/tests/run/locals_T732.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 731 +# ticket: t731 # tag: locals, vars, dir cimport cython diff --git a/tests/run/locals_expressions_T430.pyx b/tests/run/locals_expressions_T430.pyx index a0f8a0d62..a0e9dff3e 100644 --- a/tests/run/locals_expressions_T430.pyx +++ b/tests/run/locals_expressions_T430.pyx @@ -1,4 +1,4 @@ -# ticket: 430 +# ticket: t430 __doc__ = u""" >>> sorted( get_locals(1,2,3, k=5) .items()) diff --git a/tests/run/locals_rebind_T429.pyx b/tests/run/locals_rebind_T429.pyx index 9b3f06a5a..e84a13947 100644 --- a/tests/run/locals_rebind_T429.pyx +++ b/tests/run/locals_rebind_T429.pyx @@ -1,4 +1,4 @@ -# ticket: 429 +# ticket: t429 __doc__ = u""" >>> sorted( get_locals(1,2,3, k=5) .items()) diff --git a/tests/run/method_module_name_T422.pyx b/tests/run/method_module_name_T422.pyx index fbefa2144..731cd1b30 100644 --- a/tests/run/method_module_name_T422.pyx +++ b/tests/run/method_module_name_T422.pyx @@ -1,4 +1,4 @@ -# ticket: 422 +# ticket: t422 """ >>> Foo.incr.__module__ is not None diff --git a/tests/run/methodmangling_T5.py b/tests/run/methodmangling_T5.py index 4d2cfe1d8..9e2b7c63a 100644 --- a/tests/run/methodmangling_T5.py +++ b/tests/run/methodmangling_T5.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 5 +# ticket: t5 # A small number of extra tests checking: # 1) this works correctly with pure-Python-mode decorators - methodmangling_pure.py. diff --git a/tests/run/non_dict_kwargs_T470.pyx b/tests/run/non_dict_kwargs_T470.pyx index b60d56210..be6f8c67b 100644 --- a/tests/run/non_dict_kwargs_T470.pyx +++ b/tests/run/non_dict_kwargs_T470.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 470 +# ticket: t470 def func(**kwargs): diff --git a/tests/run/numpy_ValueError_T172.pyx b/tests/run/numpy_ValueError_T172.pyx index 66558eefc..233048ce7 100644 --- a/tests/run/numpy_ValueError_T172.pyx +++ b/tests/run/numpy_ValueError_T172.pyx @@ -1,4 +1,4 @@ -# ticket: 172 +# ticket: t172 # tag: numpy __doc__ = u""" diff --git a/tests/run/numpy_bufacc_T155.pyx b/tests/run/numpy_bufacc_T155.pyx index 17a8525fd..2c637ebc4 100644 --- a/tests/run/numpy_bufacc_T155.pyx +++ b/tests/run/numpy_bufacc_T155.pyx @@ -1,4 +1,4 @@ -# ticket: 155 +# ticket: t155 # tag: numpy """ diff --git a/tests/run/numpy_test.pyx b/tests/run/numpy_test.pyx index e81547c32..d2718a463 100644 --- a/tests/run/numpy_test.pyx +++ b/tests/run/numpy_test.pyx @@ -10,16 +10,10 @@ def little_endian(): cdef int endian_detector = 1 return (<char*>&endian_detector)[0] != 0 -__test__ = {} def testcase(f): - __test__[f.__name__] = f.__doc__ - return f - -def testcase_have_buffer_interface(f): - major, minor, *rest = np.__version__.split('.') - if (int(major), int(minor)) >= (1, 5): - __test__[f.__name__] = f.__doc__ + # testcase decorator now does nothing (following changes to doctest) + # but is a useful indicator of what functions are designed as tests return f if little_endian(): @@ -180,7 +174,7 @@ try: ('a', np.dtype('i,i')),\ ('b', np.dtype('i,i'))\ ])))) # doctest: +NORMALIZE_WHITESPACE - array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))], + array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))], dtype=[('a', [('f0', '!i4'), ('f1', '!i4')]), ('b', [('f0', '!i4'), ('f1', '!i4')])]) >>> print(test_nested_dtypes(np.zeros((3,), dtype=np.dtype([\ @@ -233,7 +227,7 @@ try: 8,16 >>> test_point_record() # doctest: +NORMALIZE_WHITESPACE - array([(0., 0.), (1., -1.), (2., -2.)], + array([(0., 0.), (1., -1.), (2., -2.)], dtype=[('x', '!f8'), ('y', '!f8')]) """ @@ -267,8 +261,6 @@ try: except: __doc__ = u"" -__test__[__name__] = __doc__ - def assert_dtype_sizes(): assert sizeof(np.int8_t) == 1 @@ -679,7 +671,6 @@ def get_Foo_array(): data[5].b = 9.0 return np.asarray(<Foo[:]>data).copy() -@testcase_have_buffer_interface def test_fused_ndarray(fused_ndarray a): """ >>> import cython @@ -728,9 +719,6 @@ cpdef test_fused_cpdef_ndarray(fused_ndarray a): else: print b[5] -testcase_have_buffer_interface(test_fused_cpdef_ndarray) - -@testcase_have_buffer_interface def test_fused_cpdef_ndarray_cdef_call(): """ >>> test_fused_cpdef_ndarray_cdef_call() diff --git a/tests/run/packedstruct_T290.pyx b/tests/run/packedstruct_T290.pyx index 203008ca7..d9381567e 100644 --- a/tests/run/packedstruct_T290.pyx +++ b/tests/run/packedstruct_T290.pyx @@ -1,4 +1,4 @@ -# ticket: 290 +# ticket: t290 """ >>> f() diff --git a/tests/run/parallel_swap_assign_T425.pyx b/tests/run/parallel_swap_assign_T425.pyx index fb7d1ac29..b6e7e233d 100644 --- a/tests/run/parallel_swap_assign_T425.pyx +++ b/tests/run/parallel_swap_assign_T425.pyx @@ -1,4 +1,4 @@ -# ticket: 425 +# ticket: t425 cimport cython diff --git a/tests/run/property_decorator_T593.py b/tests/run/property_decorator_T593.py index 45ddb57a8..d34db8951 100644 --- a/tests/run/property_decorator_T593.py +++ b/tests/run/property_decorator_T593.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 593 +# ticket: t593 # tag: property, decorator my_property = property diff --git a/tests/run/ptr_warning_T714.pyx b/tests/run/ptr_warning_T714.pyx index 3ec8b5b12..3bd330525 100644 --- a/tests/run/ptr_warning_T714.pyx +++ b/tests/run/ptr_warning_T714.pyx @@ -1,6 +1,6 @@ # mode: run # tag: werror -# ticket: 714 +# ticket: t714 def test_ptr(): """ diff --git a/tests/run/pure_cdef_class_property_decorator_T264.pxd b/tests/run/pure_cdef_class_property_decorator_T264.pxd index 4c1d879cf..e5e616a00 100644 --- a/tests/run/pure_cdef_class_property_decorator_T264.pxd +++ b/tests/run/pure_cdef_class_property_decorator_T264.pxd @@ -1,5 +1,5 @@ # mode: run -# ticket: 264 +# ticket: t264 # tag: property, decorator cdef class Prop: diff --git a/tests/run/pure_cdef_class_property_decorator_T264.py b/tests/run/pure_cdef_class_property_decorator_T264.py index 70f299b4f..8ca2fc7b2 100644 --- a/tests/run/pure_cdef_class_property_decorator_T264.py +++ b/tests/run/pure_cdef_class_property_decorator_T264.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 264 +# ticket: t264 # tag: property, decorator class Prop(object): diff --git a/tests/run/pxd_argument_names.srctree b/tests/run/pxd_argument_names.srctree index 885643609..94262ef92 100644 --- a/tests/run/pxd_argument_names.srctree +++ b/tests/run/pxd_argument_names.srctree @@ -1,5 +1,5 @@ # mode: run -# ticket: gh1888 +# ticket: 1888 PYTHON setup.py build_ext --inplace PYTHON -c "import a; a.test()" diff --git a/tests/run/pyclass_scope_T671.py b/tests/run/pyclass_scope_T671.py index 911268e22..00a10de11 100644 --- a/tests/run/pyclass_scope_T671.py +++ b/tests/run/pyclass_scope_T671.py @@ -1,5 +1,5 @@ # mode: run -# ticket: 671 +# ticket: t671 A = 1234 diff --git a/tests/run/pyfunction_redefine_T489.pyx b/tests/run/pyfunction_redefine_T489.pyx index cf393407f..5931ff1b6 100644 --- a/tests/run/pyfunction_redefine_T489.pyx +++ b/tests/run/pyfunction_redefine_T489.pyx @@ -1,4 +1,4 @@ -# ticket: 489 +# ticket: t489 """ >>> xxx diff --git a/tests/run/pyobjcast_T313.pyx b/tests/run/pyobjcast_T313.pyx index fb4ef80a0..0e5fc7e8e 100644 --- a/tests/run/pyobjcast_T313.pyx +++ b/tests/run/pyobjcast_T313.pyx @@ -1,4 +1,4 @@ -# ticket: 313 +# ticket: t313 # Ensure casting still works to void* """ diff --git a/tests/run/raise_memory_error_T650.pyx b/tests/run/raise_memory_error_T650.pyx index 76b1ef4ab..8bced08e0 100644 --- a/tests/run/raise_memory_error_T650.pyx +++ b/tests/run/raise_memory_error_T650.pyx @@ -1,4 +1,4 @@ -# ticket: 650 +# ticket: t650 cimport cython diff --git a/tests/run/range_optimisation_T203.pyx b/tests/run/range_optimisation_T203.pyx index 880d8952d..bf8c0c978 100644 --- a/tests/run/range_optimisation_T203.pyx +++ b/tests/run/range_optimisation_T203.pyx @@ -1,4 +1,4 @@ -# ticket: 203 +# ticket: t203 cdef int get_bound(int m): print u"get_bound(%s)"%m diff --git a/tests/run/self_in_ext_type_closure.pyx b/tests/run/self_in_ext_type_closure.pyx index efb116659..ae45cce76 100644 --- a/tests/run/self_in_ext_type_closure.pyx +++ b/tests/run/self_in_ext_type_closure.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 742 +# ticket: t742 import cython diff --git a/tests/run/short_circuit_T404.pyx b/tests/run/short_circuit_T404.pyx index 09affaf7a..dbb24820e 100644 --- a/tests/run/short_circuit_T404.pyx +++ b/tests/run/short_circuit_T404.pyx @@ -1,4 +1,4 @@ -# ticket: 404 +# ticket: t404 cdef long foo(long x): print "foo(%s)" % x diff --git a/tests/run/special_methods_T561.pyx b/tests/run/special_methods_T561.pyx index 350d452f4..d585f35d0 100644 --- a/tests/run/special_methods_T561.pyx +++ b/tests/run/special_methods_T561.pyx @@ -1,6 +1,6 @@ # mode: run -# ticket: 561 -# ticket: 3 +# ticket: tt561 +# ticket: tt3 # The patch in #561 changes code generation for most special methods # to remove the Cython-generated wrapper and let PyType_Ready() diff --git a/tests/run/special_methods_T561_py2.pyx b/tests/run/special_methods_T561_py2.pyx index 285f820f6..9781376b3 100644 --- a/tests/run/special_methods_T561_py2.pyx +++ b/tests/run/special_methods_T561_py2.pyx @@ -1,4 +1,4 @@ -# ticket: 561 +# ticket: t561 # tag: py2 # This file tests the behavior of special methods under Python 2 # after #561. (Only methods whose behavior differs between Python 2 and 3 diff --git a/tests/run/special_methods_T561_py3.pyx b/tests/run/special_methods_T561_py3.pyx index 932002254..0a5f53547 100644 --- a/tests/run/special_methods_T561_py3.pyx +++ b/tests/run/special_methods_T561_py3.pyx @@ -1,4 +1,4 @@ -# ticket: 561 +# ticket: t561 # tag: py3 # This file tests the behavior of special methods under Python 3 # after #561. (Only methods whose behavior differs between Python 2 and 3 diff --git a/tests/run/ssize_t_T399.pyx b/tests/run/ssize_t_T399.pyx index 4a8f65d68..265a3c924 100644 --- a/tests/run/ssize_t_T399.pyx +++ b/tests/run/ssize_t_T399.pyx @@ -1,4 +1,4 @@ -# ticket: 399 +# ticket: t399 __doc__ = u""" >>> test(-2) diff --git a/tests/run/starred_target_T664.pyx b/tests/run/starred_target_T664.pyx index 0d291c648..5a88d5ab2 100644 --- a/tests/run/starred_target_T664.pyx +++ b/tests/run/starred_target_T664.pyx @@ -1,4 +1,4 @@ -# ticket: 664 +# ticket: t664 def assign(): """ diff --git a/tests/run/str_char_coercion_T412.pyx b/tests/run/str_char_coercion_T412.pyx index 6a470e2b7..c1c0ba709 100644 --- a/tests/run/str_char_coercion_T412.pyx +++ b/tests/run/str_char_coercion_T412.pyx @@ -1,4 +1,4 @@ -# ticket: 412 +# ticket: t412 cdef int i = 'x' cdef char c = 'x' diff --git a/tests/run/temp_alloc_T409.pyx b/tests/run/temp_alloc_T409.pyx index 383e1ef6f..425b7064b 100644 --- a/tests/run/temp_alloc_T409.pyx +++ b/tests/run/temp_alloc_T409.pyx @@ -1,4 +1,4 @@ -# ticket: 409 +# ticket: t409 # Extracted from sage/plot/plot3d/index_face_set.pyx:502 # Turns out to be a bug in implementation of PEP 3132 (Extended Iterable Unpacking) diff --git a/tests/run/temp_sideeffects_T654.pyx b/tests/run/temp_sideeffects_T654.pyx index 8a00f7e5b..fe8f03fee 100644 --- a/tests/run/temp_sideeffects_T654.pyx +++ b/tests/run/temp_sideeffects_T654.pyx @@ -1,4 +1,4 @@ -# ticket: 654 +# ticket: t654 # function call arguments diff --git a/tests/run/test_unicode.pyx b/tests/run/test_unicode.pyx index 742103a36..2386b5124 100644 --- a/tests/run/test_unicode.pyx +++ b/tests/run/test_unicode.pyx @@ -1469,19 +1469,19 @@ class UnicodeTest(CommonTest, class Str(str, enum.Enum): ABC = 'abc' # Testing Unicode formatting strings... - self.assertEqual("%s, %s" % (Str.ABC, Str.ABC), - 'Str.ABC, Str.ABC') - self.assertEqual("%s, %s, %d, %i, %u, %f, %5.2f" % + self.assertEqual(("%s, %s" % (Str.ABC, Str.ABC)).replace("Str.", ""), + 'ABC, ABC') + self.assertEqual(("%s, %s, %d, %i, %u, %f, %5.2f" % (Str.ABC, Str.ABC, Int.IDES, Int.IDES, Int.IDES, - Float.PI, Float.PI), - 'Str.ABC, Str.ABC, 15, 15, 15, 3.141593, 3.14') + Float.PI, Float.PI)).replace("Str.", ""), + 'ABC, ABC, 15, 15, 15, 3.141593, 3.14') # formatting jobs delegated from the string implementation: - self.assertEqual('...%(foo)s...' % {'foo':Str.ABC}, - '...Str.ABC...') - self.assertEqual('...%(foo)s...' % {'foo':Int.IDES}, - '...Int.IDES...') + self.assertEqual(('...%(foo)s...' % {'foo':Str.ABC}).replace("Str.", ""), + '...ABC...') + self.assertEqual(('...%(foo)s...' % {'foo':Int.IDES}).replace("Int.", ""), + '...IDES...') self.assertEqual('...%(foo)i...' % {'foo':Int.IDES}, '...15...') self.assertEqual('...%(foo)d...' % {'foo':Int.IDES}, diff --git a/tests/run/tp_new.pyx b/tests/run/tp_new.pyx index 0da1c0bcc..45b52259f 100644 --- a/tests/run/tp_new.pyx +++ b/tests/run/tp_new.pyx @@ -1,6 +1,6 @@ # mode: run # tag: exttype, tpnew -# ticket: 808 +# ticket: t808 cimport cython diff --git a/tests/run/tp_new_T454.pyx b/tests/run/tp_new_T454.pyx index 893ef9b1b..d3401442c 100644 --- a/tests/run/tp_new_T454.pyx +++ b/tests/run/tp_new_T454.pyx @@ -1,4 +1,4 @@ -# ticket: 454 +# ticket: t454 cimport cython diff --git a/tests/run/tupleunpack_T298.pyx b/tests/run/tupleunpack_T298.pyx index 7763b1fc7..7e3150243 100644 --- a/tests/run/tupleunpack_T298.pyx +++ b/tests/run/tupleunpack_T298.pyx @@ -1,4 +1,4 @@ -# ticket: 298 +# ticket: t298 """ >>> func() diff --git a/tests/run/tupleunpack_T712.pyx b/tests/run/tupleunpack_T712.pyx index 24d750849..73b3c1446 100644 --- a/tests/run/tupleunpack_T712.pyx +++ b/tests/run/tupleunpack_T712.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 712 +# ticket: t712 def single_from_string(): """ diff --git a/tests/run/type_inference_T768.pyx b/tests/run/type_inference_T768.pyx index cb7b9eccb..8f1f2e61e 100644 --- a/tests/run/type_inference_T768.pyx +++ b/tests/run/type_inference_T768.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 768 +# ticket: t768 from cython cimport typeof def type_inference_del_int(): diff --git a/tests/run/type_inference_T768_cpp.pyx b/tests/run/type_inference_T768_cpp.pyx index 56fad4dab..295351914 100644 --- a/tests/run/type_inference_T768_cpp.pyx +++ b/tests/run/type_inference_T768_cpp.pyx @@ -1,6 +1,6 @@ # mode: run # tag: cpp -# ticket: 768 +# ticket: t768 from cython cimport typeof cdef extern from "shapes.h" namespace "shapes": diff --git a/tests/run/type_slots_int_long_T287.pyx b/tests/run/type_slots_int_long_T287.pyx index 2426225b5..7b66125b9 100644 --- a/tests/run/type_slots_int_long_T287.pyx +++ b/tests/run/type_slots_int_long_T287.pyx @@ -1,4 +1,4 @@ -# ticket: 287 +# ticket: t287 __doc__ = u""" >>> print( "%d" % Int() ) diff --git a/tests/run/typeddefaultargT373.pyx b/tests/run/typeddefaultargT373.pyx index 98ac85c3a..d817c97c7 100644 --- a/tests/run/typeddefaultargT373.pyx +++ b/tests/run/typeddefaultargT373.pyx @@ -1,4 +1,4 @@ -# ticket: 373 +# ticket: t373 import math diff --git a/tests/run/typedfieldbug_T303.pyx b/tests/run/typedfieldbug_T303.pyx index 4298a1cce..e1790c574 100644 --- a/tests/run/typedfieldbug_T303.pyx +++ b/tests/run/typedfieldbug_T303.pyx @@ -1,5 +1,5 @@ # mode: run -# ticket: 303 +# ticket: t303 __doc__ = """ >>> try: readonly() diff --git a/tests/run/typetest_T417.pyx b/tests/run/typetest_T417.pyx index 7d7b24902..622b35416 100644 --- a/tests/run/typetest_T417.pyx +++ b/tests/run/typetest_T417.pyx @@ -1,4 +1,4 @@ -# ticket: 417 +# ticket: t417 #cython: autotestdict=True cdef class Foo: diff --git a/tests/run/unsigned_char_ptr_bytes_conversion_T359.pyx b/tests/run/unsigned_char_ptr_bytes_conversion_T359.pyx index fb611511b..09df291f5 100644 --- a/tests/run/unsigned_char_ptr_bytes_conversion_T359.pyx +++ b/tests/run/unsigned_char_ptr_bytes_conversion_T359.pyx @@ -1,4 +1,4 @@ -# ticket: 359 +# ticket: t359 cdef unsigned char* some_c_unstring = 'test toast taste' diff --git a/tests/run/unsignedbehaviour_T184.pyx b/tests/run/unsignedbehaviour_T184.pyx index 9cbf65fc1..4dcb86398 100644 --- a/tests/run/unsignedbehaviour_T184.pyx +++ b/tests/run/unsignedbehaviour_T184.pyx @@ -1,4 +1,4 @@ -# ticket: 184 +# ticket: t184 """ >>> c_call() diff --git a/tests/run/with_statement_module_level_T536.pyx b/tests/run/with_statement_module_level_T536.pyx index 506c362f9..a18925f46 100644 --- a/tests/run/with_statement_module_level_T536.pyx +++ b/tests/run/with_statement_module_level_T536.pyx @@ -1,4 +1,4 @@ -# ticket: 536 +# ticket: t536 __doc__ = """ >>> inner_result |