Skip to content

Commit e0ca98b

Browse files
committed
os.putenv: Avoid propagating old errors from previous function calls
grub_env_set propagated the previous (potentially unrelated) grub_errno value, which led to spurious error messages from harmless failures. For instance, Python searches for modules by attempting to open each possible location, and handles errors by continuing the search; however, a subsequent call to putenv would noisily show that error. This resulted in a spurious error message about /boot/python/bits/efi.pyc, even though the import call that produced that message went on to open the correct file. Clear grub_errno at the start of putenv to prevent this.
1 parent 2207c88 commit e0ca98b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

rc/python/bitsmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ static PyObject *bits__putenv(PyObject *self, PyObject *args)
271271
const char *key, *value;
272272
if (!PyArg_ParseTuple(args, "ss:putenv", &key, &value))
273273
return NULL;
274+
grub_errno = GRUB_ERR_NONE;
274275
if (grub_env_set(key, value) != GRUB_ERR_NONE || grub_env_export(key) != GRUB_ERR_NONE)
275276
return PyErr_SetFromErrno(PyExc_OSError);
276277
return Py_BuildValue("");

0 commit comments

Comments
 (0)