[issue17032] Misleading error message: global name 'X' is not defined

2013-03-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f1d3fbcd837d by Ezio Melotti in branch 'default':
#17032: The global in the NameError: global name 'x' is not defined error 
message has been removed.  Patch by Ram Rachum.
http://hg.python.org/cpython/rev/f1d3fbcd837d

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-03 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

--
assignee:  - ezio.melotti
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-03 Thread Ram Rachum

Ram Rachum added the comment:

Awesome, thanks!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-02 Thread Ezio Melotti

Ezio Melotti added the comment:

Not yet, I wanted to make sure that everyone agrees on the change.
If I don't get other replies I'll commit it soon.

--
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-02 Thread Ram Rachum

Ram Rachum added the comment:

(I fixed the patch to not have a typo.)

--
Added file: 
http://bugs.python.org/file29290/cpython_patch1of1_8e9346e7ae87.patch.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-02 Thread Ram Rachum

Changes by Ram Rachum r...@rachum.com:


Removed file: 
http://bugs.python.org/file29006/cpython_patch1of1_8e9346e7ae87.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-02 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
stage: patch review - commit review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-03-02 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I just opened #17339 about another situation where the error message references 
only the last of several checks that failed.

bytes(object())  # raises
TypeError: 'object' object is not iterable  # or 4 other possibilities

I think any message like this should be fixed as noticed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-19 Thread Ezio Melotti

Ezio Melotti added the comment:

GLOBAL_NAME_ERROR_MSG has been introduced in fd8c7203251f as part of PEP 227 by 
Jeremy Hylton, so I'm adding him to the nosy to see if he agrees with the 
change (also adding a couple more devs to see if they have any comments).

There's also a typo in the last chunk of the patch.

--
nosy: +Jeremy.Hylton, ncoghlan, terry.reedy

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-19 Thread Philip Jenvey

Changes by Philip Jenvey pjen...@underboss.org:


--
nosy: +pjenvey

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-19 Thread Terry J. Reedy

Terry J. Reedy added the comment:

+NAME_ERROR_MSGy, name);
will give a NameError ;-).

The patch undoes the change from 'name' to 'global name'. Skimming the PEP, I 
do not see this change mandated or justified by the PEP. So my current view: 
while it is true that it is the final, global name lookup that fails, I agree 
with Ram that it is not necessarily a global name that was mistyped or is 
missing. So in absence of better justification of the status quo, I would apply 
the patch. Backport to 3.3 would be ok but not necessary, as the message is not 
nearly as wrong as some have been.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-08 Thread Ram Rachum

Ram Rachum added the comment:

I made a patch. Is it okay? (I don't normally use Mercurial nor work with 
patches.)

--
keywords: +patch
Added file: 
http://bugs.python.org/file29006/cpython_patch1of1_8e9346e7ae87.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-08 Thread Éric Araujo

Éric Araujo added the comment:

Patch looks good.  Does the test suite still pass?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-08 Thread Ram Rachum

Ram Rachum added the comment:

I don't program C at all. I have no idea how to compile Python or run the test 
suite. It took me half an hour just to produce this patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-08 Thread Éric Araujo

Éric Araujo added the comment:

If you’re using a programmer-friendly OS compiling is not hard.  See 
http://docs.python.org/devguide for instructions.  Otherwise somebody else will 
test the patch.  Thanks for your contribution!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-08 Thread Ram Rachum

Ram Rachum added the comment:

I think I'll go for option 2, thanks.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-02-01 Thread Ram Rachum

Ram Rachum added the comment:

Does fixing this ticket require anything more than making a change in the 
string that Python uses for this exception?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-01-25 Thread Ram Rachum

New submission from Ram Rachum:

Every single time I see the error message `global name 'X' is not defined` I 
say to myself, ah yeah, I mistyped a variable name.

But then it occurred to me, why should I have to do this mental translation 
from global name not defined to I mistyped a variable name?

Now, I'm not asking for the error message to say You mistyped a variable 
name, because that goes too much into second-guessing the user. But can we at 
least drop the reference to a global name? I understand that Python first 
searches the local namespace, and only then in the global namespace, and if the 
name isn't found there then an error is raised. But that doesn't mean that the 
error message should just assume that the variable is supposed to be global. 
It's misleading to say that a variable is global when it's in fact local.

I think that the error message should just say `Variable 'X' not defined`. 
Maybe add a suggestion `(Typo?)` at the end.


Example:

 def f():
... meow = 0
... return meoow
...
 f()
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in f
NameError: global name 'meoow' is not defined

I'd make the error message:

NameError: Variable 'meoow' is not defined

--
components: Interpreter Core
messages: 180591
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Misleading error message: global name 'X' is not defined
type: behavior
versions: Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-01-25 Thread Ezio Melotti

Ezio Melotti added the comment:

Maybe we could just drop the 'global'.

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-01-25 Thread Ramchandra Apte

Ramchandra Apte added the comment:

+1 on Ezio's idea.

--
nosy: +ramchandra.apte

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17032] Misleading error message: global name 'X' is not defined

2013-01-25 Thread Éric Araujo

Éric Araujo added the comment:

Dropping global sounds good.  (Let’s not replace name with variable though!)

--
nosy: +eric.araujo
versions:  -Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17032
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com