summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/patch.py
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2023-11-21 14:06:17 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-22 14:08:45 +0000
commitcdc40292818683b6df1c814498c7589450a163fa (patch)
tree737472559bce1e705c4bf1259fa41ee9cb4992fd /meta/lib/oe/patch.py
parent63bc72ccb63d2f8eb591d7cc481657a538f0fd42 (diff)
downloadopenembedded-core-cdc40292818683b6df1c814498c7589450a163fa.tar.gz
lib/oe/patch: ensure os.chdir restoring always happens
If we chdir(), do the chdir back to the original directory in a finally block so they always run. Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/patch.py')
-rw-r--r--meta/lib/oe/patch.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index ff9afc9df9..9b480b2b28 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -772,8 +772,9 @@ class NOOPResolver(Resolver):
self.patchset.Push()
except Exception:
import sys
- os.chdir(olddir)
raise
+ finally:
+ os.chdir(olddir)
# Patch resolver which relies on the user doing all the work involved in the
# resolution, with the exception of refreshing the remote copy of the patch
@@ -833,9 +834,9 @@ class UserResolver(Resolver):
# User did not fix the problem. Abort.
raise PatchError("Patch application failed, and user did not fix and refresh the patch.")
except Exception:
- os.chdir(olddir)
raise
- os.chdir(olddir)
+ finally:
+ os.chdir(olddir)
def patch_path(url, fetch, workdir, expand=True):