[issue42955] Add sys.module_names: list of stdlib module names (Python and extension modules)
SylvainDe added the comment: For similar reasons as friendly-traceback, I'd be interested in a list of stdlib modules to be able to provide additional information in case of exceptions. For instance: string.ascii_lowercase > Before: NameError("name 'string' is not defined",) > After: NameError("name 'string' is not defined. Did you mean to import string > first) from maths import pi > Before: ImportError('No module named maths',) > After: ImportError("No module named maths. Did you mean 'math'?",) choice > Before: NameError("name 'choice' is not defined",) > After: NameError("name 'choice' is not defined. Did you mean 'choice' from > random (not imported)?",) from itertools import pi > Before: ImportError('cannot import name pi',) > After: ImportError("cannot import name pi. Did you mean 'from math import > pi'?",) The first 2 cases only use the module name but the last 2 cases will actually import the modules to get the names in it and I want to do this for modules which are safe to import (no side-effect expected). Source: https://github.com/SylvainDe/DidYouMean-Python/blob/master/didyoumean/didyoumean_internal.py#L30 (but if you are interested in that kind of features, I'd recommend using friendly-traceback instead) -- nosy: +SylvainDe ___ Python tracker <https://bugs.python.org/issue42955> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36026] Different error message when sys.settrace is used
SylvainDe added the comment: This looks good to me :) -- ___ Python tracker <https://bugs.python.org/issue36026> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36026] Different error message when sys.settrace is used
SylvainDe added the comment: Thanks for the investigation. I'm fine with the explanation provided. -- ___ Python tracker <https://bugs.python.org/issue36026> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36026] Different error message when sys.settrace is used (regressions)
Change by SylvainDe : -- type: -> behavior versions: +Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue36026> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36026] Different error message when sys.settrace is used (regressions)
SylvainDe added the comment: This is mostly true and I agree that error messages are not part of the API. However, I'd like to add the following points: - the error message was more meaningful before - the fact that having system.settrace used or not changes the behaviour makes me think this is not intentional. - the fact that the behaviour for unit test.assertRaisesRegexp is different depending on whether it is used as a context manager makes me think this is not intentional. From the documentation it seems like the 2 should behave the same way. Thus, even if this eventually deserves to be closed as a non-issue, I'd rather go on the safe side and double check if this is the desirable behaviour or if something went wrong with the commits previously mentioned. Maybe Jeroen Demeyer (jdemeyer) would have more hindsight about this. Does that look like an acceptable trade off? -- ___ Python tracker <https://bugs.python.org/issue36026> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36026] Different error message when sys.settrace is used (regressions)
New submission from SylvainDe : Context: Follow-up from https://bugs.python.org/issue35965 which was closed when we assumed the issue was on the coverage side. After nedbat investigation, it seems like the issue comes from call to "sys.settrace". Issue: -- A test relying on "self.assertRaisesRegex" with raising code "set.add(0)" started to lead to a different error message recently on the CI jobs. Indeed, instead of "descriptor '\w+' requires a 'set' object but received a 'int'" the raised exception was: "descriptor 'add' for 'set' objects doesn't apply to 'int' object" More surprisingly, the behavior was different: - depending on whether "self.assertRaisesRegex" was used as a context manager - on the Python version - when coverage was used. Nedbat was able to pinpoint the root cause for this: the usage of "sys.settrace". This can be hilighted using simple unit-tests: == import unittest import sys def trace(frame, event, arg): return trace DESCRIPT_REQUIRES_TYPE_RE = r"descriptor '\w+' requires a 'set' object but received a 'int'" DO_SET_TRACE = True class SetAddIntRegexpTests(unittest.TestCase): def test_assertRaisesRegex(self): if DO_SET_TRACE: sys.settrace(trace) self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE, set.add, 0) def test_assertRaisesRegex_contextman(self): if DO_SET_TRACE: sys.settrace(trace) with self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE): set.add(0) if __name__ == '__main__': unittest.main() == Here are the results from the original bug: On some versions, both tests pass: Python 3.6 and before Python 3.7.0a4+ (heads/master:4666ec5, Jan 26 2018, 04:14:24) - [GCC 4.8.4] - ('CPython', 'heads/master', '4666ec5')) On some versions, only test_assertRaisesRegex_contextman fails which was the confusing part: Python 3.7.1 (default, Dec 5 2018, 18:09:53) [GCC 5.4.0 20160609] - ('CPython', '', '') Python 3.7.2+ (heads/3.7:3fcfef3, Feb 9 2019, 07:30:09) [GCC 5.4.0 20160609] - ('CPython', 'heads/3.7', '3fcfef3') On some versions, both tests fail: Python 3.8.0a1+ (heads/master:8a03ff2, Feb 9 2019, 07:30:26) [GCC 5.4.0 20160609] - ('CPython', 'heads/master', '8a03ff2') First analysis: --- Using some git bisect magic, I was able to pinpoint the commits leading to each behavior change. - test_assertRaisesRegex_contextman starts to fail from: https://bugs.python.org/issue34126 https://github.com/python/cpython/commit/56868f940e0cc0b35d33c0070107ff3bed2d8766 - test_assertRaisesRegex starts to fail as well from: https://bugs.python.org/issue34125 https://github.com/python/cpython/commit/e89de7398718f6e68848b6340830aeb90b7d582c >From my point of view, it looks like we have 2 regressions. Please let me know >if this needs to be split into 2 independant issues. -- files: issue36_git_bisect_script_and_results.txt messages: 335857 nosy: SylvainDe priority: normal severity: normal status: open title: Different error message when sys.settrace is used (regressions) Added file: https://bugs.python.org/file48151/issue36_git_bisect_script_and_results.txt ___ Python tracker <https://bugs.python.org/issue36026> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35965] Behavior for unittest.assertRaisesRegex differs depending on whether it is used as a context manager
SylvainDe added the comment: I have no explanation whatsoever but removing the call to coverage seems to remove the issue: https://travis-ci.org/SylvainDe/DidYouMean-Python/builds/491727724 . I guess we can close this issue - sorry for the inconvenience. @nedbat: do you want me to open an issue in coverage ? -- ___ Python tracker <https://bugs.python.org/issue35965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35965] Behavior for unittest.assertRaisesRegex differs depending on whether it is used as a context manager
SylvainDe added the comment: This is a brilliant idea! I'll give it a try and keep you posted. -- ___ Python tracker <https://bugs.python.org/issue35965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35965] Behavior for unittest.assertRaisesRegex differs depending on whether it is used as a context manager
SylvainDe added the comment: That's the very weird thing. I've been unable to reproduce this locally but it can be seen on Travis runs. Here are the results so far (Versions numbers are retrieved with python -VV and python -c "import sys; print(sys._git)"): On some versions, both tests pass: Python 3.6 and before Python 3.7.0a4+ (heads/master:4666ec5, Jan 26 2018, 04:14:24) - [GCC 4.8.4] - ('CPython', 'heads/master', '4666ec5')) On some versions, both tests fail: Python 3.8.0a1+ (heads/master:8a03ff2, Feb 9 2019, 07:30:26) [GCC 5.4.0 20160609] - ('CPython', 'heads/master', '8a03ff2') On some versions, only test_assertRaisesRegex_contextman fails which is what I find confusing: Python 3.7.1 (default, Dec 5 2018, 18:09:53) [GCC 5.4.0 20160609] - ('CPython', '', '') Python 3.7.2+ (heads/3.7:3fcfef3, Feb 9 2019, 07:30:09) [GCC 5.4.0 20160609] - ('CPython', 'heads/3.7', '3fcfef3') Corresponding Travis build: https://travis-ci.org/SylvainDe/DidYouMean-Python/builds/491118939 . Corresponding code on Github: https://github.com/SylvainDe/DidYouMean-Python/blob/issue36_investigation/didyoumean/didyoumean_sugg_tests.py I'm happy to add more debug information and retrigger builds if needed. -- ___ Python tracker <https://bugs.python.org/issue35965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35965] Behavior for unittest.assertRaisesRegex differs depending on whether it is used as a context manager
New submission from SylvainDe : On some Python versions, the following pieces of code have a different behavior which is not something I'd expect: ``` DESCRIPT_REQUIRES_TYPE_RE = r"descriptor '\w+' requires a 'set' object but received a 'int'" ... def test_assertRaisesRegex(self): self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE, set.add, 0) def test_assertRaisesRegex_contextman(self): with self.assertRaisesRegex(TypeError, DESCRIPT_REQUIRES_TYPE_RE): set.add(0) ``` On impacted Python versions, only test_assertRaisesRegex_contextman fails while test_assertRaisesRegex works fine. Logs for the failure: ``` == FAIL: test_assertRaisesRegex_contextman (didyoumean_sugg_tests.SetAddIntRegexpTests) -- TypeError: descriptor 'add' for 'set' objects doesn't apply to 'int' object During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/travis/build/.../didyoumean/didyoumean_sugg_tests.py", line 23, in test_assertRaisesRegex_contextman set.add(0) AssertionError: "descriptor '\w+' requires a 'set' object but received a 'int'" does not match "descriptor 'add' for 'set' objects doesn't apply to 'int' object" ``` Either I am missing something or it looks like a bug to me. If needed, more details/context can be found on the StackOverflow question I opened: https://stackoverflow.com/questions/54612348/different-error-message-when-unittest-assertraisesregex-is-called-as-a-context-m . I can provide the details directly here if it is relevant. -- components: Tests messages: 335212 nosy: SylvainDe priority: normal severity: normal status: open title: Behavior for unittest.assertRaisesRegex differs depending on whether it is used as a context manager type: behavior versions: Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue35965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26656] Documentation for re.compile is a bit outdated
SylvainDe added the comment: @swapnil agarwal I think you can go for it. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26656> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30959] Constructor signature is duplicated in the help of namedtuples
SylvainDe added the comment: Regarding the `sorted.__doc__` issue, it seems like the signature does not appear in the `__doc__` member but it does appear when using `help(sorted)` which is probably what really matters. In any case, I find PEP 257 about this part a bit ambiguous : "The one-line docstring should NOT be a "signature"". Even though is should not be JUST a signature, should it CONTAIN the signature ? ------ nosy: +SylvainDe ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30959> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30878] The staticmethod doesn't properly reject keyword arguments
SylvainDe added the comment: Thanks Serhiy Storchaka ! This issue seems to affect (all) other Python versions. Should we proceed to a cherry-pick ? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30878> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30878] The staticmethod doesn't properly reject keyword arguments
Changes by SylvainDe <sylvain.des...@gmail.com>: -- pull_requests: +2700 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30878> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30878] The staticmethod doesn't properly reject keyword arguments
SylvainDe added the comment: I have a fix ready but I'll look if other functions using _PyArg_NoKeywords may have the same defect before submitting it. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30878> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30712] struct.unpack generates wrong error in certain conditions
SylvainDe added the comment: Could it be caused by alignment ? Also, it could be interesting to explain a bit more what you expect and what you actually get. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30712> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30712] struct.unpack generates wrong error in certain conditions
Changes by SylvainDe <sylvain.des...@gmail.com>: -- nosy: +SylvainDe ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30712> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30627] Incorrect error message for a few functions called with keywod argument
Changes by SylvainDe <sylvain.des...@gmail.com>: -- pull_requests: +2263 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30627> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30645] imp.py: load_package() appends to its own loop variable
SylvainDe added the comment: Alexandru: You'll find the PSF Contributor Agreement at https://www.python.org/psf/contrib/contrib-form/ . -- nosy: +SylvainDe ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30645> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26656] Documentation for re.compile is a bit outdated
SylvainDe added the comment: IMHO, the sentence is not bad as it is. An easy (?) yet efficient way to make it much better from the a user perspective would be to make the "regular expression object" text a link leading to https://docs.python.org/3/library/re.html#regular-expression-objects . -- nosy: +SylvainDe ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26656> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20627] Add context manager support to xmlrpc.client.ServerProxy
Changes by SylvainDe <sylvain.des...@gmail.com>: -- pull_requests: +2168 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20627> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30627] Incorrect error message for a few functions called with keywod argument
SylvainDe added the comment: (Also, I suspect introspection could be used to know if the same bug is still lying somewhere: get all objects (using gc?), keep callables with no __code__ member only, call with keyword argument, check error.) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30627> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30627] Incorrect error message for a few functions called with keywod argument
New submission from SylvainDe: Follow-up for http://bugs.python.org/issue30600 which is itself a follow-up for http://bugs.python.org/issue30534 . Not quite sure what the process is in that situation : creating a new ticket or updating the old one ? After working on http://bugs.python.org/issue30600 , I thought that maybe other functions not generated by the clinic would have the same issue. "git grep _PyArg_NoStackKeywords | grep -v clinic" gave me some place to look for and indeed: Modules/_struct.c:if (!_PyArg_NoStackKeywords("pack", kwnames)) { Modules/_struct.c:if (!_PyArg_NoStackKeywords("pack_into", kwnames)) { Python/bltinmodule.c:if (!_PyArg_NoStackKeywords("getattr", kwnames)) { Python/bltinmodule.c:if (!_PyArg_NoStackKeywords("next", kwnames)) { These four functions have a not-so-good error message when called with keyword arguments (and this is a regression compared to other Python versions) I have a fix ready to be suggested but: - I want to be sure that I had to create a new ticket - I suspect functions defined via the GEN_CONSTRUCTOR macro in Modules/_hashopenssl.c have the same issue but I do not know how to test it. Any help is welcome. -- components: Interpreter Core messages: 295676 nosy: SylvainDe priority: normal severity: normal status: open title: Incorrect error message for a few functions called with keywod argument versions: Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30627> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30600] Error message incorrect when index is called with keyword argument ("[].index(x=2)")
Changes by SylvainDe <sylvain.des...@gmail.com>: -- pull_requests: +2113 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30600> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30600] Error message incorrect when index is called with keyword argument ("[].index(x=2)")
SylvainDe added the comment: Thanks Serhiy Storchaka for the tip! I am currently investigating how the argument clinic works. I have used git bisect to find when the issue got introduced. commit fdd42c481edba4261f861fc1dfe24bbd79b5a17a bpo-20185: Convert list object implementation to Argument Clinic. (#542) -- Added file: http://bugs.python.org/file46939/git_bisect_bpo30600.txt ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30600> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30600] Error message incorrect when index is called with keyword argument ("[].index(x=2)")
SylvainDe added the comment: Can I give this a try or is anyone working on this already ? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30600> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30600] Error message incorrect when index is called with keyword argument ("[].index(x=2)")
New submission from SylvainDe: Issue found while trying to write tests for https://bugs.python.org/issue30592 . Issue related to http://bugs.python.org/issue30534 . The following code: [].index(x=2) should raise the following error: TypeError: index() takes no keyword arguments but currently raises: TypeError: index() takes at least 1 argument (0 given) This is easily reproduced with the following unit test: # AssertionError: "^index\(\) takes no keyword arguments$" does not match "index() takes at least 1 argument (0 given)" def test_varargs4_kw(self): msg = r"^index\(\) takes no keyword arguments$" self.assertRaisesRegex(TypeError, msg, [].index, x=2) -- components: Interpreter Core messages: 295427 nosy: SylvainDe priority: normal severity: normal status: open title: Error message incorrect when index is called with keyword argument ("[].index(x=2)") type: behavior versions: Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30600> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30592] Bad error message 'bool()() takes no keyword arguments'
SylvainDe added the comment: Hi serhiy.storchaka, this is fine by me! I've added a corresponding comment with questions/suggestions on the Github PR. Do you reckon I should open another ticket for the issue mentionned in my previous message ? I'm happy to take care of it :) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30592> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30592] Bad error message 'bool()() takes no keyword arguments'
SylvainDe added the comment: As I was trying to test coverage for a few places where the same error was built, I have discovered another issue where the error message is very misleading: AssertionError: "^index\(\) takes no keyword arguments$" does not match "index() takes at least 1 argument (0 given)" def test_varargs4_kw(self): msg = r"^index\(\) takes no keyword arguments$" self.assertRaisesRegex(TypeError, msg, [].index, x=2) Should I open another ticket to track this ? Anyway, so far, I have reached the following conclusion regarding the test coverage: Objects/call.c:551: "%.200s() takes no keyword arguments" => TESTED (In _PyMethodDef_RawFastCallDict) Objects/call.c:690: "%.200s() takes no keyword arguments" => Not tested (In _PyMethodDef_RawFastCallKeywords) Objects/call.c:737:PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments" => Not tested (In cfunction_call_varargs) Python/getargs.c:2508:PyErr_Format(PyExc_TypeError, "%.200s takes no keyword arguments" => TESTED (Now) (In _PyArg_NoKeywords) Python/getargs.c:2525:PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments" => Not tested (In _PyArg_NoStackKeywords) Any suggestion regarding how to test what is not tested is more than welcome. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30592> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30592] Bad error message 'bool()() takes no keyword arguments'
SylvainDe added the comment: The issue seems to be in: int _PyArg_NoKeywords(const char *funcname, PyObject *kwargs) I'm happy to submit a PR if needed. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30592> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30592] Bad error message 'bool()() takes no keyword arguments'
SylvainDe added the comment: Reproduced locally using unit tests: +def test_varargs0_kw(self): +msg = r"bool\(\) takes no keyword arguments" +self.assertRaisesRegex(TypeError, msg, bool, x=2) + giving: Traceback (most recent call last): File "/home/josay/Geekage/PythonRgr/cpython/Lib/test/test_call.py", line 136, in test_varargs0_kw self.assertRaisesRegex(TypeError, msg, bool, x=2) AssertionError: "bool\(\) takes no keyword arguments" does not match "bool()() takes no keyword arguments" -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30592> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30592] Bad error message 'bool()() takes no keyword arguments'
New submission from SylvainDe: Very recent "regression". Issue found because of a pet project trying to parse error messages using regexps : more on https://github.com/SylvainDe/DidYouMean-Python/issues/31 . On recent Cron builds on Jenkins, running the following code bool(this_doesnt_exist=2) fails with the following error message 'bool()() takes no keyword arguments' instead of the expected error message 'bool() takes no keyword arguments'. Having a quick look at the recent commits, I suspect with no guarantee whatsoever the issue got introduced with https://github.com/python/cpython/commit/5eb788bf7f54a8e04429e18fc332db858edd64b6 / http://bugs.python.org/issue30534 . I haven't tried to reproduce the issue locally yet and add the findinds if any later on. -- messages: 295366 nosy: SylvainDe priority: normal severity: normal status: open title: Bad error message 'bool()() takes no keyword arguments' type: enhancement ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30592> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29932] Missing word ("be") in error message ("first argument must a type object")
Changes by SylvainDe <sylvain.des...@gmail.com>: -- pull_requests: +790 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29932> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29932] Missing word ("be") in error message ("first argument must a type object")
New submission from SylvainDe: Very uninteresting issue but error message should probably be "first argument must BE a type object" in `array__array_reconstructor_impl` in Modules/arraymodule.c . This has been introduced with ad077154d0f305ee0ba5bf41d3cb47d1d9c43e7b . I'll handle this issue in the next day. -- messages: 290701 nosy: SylvainDe priority: normal severity: normal status: open title: Missing word ("be") in error message ("first argument must a type object") type: enhancement versions: Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29932> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29924] Useless argument in call to PyErr_Format
SylvainDe added the comment: Seems to be introduced via 250e4b0063fab35770719b64d1e36209c4aa2596 in January this year. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29924> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29924] Useless argument in call to PyErr_Format
SylvainDe added the comment: http://julio.meroh.net/2011/06/validating-format-strings-in-custom-c.html -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29924> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29924] Useless argument in call to PyErr_Format
SylvainDe added the comment: I forgot to copy the link but here is a description of what I had in mind for the first idea. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29924> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29924] Useless argument in call to PyErr_Format
New submission from SylvainDe: Very uninteresting issue I've found while looking at the code. In Objects/call.c, in _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self, PyObject **arg...), we have no_keyword_error: PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", method->ml_name, nargs); The `nargs` seems pointless. This issue is mosly opened to have a record number to open a commit but it raises a few questions: - would it make sense to try to use GCC/CLang's logic around __attribute__ to have this kind of things checked during compilation as much as possible ? - would it make sense to define very small functions wrapping some calls to `PyErr_Format` so that one can use function with a very clear signature at (almost) no cost? This would be specially relevant for error raised in multiple places with the same message (The trio PyMethodDef *method/PyExc_TypeError/"%.200s() takes no keyword arguments" is a good candidate for this). I'd be happy for work on this but I'm afraid this would correspond to something Raymond Hettinger asks new comers not to do : "Don't be a picture straightener" ( https://speakerdeck.com/pybay2016/raymond-hettinger-keynote-core-developer-world ). I've filled the impacted version as 3.7 as there is no real impacted version from a user point of view. -- components: Argument Clinic messages: 290645 nosy: SylvainDe, larry priority: normal severity: normal status: open title: Useless argument in call to PyErr_Format type: enhancement versions: Python 3.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29924> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24529] Same MemoryError object gets thrown from different places.
New submission from SylvainDe: Disclaimer: This is very minor, impacts only Python 2 and is maybe not even a bug. Context: I was randomly changing attribute of Exception objects when I discovered something I did not expect : sometimes when an exception occurs, a new object is raised (which is what I expected), sometimes a previously thrown exception is re-thrown (which surprised me). More specifically, MemoryError objects seem to be reused while most of the other exceptions I've played with where newly created. One can easily see this happening in the following piece of code : - first a NameError is caught and updated - then, we run the same code and print the re-caught exception : it is a new one - then, a MemoryError is caught and updated - then, we run the same code and print the re-caught exception : it is the same as previously. pre from __future__ import print_function old_e = None try: foobar except NameError as old_e: print(old_e:, old_e) old_e.args = tuple(['NEW VALUE']) print(old_e:, old_e) try: foobar except NameError as new_e: print(new_e:, new_e) print(old_e is new_e) old_e = None try: l = [0] * 99 except MemoryError as old_e: print(old_e:, old_e) old_e.args = tuple(['NEW VALUE']) print(old_e:, old_e) try: l = [0] * 99 except MemoryError as new_e: print(new_e:, new_e) print(old_e is new_e) /pre For the record, I am quite aware that this shouldn't impact anyone using Python normally. I was just messing around as part of a toy project where I try to enhance exception messages for a better user experience ( https://github.com/SylvainDe/DidYouMean-Python ). -- components: Interpreter Core messages: 245940 nosy: SylvainDe priority: normal severity: normal status: open title: Same MemoryError object gets thrown from different places. versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24529 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21989] Missing (optional) argument `start` and `end` in documentation for list.index
New submission from SylvainDe: From : https://docs.python.org/2/tutorial/datastructures.html and https://docs.python.org/3.4/tutorial/datastructures.html (and all other versions) : list.index(x) Return the index in the list of the first item whose value is x. It is an error if there is no such item. From `help(list)` : | index(...) | L.index(value, [start, [stop]]) - integer -- return first index of value. | Raises ValueError if the value is not present. Thus, second and third parameter are undocumented. -- assignee: docs@python components: Documentation files: list_index_start_end.patch keywords: patch messages: 223195 nosy: SylvainDe, docs@python priority: normal severity: normal status: open title: Missing (optional) argument `start` and `end` in documentation for list.index type: enhancement versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file35967/list_index_start_end.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21989 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16399] argparse: append action with default list adds to list instead of overriding
SylvainDe added the comment: As this is likely not to get solved, is there a recommanded way to work around this issue ? Here's what I have done : import argparse def main(): Main function parser = argparse.ArgumentParser() parser.add_argument('--foo', action='append') for arg_str in ['--foo 1 --foo 2', '']: args = parser.parse_args(arg_str.split()) if not args.foo: args.foo = ['default', 'value'] print(args) printing Namespace(foo=['1', '2']) Namespace(foo=['default', 'value']) as expected but I wanted to know if there a more argparse-y way to do this. I have tried using `set_defaults` without any success. Also, as pointed out the doc for optparse describes the behavior in a simple way : The append action calls the append method on the current value of the option. This means that any default value specified must have an append method. It also means that if the default value is non-empty, the default elements will be present in the parsed value for the option, with any values from the command line appended after those default values. -- nosy: +SylvainDe ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16399 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com