-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Add attributes to os.stat results #35189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See bug bpo-111481, and PEP-0042. Both suggest that the With this patch, the os module will modify the The patch also modifies test_os.py to test the new In order to prevent old code from breaking, these new Backward compatibility: Code will only break if it |
Logged In: YES BTW, if this gets in, I have another patch that adds support |
Logged In: YES I second the request for supporting additional fields Consequently, I'd like to see this patch redone in C. The I have also my doubts about the naming of the fields. The |
Logged In: YES Martin: I'm not entirely sure what you mean here; while my I'm not sure it makes much sense to do this with pure C; it I agree that the field naming is suboptimal; I was taking my |
Logged In: YES On further consideration, the approach taken in the second |
Logged In: YES Here's the revised (example only) patch that takes the |
Logged In: YES Haven't had time to review the patch yet, but the idea of Regarding the field names: I think the field names should |
Logged In: YES The problem with your second and third patch is that it mode, ino, dev, nlink, uid, gid, size, a, c, m = To pass the additional fields, you already need your class |
Logged In: YES Ah! Now I see. I hadn't realized that anybody used the I'll try to write up a patch in C tonight or tomorrow |
Logged In: YES Using posix.stat is common, see http://groups.yahoo.com/group/python-list/message/4349 for examples. None of these would break with your change, If you are going to implement the type in C, I'd put it in tuple_with_attrs((value-tuple), (tuple-of-field-names), |
Logged In: YES I'm becoming more and more convinced that doing it in C is Is there some other appropriate place to put it in C? |
Logged In: YES There aren't actually so many copies of the module, since Still, putting the support type into a shared C file is |
Logged In: YES Or you could put it in modsupport.c, which is already a |
Logged In: YES Well, here's a posixmodule-only, all-C version. If this |
Logged In: YES And here's an even better all-C version. (This one doesn't |
Logged In: YES The patch looks good to me. Are you willing to revise it one
|
Logged In: YES I've fixed it with the suggestions you made, and also
I'm not sure I know how to cover Mac and RISCOS properly: If somebody with experience with these modules could let I'd also be glad to make any changes that would help |
Logged In: YES One comment on the patch: beautiful use of the new type >>> import os
>>> a = os.stat_result.__new__(os.stat_result, ())
>>> a.st_ctime
Segmentation fault (core dumped)
$ |
Logged In: YES Another comment: we should move this to its own file so that |
Logged In: YES I think this might be the one... or at least, the (1) moves the shared C code into a new module, "_stat", for Things to note: Because there are new files, I can't make 'cvs diff' get |
Logged In: YES Nick, what's your real email? I have a bunch of feedback |
Logged In: YES I've sent my email address to 'guido at python.org'. For |
Logged In: YES The fifth all-C (!) version, with changes as suggested by Big changes: This version no longer subclasses tuple. It now includes a patch for timemodule.c as well. So, how's *this* one? |
Logged In: YES If this goes in, I'd like to see it used for termios.tc I could probably implement this (but not *right* now...). |
Logged In: YES Patience, please. I'm behind reviewing this, probably won't |
Logged In: YES I'm looking at this now. |
Logged In: YES Thanks, Nick! Good job. Checked in, just in time for 2.2b1. I'm passing this |
Logged In: YES Here's a documentation patch for libos.tex. I don't know |
Logged In: YES This has been checked in, edited, and checked in again. |
Logged In: YES I know this patch is closed, but it seems a vaguely sane It's hard to pickle os.stat_results portably the way things |
Logged In: YES Adding all fields is both difficult and undesirable. It is What problem does that cause for pickling, and why would a |
Logged In: YES I'm not worried about cross version problems. The problem with pickling is that stat_results (as of today) If os.stat_result took 13 arguments everywhere, this problem |
Logged In: YES To support pickling, I think structseq objects should Alternatively, copy_reg could grow support for stat_result, Furthermore, fixing the number of arguments does not help at |
Logged In: YES Martin, I may not have been 100% clear in my last note, but cvs up Objects/structseq.c structseq objects *do* now implement a __reduce__ method, Hmm, the point about nt.stat_result is a good one. Getting support into copy_reg.py leads to interesting |
Logged In: YES I'd not put the copyreg support into copy_reg, but into As for constructing structseq objects from dictionaries: it |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: