On 07/25/2013 11:45 AM, Maciej Fijalkowski wrote:
On Wed, Jul 24, 2013 at 7:22 PM, Laurent Gautier <lgaut...@gmail.com> wrote:
On 07/24/2013 06:30 PM, Chris Angelico wrote:
On Thu, Jul 25, 2013 at 2:21 AM, Laurent Gautier <lgaut...@gmail.com>
wrote:
- errors that are typical of "Python 2 script running with Python
3"-specific are probably limited (e.g., use of unicode, use of xrange,
etc...)

The most common, in interactive scripts at least, is likely to be:

print "Hello, world!"
SyntaxError: invalid syntax

How helpful it's possible to make that one, I don't know. Is it safe
to presume that it's more likely a syntax error will come from an
interpreter version mismatch than a code bug?

The wrapper in /usr/bin/python:
- could use what is in 2to3. I think that most of the cases are solved
there.
- whenever interactive, could have an intermediate layer between the input
in the console and execution.
So you suggest that instead of a clear SyntaxError you should end up
with a confusing error (something has no attribute xyz or so) after a
while (if say somone tries to load twisted via 2to3).

In a sense, yes.

I think that the a priori (expectations) a user has plays a role in whether something is confusing or not.
Consider the two following situations:
- a programmer is working on code, and is testing it. If the program fails, this is because he/she made a mistake and the error message should indicate where the error originates from - a user is running a python script (he expects to be working), and is using the default /usr/bin/python (formerly Python 2, now Python 3). If the program fails because of obvious Python 2-only idioms, reporting this rather that the SyntaxError is much less confusing.

Having that said, the comments are pointing out that this is may be not a completely good idea (most notably because of how slow 2to3 is). A wrapper producing an unconditional warning about the default python being changed to Python 3, and differences between Python 2 and Python 3 the possible source of errors, (as I think it was suggested) is going to be a better idea.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to