This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r, kolia, steven.daprano
Date 2019-07-11.22:30:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562884214.98.0.305307974905.issue37568@roundup.psfhosted.org>
In-reply-to
Content
I'm inclined to close as Not a Bug as well. I'm worried the expanded error message would confuse people when they simply failed to assign a variable, and make them try bad workarounds like adding global/nonlocal when it's not the problem, e.g.:

def foo(bar):
    if bar > 0:
        baz = 'a'
    elif bar < 0:
        baz = 'b'
    return baz

Even if baz exists in an outer scope, they almost certainly didn't intend to use it, they just didn't properly account for all the paths to ensure baz is initialized. Adding a global or nonlocal declaration would make calling with zero as the arg "work" if the function was called with a non-zero value first, but it wouldn't be correct. When the error message suggests a fix, people tend to do it without thinking critically (or understanding the underlying problem), which is worse than a message without a fix where solving it involves learning what it actually means.
History
Date User Action Args
2019-07-11 22:30:15josh.rsetrecipients: + josh.r, steven.daprano, kolia
2019-07-11 22:30:14josh.rsetmessageid: <1562884214.98.0.305307974905.issue37568@roundup.psfhosted.org>
2019-07-11 22:30:14josh.rlinkissue37568 messages
2019-07-11 22:30:14josh.rcreate