-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
create Python wrappers for openat() and others #49011
Comments
Very recent POSIX versions have introduced a set of functions named (*) http://www.opengroup.org/onlinepubs/9699919799/functions/openat.html “The purpose of the openat() function is to enable opening files in |
There is a tradition that any POSIX calls are added to the POSIX module So contributions are welcome. |
The openat() functions sound useful indeed. However I'm concerned about I propose the addition of opendir() for the purpose of the *at() |
I'm not concerned about that. When they use os.open, they will typically
-1. This is exactly the second-guessing kind of thing that the POSIX If desired, a layer can be added on top of this that makes it more |
Attached is a patch that adds: Each function has documentation and a unit test and is conditionally included only if the functions exist using autoconf testing. Most of the code for the functions and unit tests was taken from the corresponding non-at versions. Tested on Linux 2.6.35 and FreeBSD 8.1 (although FreeBSD 8.1 does not have utimensat). This should then allow a patch for bpo-4489 to be created. |
Thanks for the patch. A couple of comments:
(I haven't looked at the C code in detail since you say it's mostly copy/paste from existing code) |
Attached is an updated patch which:
|
The docs shouldn't use "[" to denote optional args. Rather, optional arguments can just be shown by their defaults. |
Ok, attached is a patch with the documentation updated as per recommendation. |
Reference counting is not always correct. For example, in unlinkat if (res < 0)
return posix_error();
Py_DECREF(opath);
(return None) the DECREF should be before the error check. (Note that you can use the Py_RETURN_NONE macro to save INCREF'ing Py_None explicitly.) Sometimes you use posix_error, sometimes posix_error_with_allocated_filename; is that deliberate? Also, the documentation for each function should get ".. versionadded:: 3.3" tags. Otherwise, this looks good and ready for inclusion when py3k is open for new features again. |
New patch *should* have fixed up reference counting and version tags. I standardized all the error calls to posix_error. |
Thanks for the update! Three more comments:
|
This new patch has proper octal mode strings and another doc update. I'll leave faccessat until bpo-10758 has been resolved. |
Fixed small #ifdef error with fstatat. |
I have committed the patch in r88624. Thank you! |
What about Doc/whatsnew/3.3.rst? |
This is filled by Raymond (or other people) when the release nears. |
Why use a special value AT_FDCWD instead of None? It is not Pythonish. Clearly, when it is used in C, but in dynamically typed Python we are not limited to only one C-type. Such a large number of new functions littering the namespace. Why not just add additional arguments to existing functions? Instead 'fstatat(dirfd, path, flags=0)' let it be 'stat(path, *, dirfd=None, flags=0)' or even better 'stat(path, *, dirfd=None, followlinks=True)' (as in os.fwalk). |
I agree about the constant AT_FDCWD. (At least, None should be allowed in addition.) Your other proposition would break the principle of very thin platform wrappers that we try to follow in posixmodule.c. |
Addition/Substitution of None I think should be in a new issue. |
Perhaps it is better not export these functions in the In addition, |
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: