Bugs item #889500, was opened at 2004-02-02 20:39 Message generated for change (Comment added) made by nnorwitz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=889500&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Parser/Compiler >Group: Python 2.5 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Jeff Connelly aka shellreef (jeffconnelly) >Assigned to: Neal Norwitz (nnorwitz) Summary: Line 0 SyntaxWarning with duplicate global declarations Initial Comment: global a a = "b" global a a.py:0: SyntaxWarning: name 'a' is assigned to before global declaration This is a fairly minor bug, however, the message is misleading (the variable is in fact assigned to both before and after the global declaration). At least, the line number should be fixed to refer to the second declaration, and if possible the error message should be changed to "duplicate global declaration of 'a'". P.S.: If "global a" is repeated multiple times, the error message will be repeated, with the same line number, and no indication that the warning refers to a different line. ---------------------------------------------------------------------- >Comment By: Neal Norwitz (nnorwitz) Date: 2005-12-18 20:28 Message: Logged In: YES user_id=33168 Fixed for 2.5. Thanks for the bug report. Committed revision 41767. ---------------------------------------------------------------------- Comment By: Terry J. Reedy (tjreedy) Date: 2004-02-13 14:47 Message: Logged In: YES user_id=593130 >if possible the error message should be changed to "duplicate global declaration of 'a'". The ref man does not prohibit duplicate declarations, nor is duplication essential to get the misleading line number: >>> def f(): ... global a ... b = 0 ... global b ... <stdin>:1: SyntaxWarning: name 'b' is assigned to before global declaration It appears that compiler treats additional global declarations as continuations of first and only stores one line #, the first, for the 'combined' declaration. If code is too difficult to change, perhaps ref man could make note of this ;-) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=889500&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com