Title: Use of builtin file should give Py3k warning
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: benjamin.peterson, gvanrossum
Priority: normal Keywords: patch

Created on 2008-03-18 00:13 by benjamin.peterson, last changed 2008-03-18 01:07 by benjamin.peterson. This issue is now closed.

File name Uploaded Description Edit
file_warning.patch benjamin.peterson, 2008-03-18 00:13 gives file a warning
Messages (4)
msg63814 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-03-18 00:13
This patch causes the use of builtin file to give a Py3k warning.

When Python starts up, distutils.text_file gives a warning because it
uses a variable named file. I imagine there are places like this all
over in the stdlib, which should be renamed fp or something similar.
msg63821 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 00:34
I'll review this.  My hunch is that we don't need this -- 2to3 takes
care of this so there is no reason to tell people to change their code
by hand. 

(You may notice a pattern -- things that 2to3 can fix easily generally
don't deserve -3 warnings or backports, *unless* the backported feature
adds significant functionality that's not easily available otherwise in
msg63826 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-03-18 00:44
Let's not do this. This approach is not sufficiently backwards
compatible; it will break any code that uses isinstance(x, file).  Even
though that's not forward compatible with 3.0, it works in 2.5 and
before, so it should not break in 2.6.  Together with my previous remark
this means that we should just not mess with this.

(PS: I don't understand what you say about distutils.text_file -- from
your patch it looks like the only way it can issue this warning is if it
actually calls the file() builtin...)
msg63835 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-03-18 01:07
Yeah, breaking isinstance(x, file) would be bad and 2to3 can do this
automatically. I should probably learn how to write fixers. BTW, the
warning culprit was actually which used file.
Date User Action Args
2008-03-18 01:07:39benjamin.petersonsetmessages: + msg63835
2008-03-18 00:44:10gvanrossumsetstatus: open -> closed
resolution: rejected
messages: + msg63826
2008-03-18 00:34:37gvanrossumsetpriority: normal
assignee: gvanrossum
messages: + msg63821
nosy: + gvanrossum
2008-03-18 00:13:52benjamin.petersoncreate