[Python-Dev] Re: A few small issues

Tim Peters tim.one@home.com
Wed, 28 Feb 2001 18:21:15 -0500


[Ka-Ping Yee]
> On Tue, 27 Feb 2001, Ka-Ping Yee wrote:
> >
> > 1.  The error message for UnboundLocalError isn't really accurate.
> [...]
> >         UnboundLocalError: local name 'x' is not defined
>
> I'd like to check in this change today to make it into the beta.
> It's a tiny change, shouldn't break anything as i don't see how
> code would rely on the wording of the message, and makes the
> message more accurate.  Lib/test/test_scope.py checks for the
> error but does not rely on its wording.
>
> If i don't see objections i'll do this tonight.  I hope this is
> minor enough not to be a violation of etiquette.

Sorry, but I really didn't like this change.  You had to contrive a test case
using "del" for the old

    local variable 'x' referenced before assignment

msg to appear inaccurate the way you read it.  The old msg is much more
on-target 99.999% of the time than just saying "not defined", in
non-contrived test cases.  Even in the  "del" case, it's *still* the case
that the vrbl was referenced before assignment (but after "del").

So -1, on the grounds that the new msg is worse (because less specific)
almost all the time.