[Python-3000] Warning for 2.6 and greater
Anthony Baxter
anthony at interlink.com.au
Mon Jan 8 08:43:43 CET 2007
On Monday 08 January 2007 16:50, Anthony Baxter wrote:
> I've been thinking a little about how and where we'd add warnings
> to 2.6 and later for things that will break in 3.0. My first idea
> is to add a command line option '-3' (or maybe '-warn3')
> implemented as "from __future__ import py3k". We can then put
> code in that optionally generates a warning if this is set.
Ok, I lied - I implemented this pretty easily just now (patch
attached). As a first pass, I put in warnings for dict.has_key and
the builtin apply() function.
I've changed my mind about the from future statement. I think that
'from __future__ import py3k' says "please use whatever backwards
incompatible 3.x features that you support". I guess we could have
something like 'from __future__ import warn3k', perhaps. But this
wouldn't take effect for just the current source file, so could be
confusing.
If people are happy with this, I'll check it into the trunk, then
people can go crazy adding other warnings for 3.0-isms.
beaker% ./python
Python 2.6a0 (trunk:53285:53286M, Jan 8 2007, 18:34:47)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> 1 in {}
False
>>> {}.has_key(1)
False
>>> apply(lambda x:None, (1,))
>>>
beaker% ./python -3
Python 2.6a0 (trunk:53285:53286M, Jan 8 2007, 18:34:47)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> 1 in {}
False
>>> {}.has_key(1)
__main__:1: DeprecationWarning: dict.has_key not supported in 3.x
False
>>> apply(lambda x:None, (1,))
__main__:1: DeprecationWarning: apply() not supported in 3.x
>>>
Anthony
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warn3.patch
Type: text/x-diff
Size: 4039 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20070108/a6169da6/attachment.bin
More information about the Python-3000
mailing list