Issue608182
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.
Created on 2002-09-12 03:45 by taral, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
file.diff | taral, 2002-09-12 03:45 | Patch to src/Objects/fileobject.c | ||
file.diff | taral, 2002-09-12 03:47 | Patch to src/Objects/fileobject.c (second try) | ||
file.diff | taral, 2002-09-12 05:31 | Fully tested patch + test + docs |
Messages (15) | |||
---|---|---|---|
msg41132 - (view) | Author: Taral (taral) | Date: 2002-09-12 03:45 | |
This patch allows the file constructor to take a file descriptor, allowing for much easier extension of its functionality. |
|||
msg41133 - (view) | Author: Taral (taral) | Date: 2002-09-12 03:47 | |
Logged In: YES user_id=25129 Bah, forgot the variable. |
|||
msg41134 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2002-09-12 04:10 | |
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). |
|||
msg41135 - (view) | Author: Taral (taral) | Date: 2002-09-12 05:31 | |
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) |
|||
msg41136 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-09-12 06:59 | |
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") |
|||
msg41137 - (view) | Author: Taral (taral) | Date: 2002-09-12 18:39 | |
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. |
|||
msg41138 - (view) | Author: Taral (taral) | Date: 2003-01-31 20:12 | |
Logged In: YES user_id=25129 Didn't make it into 2.3alpha? |
|||
msg41139 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-05-09 01:09 | |
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. |
|||
msg41140 - (view) | Author: Taral (taral) | Date: 2003-05-09 02:32 | |
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? |
|||
msg41141 - (view) | Author: Tim Peters (tim.peters) * | Date: 2003-05-09 03:53 | |
Logged In: YES user_id=31435 You do need to convince people it's a good idea. I cringe for two reasons: it mixes up a higher-level facility with a lower-level one; and, in a language with dynamic typing, it's *helpful* that file(xyz, 'w') raises TypeError today when the runtime type of xyz is an integer. This catches a serious error before it can harm files. I'd dislike losing that error detection more than I'd like the new facility this offers. Perhaps I'm in a small minority, though, in which case a discussion on comp.lang.python could reveal that. Someone there will point out that while you can't get what you want directly via subclassing file today, you can get the effect via containment and a __getattr__ hook (to delegate the file methods you don't want to intercept to the contained file object). That covers cases this patch doesn't, too, such as file objects returned by os.popen() (i.e., even with this patch, there are still "file objects that CANNOT be subclassed"). |
|||
msg41142 - (view) | Author: Taral (taral) | Date: 2003-05-09 16:37 | |
Logged In: YES user_id=25129 Okay, you have a good point. I could convert it to this format: file(filename[, mode[, buffering[, fd]]]) or file(filename[,mode[, buffering]][, fd=fd]) That should satisfy the type requirement. I kind of prefer the keyword version, but that's just me. I know about the containment solution, but I can't pass containers to functions that expect isinstance(arg, file). (As for os.popen, that's happens to be why I made this patch in the first case. I needed to extend popen functionality, and this was the minimum way to do it without violating the above isinstance requirement.) |
|||
msg41143 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-06-01 21:21 | |
Logged In: YES user_id=357491 Has a discussion comp.lang.python occured to judge the demand for this feature? |
|||
msg41144 - (view) | Author: Taral (taral) | Date: 2003-06-02 19:33 | |
Logged In: YES user_id=25129 No, I don't have usenet access. |
|||
msg41145 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2003-06-03 04:47 | |
Logged In: YES user_id=357491 You can use groups.google.com or python-list@python.org. |
|||
msg41146 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2003-10-31 13:51 | |
Logged In: YES user_id=21627 I'm rejecting the patch, on grounds that nobody sees any need for it but the submitter. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:40 | admin | set | github: 37171 |
2002-09-12 03:45:19 | taral | create |