
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2016-09-19 07:41 bymanishearth, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| Issue28203.patch | soummyaah,2016-09-19 08:20 | diff complexobject.c | ||
| Issue28203#3.patch | soummyaah,2016-09-20 12:05 | |||
| Issue28203#4.patch | soummyaah,2016-09-20 12:32 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft,2017-03-31 16:36 | |
| Repositories containing patches | |||
|---|---|---|---|
| https://github.com/soummyaah/cpython | |||
| Messages (15) | |||
|---|---|---|---|
| msg276952 -(view) | Author: Manish Goregaokar (manishearth) | Date: 2016-09-19 07:41 | |
When the second argument of complex() is not a number/string, the type error reports the error but prints the type of the first argument: > complex({1:2},1j) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: complex() argument must be a string or a number, not 'dict' >complex(1j,{1:2}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: complex() argument must be a string or a number, not 'complex' >>> complex(1, {1:2}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: complex() argument must be a string or a number, not 'int' | |||
| msg276954 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-19 08:20 | |
Contains changes made toObjects/complexobject.cChanged the error message returned when second argument of complex() is not number/stringOriginally:>complex(1j,{1:2}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: complex() argument must be a string or a number, not 'complex'After patch:>complex(1j,{1:2}) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: complex() argument must be a string or a number, not 'dict' | |||
| msg276958 -(view) | Author: Berker Peksag (berker.peksag)*![]() | Date: 2016-09-19 08:44 | |
Please upload your patch from a Mercurial clone:*https://docs.python.org/devguide/setup.html#checkout*https://docs.python.org/devguide/patch.htmlCurrently, if you pass a string as a second argument, you get:>>> complex(1, "1")Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: complex() second arg can't be a stringSo the exception message should probably be changed to include "second arg" or "second argument":>>> complex(1j, {1: 2})Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: complex() second arg must be a number, not 'dict'Also, there is already a check for second argument in line 952 so the "must be a string" part is probably not needed. We probably need to check whether these two cases can be combined.You also need to add some tests toLib/test/test_complex.py. | |||
| msg276970 -(view) | Author: Mark Dickinson (mark.dickinson)*![]() | Date: 2016-09-19 11:04 | |
@manishearth: Nice catch! Thanks for the report.@soummyaah: Thanks for the patch. Please could you sign a contributor agreement[1], so that we can commit the patch? As Berker says, tests would be good to have, too.[1]https://www.python.org/psf/contrib/contrib-form/ | |||
| msg276972 -(view) | Author: Mark Dickinson (mark.dickinson)*![]() | Date: 2016-09-19 11:48 | |
This should be fixed in Python 3.5, too. | |||
| msg277003 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-20 04:00 | |
I've signed the contributor agreement form. I think it said that it'll take a few days to process?I've made the changes requested and am currently working on the tests. Will submit a new patch file containing all required changes soon. | |||
| msg277013 -(view) | Author: Mark Dickinson (mark.dickinson)*![]() | Date: 2016-09-20 06:22 | |
Thank you! I look forward to the new patch. | |||
| msg277022 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-20 12:03 | |
Changed error message to:>>> complex({1:2},1)Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: complex() first arg must be a string or a number, not 'dict'>>> complex(1j, {1: 2})Traceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: complex() second arg must be a number, not 'dict'Added tests to check the error raised. | |||
| msg277023 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-20 12:05 | |
Apologies. This is the correct file. | |||
| msg277025 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-20 12:32 | |
Squashed the commits for better readability.Also, change required in Python 3.4 as well | |||
| msg277026 -(view) | Author: Berker Peksag (berker.peksag)*![]() | Date: 2016-09-20 12:37 | |
Thanks for the patch. We can't fix this in 3.4 because it's in security-fix-only mode:https://docs.python.org/devguide/index.html#status-of-python-branches | |||
| msg277108 -(view) | Author: Mark Dickinson (mark.dickinson)*![]() | Date: 2016-09-21 07:55 | |
Thanks. I'll apply this shortly (but probably not before the weekend). | |||
| msg277318 -(view) | Author: Roundup Robot (python-dev)![]() | Date: 2016-09-24 14:29 | |
New changeset92f4ce2d5ebb by Mark Dickinson in branch '3.5':Issue#28203: Fix incorrect type in error message from complex(1.0, {2:3}). Patch by Soumya Sharma.https://hg.python.org/cpython/rev/92f4ce2d5ebbNew changeseta2d93e6bcbcf by Mark Dickinson in branch '3.6':Issue#28203: Merge from 3.5https://hg.python.org/cpython/rev/a2d93e6bcbcfNew changeset9790bc211107 by Mark Dickinson in branch 'default':Issue#28203: Merge from 3.6https://hg.python.org/cpython/rev/9790bc211107 | |||
| msg277319 -(view) | Author: Mark Dickinson (mark.dickinson)*![]() | Date: 2016-09-24 14:32 | |
Fixed; thanks. I made a couple of changes:- Use "argument" rather than "arg", to be consistent with the original code (but admittedly not consistent with the rest of the module, where there doesn't seem to be any consistent choice between "arg" and "argument").- Reformat C and test code to avoid long lines.- Slight rearrangement of the C code so that all of the "i" handling is in one place. | |||
| msg277353 -(view) | Author: Soumya Sharma (soummyaah)* | Date: 2016-09-25 09:49 | |
Thanks for the merge! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:37 | admin | set | github: 72390 |
| 2017-03-31 16:36:39 | dstufft | set | pull_requests: +pull_request1112 |
| 2016-09-25 09:49:42 | soummyaah | set | messages: +msg277353 |
| 2016-09-24 14:32:59 | mark.dickinson | set | status: open -> closed resolution: fixed messages: +msg277319 stage: patch review -> resolved |
| 2016-09-24 14:29:23 | python-dev | set | nosy: +python-dev messages: +msg277318 |
| 2016-09-21 07:55:56 | mark.dickinson | set | assignee:mark.dickinson messages: +msg277108 |
| 2016-09-20 12:37:13 | berker.peksag | set | messages: +msg277026 versions: - Python 3.4 |
| 2016-09-20 12:32:13 | soummyaah | set | files: +Issue28203#4.patch messages: +msg277025 versions: + Python 3.4 |
| 2016-09-20 12:05:01 | soummyaah | set | files: +Issue28203#3.patch messages: +msg277023 |
| 2016-09-20 12:04:17 | soummyaah | set | files: -Issue28203#2.patch |
| 2016-09-20 12:03:09 | soummyaah | set | files: +Issue28203#2.patch messages: +msg277022 |
| 2016-09-20 06:22:53 | mark.dickinson | set | messages: +msg277013 |
| 2016-09-20 04:00:49 | soummyaah | set | messages: +msg277003 |
| 2016-09-19 11:48:27 | mark.dickinson | set | messages: +msg276972 versions: + Python 3.5 |
| 2016-09-19 11:04:51 | mark.dickinson | set | messages: +msg276970 |
| 2016-09-19 08:44:40 | berker.peksag | set | nosy: +berker.peksag messages: +msg276958 |
| 2016-09-19 08:23:39 | SilentGhost | set | stage: patch review type: enhancement -> behavior versions: + Python 3.6 |
| 2016-09-19 08:20:57 | soummyaah | set | files: +Issue28203.patch nosy: +soummyaah messages: +msg276954 hgrepos: + hgrepo356 keywords: +patch |
| 2016-09-19 08:09:29 | serhiy.storchaka | set | nosy: +mark.dickinson,serhiy.storchaka |
| 2016-09-19 07:41:45 | manishearth | create | |