This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: builtin file() vanishes
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: barry-scott, loewis, tim.peters
Priority: normal Keywords:

Created on 2005-02-08 23:42 by barry-scott, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
filebug.tar barry-scott, 2005-02-08 23:42 tar file used to reproduce the bug
Messages (3)
msg24201 - (view) Author: Barry Alan Scott (barry-scott) * Date: 2005-02-08 23:42
The attached files reproduce a wierd problem where by
the builtin file() function completely vanishes from
python.
Notice that __builtin__ changes type from module to dict.

In the attached tar files find:
   manufacture    - main program
   bob.py            - module
   a.a                 - file to open

Untar and run:

python manufacture

Notice that file()is no ware to be found in side of bob.py

This runs the same on all 2.3 and 2.4 on Windows, Linux
and Mac OS X.
msg24202 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-02-09 03:51
Logged In: YES 
user_id=31435

No, __builtins__ (note the trailing 's') changes type from 
module to module, not __builtin__.  __builtins__ is an 
implementation detail, and you shouldn't use it at all.  
__builtin__ (no trailing 's') is a built-in module, and you're free 
to use that, but then you have to import it explicitly:

import __builtin__
__builtin__.file

There's more in the Language (not Library) reference manual, 
in the section "Naming and Binding".
msg24203 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-02-10 00:02
Logged In: YES 
user_id=21627

As Tim says, __builtins__ is a dictionary sometimes.
Therefore, it is no surprise that __builtins__.file does not
exist - dictionaries don't have a file attribute. As this is
apparently what you meant when you said that file()
"vanishes", I'm closing the report as invalid.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41549
2005-02-08 23:42:00barry-scottcreate