[Python-Dev] Those import related syntax errors again...

Thomas Wouters thomas@xs4all.net
Wed, 21 Feb 2001 07:47:10 +0100


On Tue, Feb 20, 2001 at 10:29:36PM -0500, Andrew Kuchling wrote:

> Let's not waffle.  If nested scopes are worth doing, they're worth
> breaking code.

I'm sorry, but that's bull -- I mean, I disagree completely. Nested scopes
*are* a nice feature, but if we can't do them without breaking code in weird
ways, we shouldn't, or at least *not yet*. I am still uneasy by the
restrictions seemingly created just to facilitate the implementation issues
of nested scopes, but I could live with them if they had been generating
warnings at least one release, preferably more.

I'm probably more conservative than most people here, in that aspect, but I
believe I am right in it ;) Consider the average Joe User attempting to
upgrade. He has to decide whether any of his scripts suffer from the
upgrade, and then has to figure out how to fix them. In a case like Mark
had, he is very likely to just give up and not upgrade, cursing Python while
he's doing it. 

Now consider a site admin (which I happen to be,) who has to make that
decision for all the people on the site -- which can be tens of thousands of
people. There is no way he is going to test all scripts, he is lucky to know
who even *uses* Python. He can probably live with a clean error that is an
obvious fix; that's part of upgrading. Some weird error that doesn't point
to a fix, and a weird, inconsequential fix in the first place isn't going to
make him confident in upgrading.

Now consider a distribution maintainer, who has to make that decision for
potentially millions, many of which are site maintainers. He is not a happy
camper.

I was annoyed by the socket.socket() change in 2.0, but at least we could
pretend 1.6 was a real release and that there was a lot of advance warning.
In this case, however, we had several instances of the 'bug' in the standard
library itself, which a lot of people use as code examples. I have yet to
see a book or tutorial that lists from-foo-import-* in a local scope as
illegal, and I have yet to see *anything* that lists 'exec' (not 'in'
something) in a local scope as illegal. Nevertheless, those two will seem to
be breaking the code now.

> Either leave exec and from..import illegal, or back
> out nested scopes, or think of some better solution, but let's not
> introduce complicated backward compatibility hacks.

We already *have* complicated backward compatibility hacks, though they are
masked as optimizations now. from-foo-import-* and exec are legal in a
function scope as long as you don't have a nested scope that references a
non-local name.

-- 
Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!