Make ebuild-ipc.py handle exceptions from pickle.loads().
authorZac Medico <zmedico@gentoo.org>
Fri, 10 Sep 2010 07:14:03 +0000 (00:14 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Sep 2010 07:14:03 +0000 (00:14 -0700)
bin/ebuild-ipc.py

index 5569a24b581c4f2ec8ff3e6c6de2349678fa88f5..21e5647f3919ef246b953cc8c002b828d8a72880 100755 (executable)
@@ -94,23 +94,27 @@ class EbuildIpc(object):
                except IOError as e:
                        portage.util.writemsg("%s\n" % (e,), noiselevel=-1)
 
-               if buf:
+               rval = 2
 
-                       reply = pickle.loads(buf.tostring())
-                       output_file.close()
-                       input_file.close()
+               if buf:
 
-                       (out, err, rval) = reply
+                       try:
+                               reply = pickle.loads(buf.tostring())
+                       except (EnvironmentError, EOFError, ValueError,
+                               pickle.UnpicklingError) as e:
+                               portage.util.writemsg("%s\n" % (e,), noiselevel=-1)
 
-                       if out:
-                               portage.util.writemsg_stdout(out, noiselevel=-1)
+                       else:
+                               output_file.close()
+                               input_file.close()
 
-                       if err:
-                               portage.util.writemsg(err, noiselevel=-1)
+                               (out, err, rval) = reply
 
-               else:
+                               if out:
+                                       portage.util.writemsg_stdout(out, noiselevel=-1)
 
-                       rval = 2
+                               if err:
+                                       portage.util.writemsg(err, noiselevel=-1)
 
                return rval