shadchin 1 год назад
Родитель
Сommit
7ecf6c16ab

+ 1 - 1
contrib/tools/cython/.dist-info/METADATA

@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Metadata-Version: 2.1
 Name: Cython
 Name: Cython
-Version: 0.29.35
+Version: 0.29.36
 Summary: The Cython compiler for writing C extensions for the Python language.
 Summary: The Cython compiler for writing C extensions for the Python language.
 Home-page: http://cython.org/
 Home-page: http://cython.org/
 Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al.
 Author: Robert Bradshaw, Stefan Behnel, Dag Seljebotn, Greg Ewing, et al.

+ 47 - 0
contrib/tools/cython/.yandex_meta/__init__.py

@@ -0,0 +1,47 @@
+import os
+
+from devtools.yamaker.fileutil import re_sub_file
+from devtools.yamaker.project import NixProject
+from devtools.yamaker import python
+
+
+def post_install(self):
+    dist_files = python.extract_dist_info(self)
+
+    re_sub_file(
+        f"{self.dstdir}/cython.py",
+        r"# Change content of this file to change uids for cython programs - cython.*",
+        rf"# Change content of this file to change uids for cython programs - cython {self.version} r0",
+    )
+
+    self.yamakes.clear()
+    self.yamakes["."] = self.module(
+        module="PY3_LIBRARY",
+        NO_LINT=True,
+        RESOURCE_FILES=python.prepare_resource_files(self, *dist_files),
+    )
+
+    for path, dirs, files in os.walk(self.dstdir):
+        for file in files:
+            if file.endswith(".c"):
+                file = f"{path}/{file}"
+                with open(file) as f:
+                    first_line = f.readline()
+                if first_line.startswith("/* Generated by Cython"):
+                    os.remove(file)
+
+
+cython = NixProject(
+    owners=["g:python-contrib"],
+    arcdir="contrib/tools/cython",
+    nixattr=python.make_nixattr("cython"),
+    copy_sources=["Cython/", "cygdb.py", "cython.py"],
+    keep_paths=[
+        "Cython/Includes/numpy.pxd",
+        "Cython/Utility/CommonTypes.c",
+        "Cython/ya.make",
+        "generated_c_headers.h",
+        "generated_cpp_headers.h",
+    ],
+    post_install=post_install,
+)

+ 11 - 0
contrib/tools/cython/.yandex_meta/override.nix

@@ -0,0 +1,11 @@
+pkgs: attrs: with pkgs; with pkgs.python311.pkgs; with attrs; rec {
+  version = "0.29.36";
+
+  src = fetchPypi {
+    pname = "Cython";
+    inherit version;
+    sha256 = "sha256-QcDP0tdU44PJ7rle/8mqSrhH0Ml0cHfd18Dctow7wB8=";
+  };
+
+  patches = [];
+}

+ 20 - 0
contrib/tools/cython/CHANGES.rst

@@ -2,6 +2,26 @@
 Cython Changelog
 Cython Changelog
 ================
 ================
 
 
+0.29.36 (2023-07-04)
+====================
+
+Bugs fixed
+----------
+
+* Async generators lost their return value in PyPy.
+  (Github issue :issue:`5465`)
+
+* The outdated C macro ``_PyGC_FINALIZED()`` is no longer used in Py3.9+.
+
+* The deprecated ``Py_OptimizeFlag`` is no longer used in Python 3.9+.
+  (Github issue :issue:`5343`)
+
+* Using the global ``__debug__`` variable but not assertions could lead to compile errors.
+
+* The broken HTML template support was removed from Tempita.
+  (Github issue :issue:`3309`)
+
+
 0.29.35 (2023-05-24)
 0.29.35 (2023-05-24)
 ====================
 ====================
 
 

+ 3 - 2
contrib/tools/cython/Cython/Compiler/Builtin.py

@@ -417,9 +417,10 @@ def init_builtins():
     init_builtin_types()
     init_builtin_types()
     init_builtin_funcs()
     init_builtin_funcs()
 
 
-    builtin_scope.declare_var(
+    entry = builtin_scope.declare_var(
         '__debug__', PyrexTypes.c_const_type(PyrexTypes.c_bint_type),
         '__debug__', PyrexTypes.c_const_type(PyrexTypes.c_bint_type),
-        pos=None, cname='(!Py_OptimizeFlag)', is_cdef=True)
+        pos=None, cname='__pyx_assertions_enabled()', is_cdef=True)
+    entry.utility_code = UtilityCode.load_cached("AssertionsEnabled", "Exceptions.c")
 
 
     global list_type, tuple_type, dict_type, set_type, frozenset_type
     global list_type, tuple_type, dict_type, set_type, frozenset_type
     global bytes_type, str_type, unicode_type, basestring_type, slice_type
     global bytes_type, str_type, unicode_type, basestring_type, slice_type

+ 2 - 2
contrib/tools/cython/Cython/Compiler/ModuleNode.py

