GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||
GeezerVison is showing github.com — bpo-33967: singledispatch raises TypeError when no positional arguments by corona10 · Pull Request #8184 · python/cpython Conversation
|
|
I think this is too much. I think this is enough: if not args: raise TypeError("singledispatch requires at least 1 positional argument") |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
True, both |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Okay can I update this PR into suggested one? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Updated! Please take a look! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Test seems too redundant for now.
TypeError happens always when no positional arguments.
How the generic function defined is not important.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I believe singledispatch requires positional argument by design, intentionally. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@methane |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Error message is not important here. (We won't backport such improvements)
functools.singledispatch now raises TypeError instead of IndexError when no
positional arguments are passed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@methane I've updated news |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
func can be not having the __name__ attribute in general case. This PR can break a code which use singledispatch() with custom callables.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Also this change creates a new reference to func linked to from wrapper. It may be better to keep a reference just to the name. E.g.
funcname = getattr(func, '__name__', 'singledispatch function') def wrapper(*args, **kw): # use funcname
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I fixed it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-8220 is a backport of this pull request to the 3.7 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-8184) (cherry picked from commit 445f1b3) Co-authored-by: Dong-hee Na <[email protected]>
|
GH-8221 is a backport of this pull request to the 3.6 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-8184) (cherry picked from commit 445f1b3) Co-authored-by: Dong-hee Na <[email protected]>
(cherry picked from commit 445f1b3) Co-authored-by: Dong-hee Na <[email protected]>
(cherry picked from commit 445f1b3) Co-authored-by: Dong-hee Na <[email protected]>
| def f(*args): | ||
| pass | ||
| msg = 'f requires at least 1 positional argument' | ||
| with self.assertRaisesRegexp(TypeError, msg): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
assertRaisesRegexp() is deprecated, so this test fails when test_functools is run with -Werror (see #8261).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.