diff options
author | shadchin <shadchin@yandex-team.com> | 2024-04-11 21:35:50 +0300 |
---|---|---|
committer | shadchin <shadchin@yandex-team.com> | 2024-04-11 21:45:16 +0300 |
commit | 00ff372db04018582b653a028eb3647b40544256 (patch) | |
tree | 77a826d8773ce993032736f6ba0a56f9629cc2b2 /contrib | |
parent | e777f6fe503bff0abc88aec2b1f7da675bfb68ae (diff) | |
download | ydb-00ff372db04018582b653a028eb3647b40544256.tar.gz |
Fix utilitycode generation for const fused typedef (backport)
Need for update scikit-learn
371604d3522a7676f7380c48b63025dbe6dcf25f
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/FusedNode.py | 8 | ||||
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/Naming.py | 1 | ||||
-rwxr-xr-x | contrib/tools/cython/cython.py | 2 | ||||
-rw-r--r-- | contrib/tools/cython/patches/pr5233-backport-support-const.patch | 37 |
4 files changed, 44 insertions, 4 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/FusedNode.py b/contrib/tools/cython/Cython/Compiler/FusedNode.py index c32b02d941..b833e35189 100644 --- a/contrib/tools/cython/Cython/Compiler/FusedNode.py +++ b/contrib/tools/cython/Cython/Compiler/FusedNode.py @@ -3,7 +3,8 @@ from __future__ import absolute_import import copy from . import (ExprNodes, PyrexTypes, MemoryView, - ParseTreeTransforms, StringEncoding, Errors) + ParseTreeTransforms, StringEncoding, Errors, + Naming) from .ExprNodes import CloneNode, ProxyNode, TupleNode from .Nodes import FuncDefNode, CFuncDefNode, StatListNode, DefNode from ..Utils import OrderedSet @@ -291,9 +292,10 @@ class FusedCFuncDefNode(StatListNode): """) def _dtype_name(self, dtype): + name = str(dtype).replace('_', '__').replace(' ', '_') if dtype.is_typedef: - return '___pyx_%s' % dtype - return str(dtype).replace(' ', '_') + name = Naming.fused_dtype_prefix + name + return name def _dtype_type(self, dtype): if dtype.is_typedef: diff --git a/contrib/tools/cython/Cython/Compiler/Naming.py b/contrib/tools/cython/Cython/Compiler/Naming.py index 4dd6cbbd5c..ceaddf4b18 100644 --- a/contrib/tools/cython/Cython/Compiler/Naming.py +++ b/contrib/tools/cython/Cython/Compiler/Naming.py @@ -118,6 +118,7 @@ frame_cname = pyrex_prefix + "frame" frame_code_cname = pyrex_prefix + "frame_code" binding_cfunc = pyrex_prefix + "binding_PyCFunctionType" fused_func_prefix = pyrex_prefix + 'fuse_' +fused_dtype_prefix = pyrex_prefix + 'fused_dtype_' quick_temp_cname = pyrex_prefix + "temp" # temp variable for quick'n'dirty temping tp_dict_version_temp = pyrex_prefix + "tp_dict_version" obj_dict_version_temp = pyrex_prefix + "obj_dict_version" diff --git a/contrib/tools/cython/cython.py b/contrib/tools/cython/cython.py index 554ba1b4ff..4111f048da 100755 --- a/contrib/tools/cython/cython.py +++ b/contrib/tools/cython/cython.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Change content of this file to change uids for cython programs - cython 0.29.37 r0 +# Change content of this file to change uids for cython programs - cython 0.29.37 r1 # # Cython -- Main Program, generic diff --git a/contrib/tools/cython/patches/pr5233-backport-support-const.patch b/contrib/tools/cython/patches/pr5233-backport-support-const.patch new file mode 100644 index 0000000000..bb7a9c3f6e --- /dev/null +++ b/contrib/tools/cython/patches/pr5233-backport-support-const.patch @@ -0,0 +1,37 @@ +https://github.com/cython/cython/pull/5233 + +--- contrib/tools/cython/Cython/Compiler/FusedNode.py (index) ++++ contrib/tools/cython/Cython/Compiler/FusedNode.py (working tree) +@@ -3,7 +3,8 @@ from __future__ import absolute_import + import copy + + from . import (ExprNodes, PyrexTypes, MemoryView, +- ParseTreeTransforms, StringEncoding, Errors) ++ ParseTreeTransforms, StringEncoding, Errors, ++ Naming) + from .ExprNodes import CloneNode, ProxyNode, TupleNode + from .Nodes import FuncDefNode, CFuncDefNode, StatListNode, DefNode + from ..Utils import OrderedSet +@@ -291,9 +292,10 @@ class FusedCFuncDefNode(StatListNode): + """) + + def _dtype_name(self, dtype): ++ name = str(dtype).replace('_', '__').replace(' ', '_') + if dtype.is_typedef: +- return '___pyx_%s' % dtype +- return str(dtype).replace(' ', '_') ++ name = Naming.fused_dtype_prefix + name ++ return name + + def _dtype_type(self, dtype): + if dtype.is_typedef: +--- contrib/tools/cython/Cython/Compiler/Naming.py (index) ++++ contrib/tools/cython/Cython/Compiler/Naming.py (working tree) +@@ -118,6 +118,7 @@ frame_cname = pyrex_prefix + "frame" + frame_code_cname = pyrex_prefix + "frame_code" + binding_cfunc = pyrex_prefix + "binding_PyCFunctionType" + fused_func_prefix = pyrex_prefix + 'fuse_' ++fused_dtype_prefix = pyrex_prefix + 'fused_dtype_' + quick_temp_cname = pyrex_prefix + "temp" # temp variable for quick'n'dirty temping + tp_dict_version_temp = pyrex_prefix + "tp_dict_version" + obj_dict_version_temp = pyrex_prefix + "obj_dict_version" |