Skip to content
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

posix_spawn explicit file_actions=None throws error #80995

Closed
MatthewTanous mannequin opened this issue May 6, 2019 · 7 comments
Closed

posix_spawn explicit file_actions=None throws error #80995

MatthewTanous mannequin opened this issue May 6, 2019 · 7 comments
Assignees
Labels
3.8 only security fixes stdlib Python modules in the Lib dir

Comments

@MatthewTanous
Copy link
Mannequin

MatthewTanous mannequin commented May 6, 2019

BPO 36814
Nosy @vstinner, @tonybaloney, @nanjekyejoannah
PRs
  • bpo-36814: ensure os.posix_spawnp handles Py_None #13144
  • 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:

    assignee = 'https://github.com/tonybaloney'
    closed_at = <Date 2019-05-10.02:01:01.766>
    created_at = <Date 2019-05-06.15:05:56.265>
    labels = ['3.8', 'library']
    title = 'posix_spawn explicit file_actions=None throws error'
    updated_at = <Date 2019-05-10.02:01:01.766>
    user = 'https://bugs.python.org/MatthewTanous'

    bugs.python.org fields:

    activity = <Date 2019-05-10.02:01:01.766>
    actor = 'vstinner'
    assignee = 'anthonypjshaw'
    closed = True
    closed_date = <Date 2019-05-10.02:01:01.766>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2019-05-06.15:05:56.265>
    creator = 'Matthew Tanous'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36814
    keywords = ['patch']
    message_count = 7.0
    messages = ['341522', '341659', '341661', '341663', '341664', '342036', '342038']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'Matthew Tanous', 'anthonypjshaw', 'nanjekyejoannah']
    pr_nums = ['13144']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36814'
    versions = ['Python 3.8']

    @MatthewTanous
    Copy link
    Mannequin Author

    MatthewTanous mannequin commented May 6, 2019

    Allowing posix_spawn file_actions to default to None works, but explicitly setting it throws a TypeError:

    Python 3.8.0a3 (v3.8.0a3:9a448855b5, Mar 25 2019, 17:05:20)
    [Clang 6.0 (clang-600.0.57)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> os.posix_spawnp('whoami', ['whoami'], os.environ, file_actions=None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: file_actions must be a sequence or None

    This required me to default to an empty sequence to complete it:

    >>> os.posix_spawnp('whoami', ['whoami'], os.environ, file_actions=[])
    6308

    @MatthewTanous MatthewTanous mannequin added 3.8 only security fixes stdlib Python modules in the Lib dir labels May 6, 2019
    @tonybaloney
    Copy link
    Mannequin

    tonybaloney mannequin commented May 6, 2019

    Verified on master
    Python 3.8.0a3+ (heads/bpo-28367:373c7aa098, May  6 2019, 17:34:39) 
    [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> os.posix_spawnp('whoami', ['whoami'], os.environ, file_actions=None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'os' is not defined
    >>> import os
    >>> os.posix_spawnp('whoami', ['whoami'], os.environ, file_actions=None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: file_actions must be a sequence or None

    @tonybaloney
    Copy link
    Mannequin

    tonybaloney mannequin commented May 6, 2019

    Issue is in parse_file_actions

    parse_file_actions(PyObject *file_actions,
                       posix_spawn_file_actions_t *file_actionsp,
                       PyObject *temp_buffer)
    {
        PyObject *seq;
        PyObject *file_action = NULL;
        PyObject *tag_obj;
    
        seq = v(file_actions,
                              "file_actions must be a sequence or None");
        if (seq == NULL) {
            return -1;
        }

    PySequence_Fast will raise a TypeError if PyObject_GetIter fails.

    @tonybaloney tonybaloney mannequin self-assigned this May 6, 2019
    @tonybaloney
    Copy link
    Mannequin

    tonybaloney mannequin commented May 6, 2019

    Raised a fix in #57353

    @tonybaloney
    Copy link
    Mannequin

    tonybaloney mannequin commented May 6, 2019

    After patch:

    Python 3.8.0a3+ (heads/31968-dirty:c664b342a4, May  6 2019, 18:06:21) 
    [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> os.posix_spawnp('whoami', ['whoami'], os.environ, file_actions=None)
    17300
    >>> anthonyshaw

    @vstinner
    Copy link
    Member

    New changeset 948ed8c by Victor Stinner (Anthony Shaw) in branch 'master':
    bpo-36814: ensure os.posix_spawn() handles None (GH-13144)
    948ed8c

    @vstinner
    Copy link
    Member

    Matthew Tanous: Oops, I completely missed this case! Thanks for the bug report.

    Thanks Anthony Shaw for the fix.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant