FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-149083: use sentinel to fix _functools.reduce() signature by skirpichev · Pull Request #149591 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .py  (2) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
3 changes: 2 additions & 1 deletion Lib/inspect.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,8 @@ def wrap_value(s):
except NameError:
raise ValueError

if isinstance(value, (str, int, float, bytes, bool, type(None))):
if isinstance(value, (str, int, float, bytes, bool, type(None),
sentinel)):
return ast.Constant(value)
raise ValueError

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_inspect/test_inspect.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6255,8 +6255,7 @@ def test_faulthandler_module_has_signatures(self):
self._test_module_has_signatures(faulthandler, unsupported_signature=unsupported_signature)

def test_functools_module_has_signatures(self):
unsupported_signature = {"reduce"}
self._test_module_has_signatures(functools, unsupported_signature=unsupported_signature)
self._test_module_has_signatures(functools)

def test_gc_module_has_signatures(self):
import gc
Expand Down
4 changes: 2 additions & 2 deletions Modules/_functoolsmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ _functools.reduce
function as func: object
iterable as seq: object
/
initial as result: object = NULL
initial as result: object(c_default="NULL") = functools._initial_missing

Apply a function of two arguments cumulatively to the items of an iterable, from left to right.

Expand All @@ -1081,7 +1081,7 @@ calculates ((((1 + 2) + 3) + 4) + 5).
static PyObject *
_functools_reduce_impl(PyObject *module, PyObject *func, PyObject *seq,
PyObject *result)
/*[clinic end generated code: output=30d898fe1267c79d input=4ccfb74548ce5170]*/
/*[clinic end generated code: output=30d898fe1267c79d input=5c9088c98ffe2793]*/
{
PyObject *args, *it;

Expand Down
5 changes: 3 additions & 2 deletions Modules/clinic/_functoolsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

Back | FazBrowse Home | New Git URL