* [RFC][PATCH] parse: Return IOError when including file with absolute path
@ 2013-08-23 16:48 Martin Jansa
2013-08-23 17:06 ` [PATCH] " Martin Jansa
0 siblings, 1 reply; 2+ messages in thread
From: Martin Jansa @ 2013-08-23 16:48 UTC (permalink / raw)
To: bitbake-devel
* resolve_file was behaving different when relative and absolute
paths were passed to it
* include relative-path/non-existent-file.inc
works correctly resolve_file throws IOError, BBHandler.py:handle()
doesn't catch it, ConfHandler.py:include() catches IOError and shows:
DEBUG: CONF file 'relative-path/non-existent-file.inc' not found
* include /absolute-path/non-existent-file.inc
was failing, because resolve_file just returns fn,
BBHandler.py:handle() calls bb.parse.mark_dependency(d, abs_fn)
which throws:
OSError: [Errno 2] No such file or directory: '/absolute-path/non-existent-file.inc'
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 relative-path-to-recipe.bb and
absolute path, so consider this patch only as RFC and documentation of
this problem
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
lib/bb/parse/__init__.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/bb/parse/__init__.py b/lib/bb/parse/__init__.py
index 3f93ad2..c973f6f 100644
--- a/lib/bb/parse/__init__.py
+++ b/lib/bb/parse/__init__.py
@@ -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
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] parse: Return IOError when including file with absolute path
2013-08-23 16:48 [RFC][PATCH] parse: Return IOError when including file with absolute path Martin Jansa
@ 2013-08-23 17:06 ` Martin Jansa
0 siblings, 0 replies; 2+ messages in thread
From: Martin Jansa @ 2013-08-23 17:06 UTC (permalink / raw)
To: bitbake-devel
* resolve_file was behaving different when relative and absolute
paths were passed to it
* include relative-path/non-existent-file.inc
works correctly resolve_file throws IOError, BBHandler.py:handle()
doesn't catch it, ConfHandler.py:include() catches IOError and shows:
DEBUG: CONF file 'relative-path/non-existent-file.inc' not found
* include /absolute-path/non-existent-file.inc
was failing, because resolve_file just returns fn,
BBHandler.py:handle() calls bb.parse.mark_dependency(d, abs_fn)
which throws:
OSError: [Errno 2] No such file or directory: '/absolute-path/non-existent-file.inc'
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 relative-path-to-recipe.bb and
absolute path, so consider this patch only as RFC and documentation of
this problem
* Catch OSError too in ConfHandler.py:include() e.g. in case the file exists, but user
cannot read it or something like that.
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
lib/bb/parse/__init__.py | 3 +++
lib/bb/parse/parse_py/ConfHandler.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/bb/parse/__init__.py b/lib/bb/parse/__init__.py
index 3f93ad2..c973f6f 100644
--- a/lib/bb/parse/__init__.py
+++ b/lib/bb/parse/__init__.py
@@ -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/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py
index 7d4a5b1..7b30c8a 100644
--- a/lib/bb/parse/parse_py/ConfHandler.py
+++ b/lib/bb/parse/parse_py/ConfHandler.py
@@ -89,7 +89,7 @@ def include(oldfn, fn, lineno, data, error_out):
from bb.parse import handle
try:
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)
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-23 17:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-23 16:48 [RFC][PATCH] parse: Return IOError when including file with absolute path Martin Jansa
2013-08-23 17:06 ` [PATCH] " Martin Jansa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.