[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

Unfortunately there's not much that can be done about this. The code that 
writes that error message only knows about objects, which don't have names, 
only types and values.

--

___
Python tracker 

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



[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Jason Schwefel


Jason Schwefel  added the comment:

>What do you expect to gain with the "int = ''" statement?

I did not expect anything. I made a mistake in my initial code and the error 
message indicated that I rebound 'str'. I could not find where I had used 'str' 
as a variable name. If it would have said 'int', as that was the function that 
I rebound as a variable name, I would have immediately known what to look for.

I understand that it is mostly cosmetic, but I am sure I am not the first 
person that went down the wrong path because of this. 

I understand that I was using the variable named 'int' as a string and 
therefore referencing it as 'str' object is technically correct. However, I am 
still relatively new to Python, as many others are, and the the error message 
could be a bit more clear.

--

___
Python tracker 

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



[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Closing as "not a bug".

--
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> 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



[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

I should point out that this is the same as doing:

>>> ''()
:1: SyntaxWarning: 'str' object is not callable; perhaps you missed a 
comma?
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'str' object is not callable

Except for the SyntaxWarning part, where the compiler is trying to be helpful.

--

___
Python tracker 

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



[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Eric V. Smith


Eric V. Smith  added the comment:

You've rebound "int" to a string. I think the error message is correct.

Here's a simpler case:

>>> int = ''
>>> int
''
>>> int()
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'str' object is not callable

What do you expect to gain with the "int = ''" statement?

--
nosy: +eric.smith

___
Python tracker 

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



[issue42118] TypeError gives wrong reserved name

2020-10-22 Thread Jason Schwefel


New submission from Jason Schwefel :

The following code gives a "TypeError: 'str' object is not callable" exception:

int = ''
s = '3500:day'
a = s.split(':')
i = int(a[0])

Proper exception message should be "TypeError: 'int' object is not callable" 

Only able to test on 3.8 and 3.9

--
components: Interpreter Core
messages: 379300
nosy: jason.schwefel78
priority: normal
severity: normal
status: open
title: TypeError gives wrong reserved name
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

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