Imported Upstream version 0.28.6 upstream/0.28.6
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 31 Dec 2020 03:04:15 +0000 (12:04 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 31 Dec 2020 03:04:15 +0000 (12:04 +0900)
13 files changed:
CHANGES.rst
Cython/Compiler/ModuleNode.py
Cython/Compiler/Optimize.py
Cython/Compiler/TreePath.py
Cython/Shadow.py
Cython/Utility/ModuleSetupCode.c
appveyor.yml
runtests.py
tests/run/generators_py.py
tests/run/generators_py35.py [new file with mode: 0644]
tests/run/pure_py.py
tests/run/pure_py3.py
tests/run/unicodeliterals.pyx

index 6af53424b97dece8a616cd0af2d428225d046063..a31da0f25dd7792d89bfe326816283d2d1ab618a 100644 (file)
@@ -2,6 +2,20 @@
 Cython Changelog
 ================
 
+0.28.6 (2018-11-01)
+===================
+
+Bugs fixed
+----------
+
+* Extensions compiled with MinGW-64 under Windows could misinterpret integer
+  objects larger than 15 bit and return incorrect results.
+  (Github issue #2670)
+
+* Multiplied string literals lost their factor when they are part of another
+  constant expression (e.g. 'x' * 10 + 'y' => 'xy').
+
+
 0.28.5 (2018-08-03)
 ===================
 
index 64cec6d6919e98b937c80caa7b75f5bc0ecaf008..fc6ff54fcec7ec733e80492ed24ac88e29bb69e5 100644 (file)
@@ -245,6 +245,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
             h_code.put_generated_by()
             api_guard = Naming.api_guard_prefix + self.api_name(env)
             h_code.put_h_guard(api_guard)
+            # Work around https://bugs.python.org/issue4709
+            h_code.putln('#ifdef __MINGW64__')
+            h_code.putln('#define MS_WIN64')
+            h_code.putln('#endif')
+
             h_code.putln('#include "Python.h"')
             if result.h_file:
                 h_code.putln('#include "%s"' % os.path.basename(result.h_file))
index 6be3cb774e461ff178f8e3d166e3107346baad39..c43961d21eb9d9556103acc6181c22b103d6e859 100644 (file)
@@ -4234,7 +4234,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
                     string_node.bytes_value.encoding)
         else:
             assert False, "unknown string node type: %s" % type(string_node)
-        string_node.value = build_string(
+        string_node.constant_result = string_node.value = build_string(
             string_node.value * multiplier,
             string_node.value.encoding)
         return string_node
index 2c092ce879769c5b57a58bc1c5ddc3e55b9e0270..272570a033a1348802d81055fa8168488faae7e9 100644 (file)
@@ -12,14 +12,14 @@ import re
 import operator
 
 path_tokenizer = re.compile(
-    "("
-    "'[^']*'|\"[^\"]*\"|"
-    "//?|"
-    "\(\)|"
-    "==?|"
-    "[/.*\[\]\(\)@])|"
-    "([^/\[\]\(\)@=\s]+)|"
-    "\s+"
+    r"("
+    r"'[^']*'|\"[^\"]*\"|"
+    r"//?|"
+    r"\(\)|"
+    r"==?|"
+    r"[/.*\[\]()@])|"
+    r"([^/\[\]()@=\s]+)|"
+    r"\s+"
     ).findall
 
 def iterchildren(node, attr_name):
index 30d4aac84f72cb3e05e902d1830076469ba643f3..fb18e419e526527fc367b6edbd6b2eb5144cdf8a 100644 (file)
@@ -1,7 +1,7 @@
 # cython.* namespace for pure mode.
 from __future__ import absolute_import
 
-__version__ = "0.28.5"
+__version__ = "0.28.6"
 
 try:
     from __builtin__ import basestring
index 2ced47e4cdb115a1b976d2817829a360fa08518a..0480d618960b08c87caae0999d3b12b27d481601 100644 (file)
   #undef SHIFT
   #undef BASE
   #undef MASK
+  /* Compile-time sanity check that these are indeed equal.  Github issue #2670. */
+  #ifdef SIZEOF_VOID_P
+    enum { __pyx_check_sizeof_voidp = 1/(SIZEOF_VOID_P == sizeof(void*)) };
+  #endif
 #endif
 
 #ifndef __has_attribute
index e6a15d1e7c8d1edbb1ecf9ff3f8a0dd93faf7c3f..e36fcea0c4c31b7b1e3ed91ba853e460a03ffe97 100644 (file)
@@ -17,6 +17,14 @@ environment:
       PYTHON_VERSION: "2.7"
       PYTHON_ARCH: "64"
 
+    - PYTHON: "C:\\Python37"
+      PYTHON_VERSION: "3.7"
+      PYTHON_ARCH: "32"
+
+    - PYTHON: "C:\\Python37-x64"
+      PYTHON_VERSION: "3.7"
+      PYTHON_ARCH: "64"
+
     - PYTHON: "C:\\Python36"
       PYTHON_VERSION: "3.6"
       PYTHON_ARCH: "32"
index 616d2a0a39484218b0e356a732fc34a1637fe280..4c9a476c255b570840762f718931d9da3289c813 100755 (executable)
@@ -487,7 +487,7 @@ class build_ext(_build_ext):
 
 
 class ErrorWriter(object):
-    match_error = re.compile('(warning:)?(?:.*:)?\s*([-0-9]+)\s*:\s*([-0-9]+)\s*:\s*(.*)').match
+    match_error = re.compile(r'(warning:)?(?:.*:)?\s*([-0-9]+)\s*:\s*([-0-9]+)\s*:\s*(.*)').match
 
     def __init__(self):
         self.output = []
index db4ffd1a576441921aaef87f95ac68d8b9f377a4..914252bf48e9ceee1e15a540a2b057209c918a53 100644 (file)
@@ -81,17 +81,6 @@ def with_outer(*args):
             yield i
     return generator
 
-def with_outer_raising(*args):
-    """
-    >>> x = with_outer_raising(1, 2, 3)
-    >>> list(x())
-    [1, 2, 3]
-    """
-    def generator():
-        for i in args:
-            yield i
-        raise StopIteration
-    return generator
 
 def test_close():
     """
diff --git a/tests/run/generators_py35.py b/tests/run/generators_py35.py
new file mode 100644 (file)
index 0000000..ac20268
--- /dev/null
@@ -0,0 +1,24 @@
+# mode: run
+# tag: generators, pure3.5
+
+from __future__ import generator_stop
+
+# "generator_stop" was only added in Py3.5.
+
+
+def with_outer_raising(*args):
+    """
+    >>> x = with_outer_raising(1, 2, 3)
+    >>> try:
+    ...     list(x())
+    ... except RuntimeError:
+    ...     print("OK!")
+    ... else:
+    ...     print("NOT RAISED!")
+    OK!
+    """
+    def generator():
+        for i in args:
+            yield i
+        raise StopIteration
+    return generator
index b52517a3accd28ba5470554aab9a0025f2de0203..72218d91010d4ab79cd432d8634ceda705698a99 100644 (file)
@@ -209,6 +209,10 @@ def test_declare_c_types(n):
 @cython.ccall
 @cython.returns(cython.double)
 def c_call(x):
+    return x
+
+
+def call_ccall(x):
     """
     Test that a declared return type is honoured when compiled.
 
@@ -224,10 +228,6 @@ def c_call(x):
     >>> (is_compiled and 1) or result
     1
     """
-    return x
-
-
-def call_ccall(x):
     ret = c_call(x)
     return ret, cython.typeof(ret)
 
@@ -236,9 +236,13 @@ def call_ccall(x):
 @cython.inline
 @cython.returns(cython.double)
 def cdef_inline(x):
+    return x + 1
+
+
+def call_cdef_inline(x):
     """
     >>> result, return_type = call_cdef_inline(1)
-    >>> (not is_compiled and 'float') or type(return_type).__name__
+    >>> (not is_compiled and 'float') or type(result).__name__
     'float'
     >>> (not is_compiled and 'double') or return_type
     'double'
@@ -247,10 +251,6 @@ def cdef_inline(x):
     >>> result == 2.0  or  result
     True
     """
-    return x + 1
-
-
-def call_cdef_inline(x):
     ret = cdef_inline(x)
     return ret, cython.typeof(ret)
 
@@ -293,6 +293,12 @@ def ccall_except(x):
 @cython.returns(cython.long)
 @cython.exceptval(-1)
 def cdef_except(x):
+    if x == 0:
+        raise ValueError
+    return x+1
+
+
+def call_cdef_except(x):
     """
     >>> call_cdef_except(41)
     42
@@ -300,12 +306,6 @@ def cdef_except(x):
     Traceback (most recent call last):
     ValueError
     """
-    if x == 0:
-        raise ValueError
-    return x+1
-
-
-def call_cdef_except(x):
     return cdef_except(x)
 
 
index 1e07b59fda3dae4eebc1300cf6659e3ac7089f8c..4217ca43f9ca8528cc51e0533597a0767d2f8ceb 100644 (file)
@@ -42,6 +42,10 @@ def test_struct(n: cython.int, x: cython.double) -> MyStruct2:
 
 @cython.ccall
 def c_call(x) -> cython.double:
+    return x
+
+
+def call_ccall(x):
     """
     Test that a declared return type is honoured when compiled.
 
@@ -57,10 +61,6 @@ def c_call(x) -> cython.double:
     >>> (is_compiled and 1) or result
     1
     """
-    return x
-
-
-def call_ccall(x):
     ret = c_call(x)
     return ret, cython.typeof(ret)
 
@@ -68,9 +68,13 @@ def call_ccall(x):
 @cython.cfunc
 @cython.inline
 def cdef_inline(x) -> cython.double:
+    return x + 1
+
+
+def call_cdef_inline(x):
     """
     >>> result, return_type = call_cdef_inline(1)
-    >>> (not is_compiled and 'float') or type(return_type).__name__
+    >>> (not is_compiled and 'float') or type(result).__name__
     'float'
     >>> (not is_compiled and 'double') or return_type
     'double'
@@ -79,9 +83,5 @@ def cdef_inline(x) -> cython.double:
     >>> result == 2.0  or  result
     True
     """
-    return x + 1
-
-
-def call_cdef_inline(x):
     ret = cdef_inline(x)
     return ret, cython.typeof(ret)
index c1acf56cabf7358ee683e723db169dc1899474cf..7d4806ef1a9c7f65d9b06a533d777722259fa1f4 100644 (file)
@@ -85,6 +85,8 @@ __doc__ = br"""
     True
     >>> wide_literal == u'\\U00101234'   # unescaped by Python
     True
+    >>> ustring_in_constant_tuple == ('a', u'abc', u'\\N{SNOWMAN}', u'x' * 3, u'\\N{SNOWMAN}' * 4 + u'O')  or  ustring_in_constant_tuple  # unescaped by Python
+    True
 """
 
 if sys.version_info >= (2,6,5):
@@ -118,3 +120,5 @@ add = u'Søk ik' + u'üÖä' + u'abc'
 null = u'\x00'
 
 wide_literal = u'\U00101234'
+
+ustring_in_constant_tuple = ('a', u'abc', u'\N{SNOWMAN}', u'x' * 3, u'\N{SNOWMAN}' * 4 + u'O')