From: Juro Bystricky Date: Mon, 26 Sep 2016 20:53:13 +0000 (-0700) Subject: build.py: fix os.getcwd() exception X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bcf77589312d9936340d8c308006c2fc9baf67c;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git build.py: fix os.getcwd() exception When trying to obtain the current directory from a directory that does not exist anymore, an exception is raised. This patch handles such exception. [YOCTO #10331] Signed-off-by: Juro Bystricky Signed-off-by: Richard Purdie --- diff --git a/lib/bb/build.py b/lib/bb/build.py index 2ed0441b491..249f7d6bb44 100644 --- a/lib/bb/build.py +++ b/lib/bb/build.py @@ -261,9 +261,14 @@ def exec_func(func, d, dirs = None, pythonexception=False): else: exec_func_shell(func, d, runfile, cwd=adir) - if oldcwd and os.getcwd() != oldcwd: + try: + curcwd = os.getcwd() + except: + curcwd = None + + if oldcwd and curcwd != oldcwd: try: - bb.warn("Task %s changed cwd to %s" % (func, os.getcwd())) + bb.warn("Task %s changed cwd to %s" % (func, curcwd)) os.chdir(oldcwd) except: pass