summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-07 11:37:28 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-07 11:37:28 +0200
commita7125d5535c2cf641f188eeeb6fb83676953c1c0 (patch)
treea2098e7301b7c686619f7480698102caa62c1e78
parentbc11c9d23e603e482a054c661bd532ee08fc28a0 (diff)
parent30c891e0dc36a553455df9064ecb1f13414a12d2 (diff)
downloadcython-a7125d5535c2cf641f188eeeb6fb83676953c1c0.tar.gz
Merge branch 'master' into fix_srctree_tests_on_windows
-rw-r--r--Cython/Compiler/ExprNodes.py6
-rw-r--r--Cython/Compiler/FusedNode.py2
-rw-r--r--tests/run/test_asyncgen.py2
-rw-r--r--tests/run/test_fstring.pyx8
4 files changed, 11 insertions, 7 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 212dca068..9e94d0bd8 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -9279,7 +9279,8 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
value=arg.default)
for arg in default_kwargs])
self.defaults_kwdict = defaults_kwdict.analyse_types(env)
- else:
+ elif not self.specialized_cpdefs:
+ # Fused dispatch functions do not support (dynamic) default arguments, only the specialisations do.
if default_args:
defaults_tuple = DefaultsTupleNode(
self.pos, default_args, self.defaults_struct)
@@ -9440,8 +9441,7 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
if self.defaults_kwdict:
code.putln('__Pyx_CyFunction_SetDefaultsKwDict(%s, %s);' % (
self.result(), self.defaults_kwdict.py_result()))
- if def_node.defaults_getter and not self.specialized_cpdefs:
- # Fused functions do not support dynamic defaults, only their specialisations can have them for now.
+ if def_node.defaults_getter:
code.putln('__Pyx_CyFunction_SetDefaultsGetter(%s, %s);' % (
self.result(), def_node.defaults_getter.entry.pyfunc_cname))
if self.annotations_dict:
diff --git a/Cython/Compiler/FusedNode.py b/Cython/Compiler/FusedNode.py
index 42f15eea3..b45928e54 100644
--- a/Cython/Compiler/FusedNode.py
+++ b/Cython/Compiler/FusedNode.py
@@ -640,7 +640,7 @@ class FusedCFuncDefNode(StatListNode):
pyx_code.put_chunk(
u"""
- def __pyx_fused_cpdef(signatures, args, kwargs, defaults, *, _fused_sigindex={}):
+ def __pyx_fused_cpdef(signatures, args, kwargs, defaults, _fused_sigindex={}):
# FIXME: use a typed signature - currently fails badly because
# default arguments inherit the types we specify here!
diff --git a/tests/run/test_asyncgen.py b/tests/run/test_asyncgen.py
index eebbb4c82..aa19727cb 100644
--- a/tests/run/test_asyncgen.py
+++ b/tests/run/test_asyncgen.py
@@ -894,7 +894,7 @@ class AsyncGenAsyncioTest(unittest.TestCase):
async def target():
await asyncio.sleep(0.01)
- 1 / 0
+ 1 / ZERO
async def foo():
nonlocal DONE
diff --git a/tests/run/test_fstring.pyx b/tests/run/test_fstring.pyx
index 5bcf9c0b6..b8e93673a 100644
--- a/tests/run/test_fstring.pyx
+++ b/tests/run/test_fstring.pyx
@@ -255,8 +255,12 @@ f'{a * x()}'"""
width = 1
# Test around 256.
- for i in range(250, 260):
- self.assertEqual(cy_eval(build_fstr(i), x=x, width=width), (x+' ')*i)
+ # for i in range(250, 260):
+ # self.assertEqual(cy_eval(build_fstr(i), x=x, width=width), (x+' ')*i)
+ self.assertEqual(
+ cy_eval('[' + ', '.join(build_fstr(i) for i in range(250, 260)) + ']', x=x, width=width),
+ [(x+' ')*i for i in range(250, 260)],
+ )
# Test concatenating 2 largs fstrings.
self.assertEqual(cy_eval(build_fstr(255)*3, x=x, width=width), (x+' ')*(255*3)) # CPython uses 255*256