[Patches] [ python-Patches-608182 ] Enhanced file constructor

SourceForge.net noreply@sourceforge.net
Thu, 08 May 2003 19:32:41 -0700


Patches item #608182, was opened at 2002-09-11 22:45
Message generated for change (Comment added) made by taral
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=608182&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Taral (taral)
Assigned to: Nobody/Anonymous (nobody)
Summary: Enhanced file constructor

Initial Comment:
This patch allows the file constructor to take a file
descriptor, allowing for  much easier extension of its
functionality.

----------------------------------------------------------------------

>Comment By: Taral (taral)
Date: 2003-05-08 21:32

Message:
Logged In: YES 
user_id=25129

I have a very good reason! Without it, there are file
objects that CANNOT be subclassed, specifically those
created via os.fdopen.

Yes, I am _still_ waiting for this to go in. Do I need to do
something else on some mailing list to get people to notice it?

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2003-05-08 20:09

Message:
Logged In: YES 
user_id=357491

This functionality has still not made it into 2.3b1 .  If no one speaks up and 
comes up with a good argument to apply this by May 15 I am going to reject 
this patch.

----------------------------------------------------------------------

Comment By: Taral (taral)
Date: 2003-01-31 14:12

Message:
Logged In: YES 
user_id=25129

Didn't make it into 2.3alpha?

----------------------------------------------------------------------

Comment By: Taral (taral)
Date: 2002-09-12 13:39

Message:
Logged In: YES 
user_id=25129

class some_class(file):
    def __init__(self, arg):
        fd = do_some_os_stuff_with_forks_and_pipes_or_sockets
        return file.__init__(self, fd, 'r')

    def close(self):
        do_some_cleanup_stuff
        return file.close(self)

and so on.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-09-12 01:59

Message:
Logged In: YES 
user_id=21627

What's wrong with os.fdopen? Why is

f = file(10, "r")

much easier than

f = os.fdopen(10, "r")

----------------------------------------------------------------------

Comment By: Taral (taral)
Date: 2002-09-12 00:31

Message:
Logged In: YES 
user_id=25129

Okay, fixed it all. Passes 'make test' on linux/x86 with
default configure (does not test dbm/gdbm/mpz/bsddb).

(btw, old versions can be deleted)

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-09-11 23:10

Message:
Logged In: YES 
user_id=33168

fp's and fd's are not interchangable.  The variable should
be called fd, since it's an int.  fill_file_fields() 2nd arg
is a FILE*, not an int.  So you would need to do file =
fdopen(fd, mode), then pass file as the 2nd arg.  In order
for this patch to be accepted, a test would also need to be
added (see Lib/test/test_file.py) and doc should be updated
(see Doc/lib/libfuncs.tex).

----------------------------------------------------------------------

Comment By: Taral (taral)
Date: 2002-09-11 22:47

Message:
Logged In: YES 
user_id=25129

Bah, forgot the variable.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=608182&group_id=5470