processutils python_exec arg cannot be None

Bug #1962603 reported by Brian Rosmaita
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.concurrency
Fix Released
Undecided
Brian Rosmaita

Bug Description

Ran into this use case in Glance, where we may want to pass a configured path for python_exec in some cases, but otherwise want to let processutils handle it. Thus, we'd call

  processutils.execute(python_exec=conf.python_interp)

where conf.python_interp could be None. On the processutiils side, the python_exec parameter is handled like this [0]:

  python_exec = kwargs.pop('python_exec', sys.executable)

So for the glance use case, what happens is that when 'python_exec' is passed with value None, None becomes the local value of python_exec, which will not end well inside the execute() function. I can't think of an actual use case for having python_exec being None within the execute() function, so I propose that the line above be changed to:

  python_exec = kwargs.pop('python_exec', None) or sys.executable

This way, if the python_exec argument is missing or is None, processutils will use an appropriate executable, which I think is most likely how people think this argument behaves anyway (I know I did).

[0] https://opendev.org/openstack/oslo.concurrency/src/commit/95b9334cfab6849fbe47e2b118e5355af3675dba/oslo_concurrency/processutils.py#L332

Changed in oslo.concurrency:
assignee: nobody → Brian Rosmaita (brian-rosmaita)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.concurrency (master)
Changed in oslo.concurrency:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.concurrency (master)

Reviewed: https://review.opendev.org/c/openstack/oslo.concurrency/+/831432
Committed: https://opendev.org/openstack/oslo.concurrency/commit/a937c5562f7cca721972822d72ae7d2915bd5d52
Submitter: "Zuul (22348)"
Branch: master

commit a937c5562f7cca721972822d72ae7d2915bd5d52
Author: Brian Rosmaita <email address hidden>
Date: Tue Mar 1 12:50:33 2022 -0500

    Allow python_exec kwarg to be None

    processutils.execute() is documented to take a python_exec kwarg and
    default to using sys.executable if that argument isn't set. It is
    convenient (and more intuitive) for this behavior to also occur if
    the argument is present with value None.

    Closes-bug: #1962603
    Related-bug: #1962581
    Change-Id: I2e1f187feaf4bf9fbfaf04fce78efa0cba49fc07

Changed in oslo.concurrency:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.concurrency 4.5.1

This issue was fixed in the openstack/oslo.concurrency 4.5.1 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.