@@ -1469,10 +1469,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
             # in Py3.4+, call tp_finalize() as early as possible
             # in Py3.4+, call tp_finalize() as early as possible
             code.putln("#if CYTHON_USE_TP_FINALIZE")
             code.putln("#if CYTHON_USE_TP_FINALIZE")
             if needs_gc:
             if needs_gc:
-                finalised_check = '!_PyGC_FINALIZED(o)'
+                finalised_check = '!__Pyx_PyObject_GC_IsFinalized(o)'
             else:
             else:
                 finalised_check = (
                 finalised_check = (
-                    '(!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))')
+                    '(!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))')
             code.putln(
             code.putln(
                 "if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)"
                 "if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)"
                 " && Py_TYPE(o)->tp_finalize) && %s) {" % finalised_check)
                 " && Py_TYPE(o)->tp_finalize) && %s) {" % finalised_check)

+ 3 - 1
contrib/tools/cython/Cython/Compiler/Nodes.py

@@ -6215,8 +6215,10 @@ class AssertStatNode(StatNode):
     gil_message = "Raising exception"
     gil_message = "Raising exception"
 
 
     def generate_execution_code(self, code):
     def generate_execution_code(self, code):
+        code.globalstate.use_utility_code(
+            UtilityCode.load_cached("AssertionsEnabled", "Exceptions.c"))
         code.putln("#ifndef CYTHON_WITHOUT_ASSERTIONS")
         code.putln("#ifndef CYTHON_WITHOUT_ASSERTIONS")
