[Python-Dev] Best Python API for exposing posix_spawn (original) (raw)

Brett Cannon brett at python.org
Mon Jan 8 14:35:26 EST 2018


On Mon, 8 Jan 2018 at 07:57 Pablo Galindo Salgado <pablogsal at gmail.com> wrote:

Hi,

I'm currently working on exposing posixspawn in the posix module (and by extension in the os module). You can find the initial implementation in this PR: https://github.com/python/cpython/pull/5109 As pointed out by Gregory P. Smith, some changes are needed in the way the fileactions arguments is passed from Python. For context, posixspawn has the following declaration: int posixspawn(pidt *pid, const char *path, const posixspawnfileactionst *fileactions, const posixspawnattrt *attrp, char *const argv[], char *const envp[]); Here, fileactions is an object that represents a list of file actions (open, close or dup2) that is populated using helper functions on the C API. The question is: what is the best way to deal with this argument? Following Gregory's comment on the PR I understand that he is proposing to have three objects in the os module representing each action and pass a sequence of these objects to the Python API. What I am not sure about this is that there is no previous example of such classes in the os module for other similar APIs and therefore I am not sure if there is a better approach. Thanks you very much for your time!

Any chance of using an enum? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180108/81c604bc/attachment.html>



More information about the Python-Dev mailing list