Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] lib/oe/qa: handle missing data attribute in __exit__
@ 2019-12-29  9:31 Alex Kiernan
  2019-12-29 10:02 ` ✗ patchtest: failure for " Patchwork
  2019-12-29 10:44 ` [PATCH] " Richard Purdie
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Kiernan @ 2019-12-29  9:31 UTC (permalink / raw)
  To: openembedded-core

If mmap fails in open, we don't have a data attribute so when we execute
as a context manager the call to self.data.close needs to handle the
missing attribute:

  File: '/home/akiernan/nanohub/build/../poky/meta/classes/chrpath.bbclass', lineno: 11, function: process_file_linux
       0007:    with oe.qa.ELFFile(fpath) as elf:
       0008:        try:
       0009:            elf.open()
       0010:        except oe.qa.NotELFFileError:
   *** 0011:            return
       0012:
       0013:    p = sub.Popen([cmd, '-l', fpath],stdout=sub.PIPE,stderr=sub.PIPE)
       0014:    out, err = p.communicate()
       0015:    # If returned successfully, process stdout for results
  File: '/home/akiernan/nanohub/build/../poky/meta/lib/oe/qa.py', lineno: 50, function: __exit__
       0046:    def __enter__(self):
       0047:        return self
       0048:
       0049:    def __exit__(self, exc_type, exc_value, traceback):
   *** 0050:        self.data.close()
       0051:
       0052:    def open(self):
       0053:        with open(self.name, "rb") as f:
       0054:            try:
  Exception: AttributeError: 'ELFFile' object has no attribute 'data'

Fixes: 7785c41d0b95 ("chrpath: do less work")
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 meta/lib/oe/qa.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 21066c4dc3b3..d85206f155f0 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -47,7 +47,11 @@ class ELFFile:
         return self
 
     def __exit__(self, exc_type, exc_value, traceback):
-        self.data.close()
+        try:
+            self.data.close()
+        except AttributeError:
+            # If we failed to mmap in open then the data attribute won't exist
+            pass
 
     def open(self):
         with open(self.name, "rb") as f:
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-29 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-29  9:31 [PATCH] lib/oe/qa: handle missing data attribute in __exit__ Alex Kiernan
2019-12-29 10:02 ` ✗ patchtest: failure for " Patchwork
2019-12-29 10:44 ` [PATCH] " Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox