Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:
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. ---------- nosy: +josh.r _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37568> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com