Commit bd56216a authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.29.x'

parents 2f021123 d4ce52c0
......@@ -98,6 +98,12 @@ Other changes
Bugs fixed
----------
* Fix a crash when accessing the ``__kwdefaults__`` special attribute of
fused functions. (Github issue #1470)
* Fix the parsing of buffer format strings that contain numeric sizes, which
could lead to incorrect input rejections. (Github issue #2845)
* Avoid a C #pragma in old gcc versions that was only added in GCC 4.6.
Patch by Michael Anselmi. (Github issue #2838)
......
......@@ -9465,7 +9465,8 @@ 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:
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.
code.putln('__Pyx_CyFunction_SetDefaultsGetter(%s, %s);' % (
self.result(), def_node.defaults_getter.entry.pyfunc_cname))
if self.annotations_dict:
......
......@@ -58,12 +58,21 @@ def opt_func(fused_t obj, cython.floating myf = 1.2, cython.integral myi = 7):
>>> opt_func("spam", f, i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func("spam", f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func("spam", myf=f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func[str, float, int]("spam", f, i)
str object float int
spam 5.60 9 5.60 9
>>> opt_func[str, cy.double, cy.long]("spam", f, i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func[str, cy.double, cy.long]("spam", f, myi=i)
str object double long
spam 5.60 9 5.60 9
>>> opt_func[str, float, cy.int]("spam", f, i)
str object float int
spam 5.60 9 5.60 9
......@@ -129,6 +138,28 @@ def test_opt_func():
opt_func("ham", f, entry4)
def test_opt_func_introspection():
"""
>>> opt_func.__defaults__
(1.2, 7)
>>> opt_func.__kwdefaults__
>>> opt_func.__annotations__
{}
>>> opt_func[str, float, int].__defaults__
(1.2, 7)
>>> opt_func[str, float, int].__kwdefaults__
>>> opt_func[str, float, int].__annotations__
{}
>>> opt_func[str, cy.double, cy.long].__defaults__
(1.2, 7)
>>> opt_func[str, cy.double, cy.long].__kwdefaults__
>>> opt_func[str, cy.double, cy.long].__annotations__
{}
"""
def func_with_object(fused_with_object obj, cython.integral myi = 7):
"""
>>> func_with_object(1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment