On 1/12/07, A.M. Kuchling <[EMAIL PROTECTED]> wrote: > Forwarded for discussion from http://www.python.org/sf/1633665. > > --amk > > [forwarded from http://bugs.debian.org/327060] > > Many types in Python are idempotent, so that int(1) works > as expected, float(2.34)==2.34, ''.join('hello')=='hello' > et cetera. > > Why not file()? Currently, file(open(something, 'r')) fails > with "TypeError: coercing to Unicode: need string or buffer, file found." > > Semantically, file(fd) should be equivalent to os.fdopen(fd.fileno()) > or the proposed file.fromfd() (Jp Calderone, Python-dev, 2003). > You should get another independent > file object that accesses the same file. >
For security reasons I might be asking for file's constructor to be removed from the type for Python source code at some point (it can be relocated to an extension module if desired). By forcing people to go through open() to create a file object you can more easily control read/write access to the file system (assuming the proper importation of extension modules has been blocked). Not removing the constructor allows any code that has been explicitly given a file object but not open() to just get the class and call the constructor to open a new file. Don't know when I am gonig to get around to asking for it, though (still have to finish my security work to have something to present to python-dev). -Brett _______________________________________________ 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