-        code.putln("if (unlikely(!Py_OptimizeFlag)) {")
+        code.putln("if (unlikely(__pyx_assertions_enabled())) {")
         code.mark_pos(self.pos)
         code.mark_pos(self.pos)
         self.cond.generate_evaluation_code(code)
         self.cond.generate_evaluation_code(code)
         code.putln(
         code.putln(

+ 1 - 1
contrib/tools/cython/Cython/Shadow.py

@@ -1,7 +1,7 @@
 # cython.* namespace for pure mode.
 # cython.* namespace for pure mode.
 from __future__ import absolute_import
 from __future__ import absolute_import
 
 
-__version__ = "0.29.35"
+__version__ = "0.29.36"
 
 
 try:
 try:
     from __builtin__ import basestring
     from __builtin__ import basestring

+ 8 - 117
contrib/tools/cython/Cython/Tempita/_tempita.py

@@ -33,17 +33,6 @@ from __future__ import absolute_import
 
 
 import re
 import re
 import sys
 import sys
-try:
-    import cgi
-except ImportError:
-    pass
-try:
-    from urllib import quote as url_quote
-except ImportError:  # Py3
-    try:
-        from urllib.parse import quote as url_quote
-    except ImportError:
-        pass
 import os
 import os
 import tokenize
 import tokenize
 from io import StringIO
 from io import StringIO
@@ -51,8 +40,7 @@ from io import StringIO
 from ._looper import looper
 from ._looper import looper
 from .compat3 import bytes, unicode_, basestring_, next, is_unicode, coerce_text
 from .compat3 import bytes, unicode_, basestring_, next, is_unicode, coerce_text
 
 
-__all__ = ['TemplateError', 'Template', 'sub', 'HTMLTemplate',
-           'sub_html', 'html', 'bunch']
+__all__ = ['TemplateError', 'Template', 'sub', 'bunch']
 
 
 in_re = re.compile(r'\s+in\s+')
 in_re = re.compile(r'\s+in\s+')
 var_re = re.compile(r'^[a-z_][a-z0-9_]*$', re.I)
 var_re = re.compile(r'^[a-z_][a-z0-9_]*$', re.I)
@@ -150,9 +138,8 @@ class Template(object):
 
 
     def from_filename(cls, filename, namespace=None, encoding=None,
     def from_filename(cls, filename, namespace=None, encoding=None,
                       default_inherit=None, get_template=get_file_template):
                       default_inherit=None, get_template=get_file_template):
-        f = open(filename, 'rb')
-        c = f.read()
-        f.close()
+        with open(filename, 'rb') as f:
+            c = f.read()
         if encoding:
         if encoding:
             c = c.decode(encoding)
             c = c.decode(encoding)
         return cls(content=c, name=filename, namespace=namespace,
         return cls(content=c, name=filename, namespace=namespace,
@@ -417,91 +404,6 @@ class bunch(dict):
             self.__class__.__name__,
             self.__class__.__name__,
             ' '.join(['%s=%r' % (k, v) for k, v in sorted(self.items())]))
             ' '.join(['%s=%r' % (k, v) for k, v in sorted(self.items())]))
 
 
-############################################################
-## HTML Templating
-############################################################
-
-
-class html(object):
-
-    def __init__(self, value):
-        self.value = value
-
-    def __str__(self):
-        return self.value
-
-    def __html__(self):
-        return self.value
-
-    def __repr__(self):
-        return '<%s %r>' % (
-            self.__class__.__name__, self.value)
-
-
-def html_quote(value, force=True):
-    if not force and hasattr(value, '__html__'):
-        return value.__html__()
-    if value is None:
-        return ''
-    if not isinstance(value, basestring_):
-        value = coerce_text(value)
-    if sys.version >= "3" and isinstance(value, bytes):
-        value = cgi.escape(value.decode('latin1'), 1)
-        value = value.encode('latin1')
-    else:
-        value = cgi.escape(value, 1)
-    if sys.version < "3":
-        if is_unicode(value):
-            value = value.encode('ascii', 'xmlcharrefreplace')
-    return value
-
-
-def url(v):
-    v = coerce_text(v)
-    if is_unicode(v):
-        v = v.encode('utf8')
-    return url_quote(v)
-
-
-def attr(**kw):
-    parts = []
-    for name, value in sorted(kw.items()):
-        if value is None:
-            continue
-        if name.endswith('_'):
-            name = name[:-1]
-        parts.append('%s="%s"' % (html_quote(name), html_quote(value)))
-    return html(' '.join(parts))
-
-
-class HTMLTemplate(Template):
-
-    default_namespace = Template.default_namespace.copy()
-    default_namespace.update(dict(
-        html=html,
-        attr=attr,
-        url=url,
-        html_quote=html_quote,
-        ))
-
-    def _repr(self, value, pos):
-        if hasattr(value, '__html__'):
-            value = value.__html__()
-            quote = False
-        else:
-            quote = True
-        plain = Template._repr(self, value, pos)
-        if quote:
-            return html_quote(plain)
-        else:
-            return plain
-
-
-def sub_html(content, **kw):
-    name = kw.get('__name')
-    tmpl = HTMLTemplate(content, name=name)
-    return tmpl.substitute(kw)
-
 
 
 class TemplateDef(object):
 class TemplateDef(object):
     def __init__(self, template, func_name, func_signature,
     def __init__(self, template, func_name, func_signature,
@@ -1136,11 +1038,6 @@ def fill_command(args=None):
         dest='output',
         dest='output',
         metavar="FILENAME",
         metavar="FILENAME",
         help="File to write output to (default stdout)")
         help="File to write output to (default stdout)")
-    parser.add_option(
-        '--html',
-        dest='use_html',
-        action='store_true',
-        help="Use HTML style filling (including automatic HTML quoting)")
     parser.add_option(
     parser.add_option(
         '--env',
         '--env',
         dest='use_env',
         dest='use_env',
@@ -1168,19 +1065,13 @@ def fill_command(args=None):
         template_content = sys.stdin.read()
         template_content = sys.stdin.read()
         template_name = '<stdin>'
         template_name = '<stdin>'
     else:
     else:
-        f = open(template_name, 'rb')
-        template_content = f.read()
-        f.close()
-    if options.use_html:
-        TemplateClass = HTMLTemplate
-    else:
-        TemplateClass = Template
-    template = TemplateClass(template_content, name=template_name)
+        with open(template_name, 'rb') as f:
+            template_content = f.read()
+    template = Template(template_content, name=template_name)
     result = template.substitute(vars)
     result = template.substitute(vars)
     if options.output:
     if options.output:
-        f = open(options.output, 'wb')
-        f.write(result)
-        f.close()
+        with open(options.output, 'wb') as f:
+            f.write(result)
     else:
     else:
         sys.stdout.write(result)
         sys.stdout.write(result)
 
 

+ 10 - 1
contrib/tools/cython/Cython/Utility/AsyncGen.c

@@ -202,7 +202,9 @@ __Pyx_async_gen_repr(__pyx_CoroutineObject *o)
 static int
 static int
 __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
 __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
 {
 {
+#if !CYTHON_COMPILING_IN_PYPY
     PyThreadState *tstate;
     PyThreadState *tstate;
+#endif
     PyObject *finalizer;
     PyObject *finalizer;
     PyObject *firstiter;
     PyObject *firstiter;
 
 
@@ -212,15 +214,22 @@ __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
 
 
     o->ag_hooks_inited = 1;
     o->ag_hooks_inited = 1;
 
 
+#if CYTHON_COMPILING_IN_PYPY
+    finalizer = _PyEval_GetAsyncGenFinalizer();
+#else
     tstate = __Pyx_PyThreadState_Current;
     tstate = __Pyx_PyThreadState_Current;
-
     finalizer = tstate->async_gen_finalizer;
     finalizer = tstate->async_gen_finalizer;
+#endif
     if (finalizer) {
     if (finalizer) {
         Py_INCREF(finalizer);
         Py_INCREF(finalizer);
         o->ag_finalizer = finalizer;
         o->ag_finalizer = finalizer;
     }
     }
 
 
+#if CYTHON_COMPILING_IN_PYPY
+    firstiter = _PyEval_GetAsyncGenFirstiter();
+#else
     firstiter = tstate->async_gen_firstiter;
     firstiter = tstate->async_gen_firstiter;
+#endif
     if (firstiter) {
     if (firstiter) {
         PyObject *res;
         PyObject *res;
 #if CYTHON_UNPACK_METHODS
 #if CYTHON_UNPACK_METHODS

Некоторые файлы не были показаны из-за большого количества измененных файлов