[issue28203] complex() gives wrong error when the second argument has an invalid type

2017-03-31 Thread Donald Stufft

Changes by Donald Stufft :


--
pull_requests: +1112

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-25 Thread Soumya Sharma

Soumya Sharma added the comment:

Thanks for the merge!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-24 Thread Mark Dickinson

Mark Dickinson added the comment:

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.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-24 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 92f4ce2d5ebb 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/92f4ce2d5ebb

New changeset a2d93e6bcbcf by Mark Dickinson in branch '3.6':
Issue #28203: Merge from 3.5
https://hg.python.org/cpython/rev/a2d93e6bcbcf

New changeset 9790bc211107 by Mark Dickinson in branch 'default':
Issue #28203: Merge from 3.6
https://hg.python.org/cpython/rev/9790bc211107

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-21 Thread Mark Dickinson

Mark Dickinson added the comment:

Thanks. I'll apply this shortly (but probably not before the weekend).

--
assignee:  -> mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Berker Peksag

Berker Peksag added the comment:

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

--
versions:  -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Soumya Sharma

Soumya Sharma added the comment:

Squashed the commits for better readability.
Also, change required in Python 3.4 as well

--
versions: +Python 3.4
Added file: http://bugs.python.org/file44755/Issue28203#4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Soumya Sharma

Soumya Sharma added the comment:

Apologies. This is the correct file.

--
Added file: http://bugs.python.org/file44754/Issue28203#3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Soumya Sharma

Changes by Soumya Sharma :


Removed file: http://bugs.python.org/file44753/Issue28203#2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Soumya Sharma

Soumya Sharma added the comment:

Changed error message to:

>>> complex({1:2},1)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: complex() first arg must be a string or a number, not 'dict'

>>> complex(1j, {1: 2})
Traceback (most recent call last):
  File "", line 1, in 
TypeError: complex() second arg must be a number, not 'dict'

Added tests to check the error raised.

--
Added file: http://bugs.python.org/file44753/Issue28203#2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-20 Thread Mark Dickinson

Mark Dickinson added the comment:

Thank you! I look forward to the new patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Soumya Sharma

Soumya Sharma added the comment:

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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Mark Dickinson

Mark Dickinson added the comment:

This should be fixed in Python 3.5, too.

--
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Mark Dickinson

Mark Dickinson added the comment:

@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/

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Berker Peksag

Berker Peksag added the comment:

Please upload your patch from a Mercurial clone:

* https://docs.python.org/devguide/setup.html#checkout
* https://docs.python.org/devguide/patch.html

Currently, if you pass a string as a second argument, you get:

>>> complex(1, "1")
Traceback (most recent call last):
  File "", line 1, in 
TypeError: complex() second arg can't be a string

So the exception message should probably be changed to include "second arg" or 
"second argument":

>>> complex(1j, {1: 2})
Traceback (most recent call last):
  File "", line 1, in 
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 to Lib/test/test_complex.py.

--
nosy: +berker.peksag

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread SilentGhost

Changes by SilentGhost :


--
stage:  -> patch review
type: enhancement -> behavior
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Soumya Sharma

Soumya Sharma added the comment:

Contains changes made to Objects/complexobject.c
Changed the error message returned when second argument of complex() is not 
number/string
Originally:
>complex(1j,{1:2})
Traceback (most recent call last):
 File "", line 1, in 
TypeError: complex() argument must be a string or a number, not 'complex'

After patch:
>complex(1j,{1:2})
Traceback (most recent call last):
 File "", line 1, in 
TypeError: complex() argument must be a string or a number, not 'dict'

--
hgrepos: +356
keywords: +patch
nosy: +soummyaah
Added file: http://bugs.python.org/file44745/Issue28203.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +mark.dickinson, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28203] complex() gives wrong error when the second argument has an invalid type

2016-09-19 Thread Manish Goregaokar

New submission from Manish Goregaokar:

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 "", line 1, in 
TypeError: complex() argument must be a string or a number, not 'dict'
>complex(1j,{1:2})
Traceback (most recent call last):
 File "", line 1, in 
TypeError: complex() argument must be a string or a number, not 'complex'
>>> complex(1, {1:2})
Traceback (most recent call last):
  File "", line 1, in 
TypeError: complex() argument must be a string or a number, not 'int'

--
components: Library (Lib)
messages: 276952
nosy: Manish Goregaokar
priority: normal
severity: normal
status: open
title: complex() gives wrong error when the second argument has an invalid type
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com