[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python 2.7 status on Ubuntu Maverick



On Jul 27, 2010, at 12:33 AM, Jakub Wilk wrote:

>In sid there are two packages with python2.7-specific bytecompilation
>errors: mgltools-viewerframework and python-jaxml. Both packages do
>something like:
>
>import sys
>sys.__debug__ = something
>
>which is a syntax error in Python 2.7.

This one's really interesting.

% python2.6
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> __debug__ = 1
  File "<stdin>", line 1
SyntaxError: can not assign to __debug__
>>> import sys
>>> sys.__debug__ = 1
>>> 
% python2.7
Python 2.7.0+ (release27-maint:83294, Jul 30 2010, 15:49:51) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> __debug__ = 1
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> import sys
>>> sys.__debug__ = 1
  File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> 

So assignment to global __debug__ has been a SyntaxError since 2.6 (at least),
but it now appears that the parser is more strict.  It's not that __debug__ is
a reserved word though because assignment to e.g. sys.print gives you a
different SyntaxError.

I don't see a specific item describing this in the Python 2.7 Misc/NEWS file,
nor can I find a bug in the tracker for this issue, so I'm not sure if it's
intended behavior or not.  I think I'll raise this on python-dev before
working on a patch for Debian.

-Barry

Attachment: signature.asc
Description: PGP signature


Reply to: