diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2023-04-24 12:44:09 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2023-04-24 18:56:11 +0200 |
commit | 91b08978873bd49360afeb9d298c874c11cb963e (patch) | |
tree | 40e069c94d27d37dc63841ca3c502b3f457f1104 | |
parent | 0cc6b283d093ccbfd0dd4c350fb1cc9c789f07dc (diff) | |
download | cython-91b08978873bd49360afeb9d298c874c11cb963e.tar.gz |
Treat @total_ordering directive like @cfunc/@ccall directives by excluding it from the normal directives dict unless it's being used.
Also, remove it from the active directives once it's been used, to prevent it from appearing in nested structures.
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 4 | ||||
-rw-r--r-- | Cython/Compiler/Options.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index cba8effef..79a42827b 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1466,7 +1466,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if scope.defines_any_special(TypeSlots.richcmp_special_methods): self.generate_richcmp_function(scope, code) - elif scope.directives.get('total_ordering'): + elif 'total_ordering' in scope.directives: # Warn if this is used when it can't have any effect. warning(scope.parent_type.pos, "total_ordering directive used, but no comparison and equality methods defined") @@ -2144,7 +2144,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): # need to call up into base classes as we may not know all implemented comparison methods extern_parent = cls if cls.typeptr_cname else scope.parent_type.base_type - total_ordering = scope.directives.get('total_ordering', False) + total_ordering = 'total_ordering' in scope.directives comp_entry = {} diff --git a/Cython/Compiler/Options.py b/Cython/Compiler/Options.py index 13d07b495..cd1bb0431 100644 --- a/Cython/Compiler/Options.py +++ b/Cython/Compiler/Options.py @@ -341,7 +341,7 @@ directive_types = { 'c_string_type': one_of('bytes', 'bytearray', 'str', 'unicode'), 'c_string_encoding': normalise_encoding_name, 'trashcan': bool, - 'total_ordering': bool, + 'total_ordering': None, 'dataclasses.dataclass': DEFER_ANALYSIS_OF_ARGUMENTS, 'dataclasses.field': DEFER_ANALYSIS_OF_ARGUMENTS, } @@ -405,7 +405,7 @@ immediate_decorator_directives = { 'inline', 'exceptval', 'returns', # class directives 'freelist', 'no_gc', 'no_gc_clear', 'type_version_tag', 'final', - 'auto_pickle', 'internal', 'collection_type', + 'auto_pickle', 'internal', 'collection_type', 'total_ordering', # testing directives 'test_fail_if_path_exists', 'test_assert_path_exists', } |