Patchwork [bitbake-devel] parse: Return IOError when including file with absolute path

mail settings
Submitter Martin Jansa
Date Aug. 23, 2013, 5:06 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/56431/
State Accepted
Commit b0bbd89a4f0b98fa1ab28b8e0526cd9ddb76fa57
Headers show


Martin Jansa - Aug. 23, 2013, 5:06 p.m.
* resolve_file was behaving different when relative and absolute
  paths were passed to it

* include relative-path/
  works correctly resolve_file throws IOError,
  doesn't catch it, catches IOError and shows:
  DEBUG: CONF file 'relative-path/' not found
* include /absolute-path/
  was failing, because resolve_file just returns fn, calls bb.parse.mark_dependency(d, abs_fn)
  which throws:
  OSError: [Errno 2] No such file or directory: '/absolute-path/'
  and parsing fails.
  Ad isfile() test for absolute fn and throw IOError to make
  resolve_file behavior consistent for both paths.

* I know we had some issues with -b and
  absolute path, so consider this patch only as RFC and documentation of
  this problem

* Catch OSError too in e.g. in case the file exists, but user
  cannot read it or something like that.

Signed-off-by: Martin Jansa <>
 lib/bb/parse/             | 3 +++
 lib/bb/parse/parse_py/ | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)


diff --git a/lib/bb/parse/ b/lib/bb/parse/
index 3f93ad2..c973f6f 100644
--- a/lib/bb/parse/
+++ b/lib/bb/parse/
@@ -107,6 +107,9 @@  def resolve_file(fn, d):
             raise IOError("file %s not found in %s" % (fn, bbpath))
         fn = newfn
+    if not os.path.isfile(fn):
+        raise IOError("file %s not found" % fn)
     logger.debug(2, "LOAD %s", fn)
     return fn
diff --git a/lib/bb/parse/parse_py/ b/lib/bb/parse/parse_py/
index 7d4a5b1..7b30c8a 100644
--- a/lib/bb/parse/parse_py/
+++ b/lib/bb/parse/parse_py/
@@ -89,7 +89,7 @@  def include(oldfn, fn, lineno, data, error_out):
     from bb.parse import handle
         ret = handle(fn, data, True)
-    except IOError:
+    except (IOError, OSError):
         if error_out:
             raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno)
         logger.debug(2, "CONF file '%s' not found", fn)