cache.ebuild_xattr: don't import ENODATA globally
authorZac Medico <zmedico@gentoo.org>
Tue, 8 Feb 2011 06:35:14 +0000 (22:35 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 Feb 2011 06:35:14 +0000 (22:35 -0800)
ENODATA is undefined on FreeBSD. This will fix bug #354057.

pym/portage/cache/ebuild_xattr.py

index 1d7e26f900bb914984b4a11d4023f40e5786ff06..6b388faaf7b0bb91f887ff5c091cce374b8685af 100644 (file)
@@ -4,6 +4,8 @@
 
 __all__ = ['database']
 
+import errno
+
 import portage
 from portage.cache import fs_template
 from portage.versions import catsplit
@@ -11,7 +13,6 @@ from portage import cpv_getkey
 from portage import os
 from portage import _encodings
 from portage import _unicode_decode
-from errno import ENODATA,ENOSPC,E2BIG
 portage.proxy.lazyimport.lazyimport(globals(),
        'xattr')
 
@@ -58,16 +59,16 @@ class database(fs_template.FsBased):
                except IOError as e:
                        # ext based give wrong errno
                        # http://bugzilla.kernel.org/show_bug.cgi?id=12793
-                       if e.errno in (E2BIG,ENOSPC):
+                       if e.errno in (errno.E2BIG, errno.ENOSPC):
                                result = len(s)-100
                        else:
-                               raise e
+                               raise
 
                try:
                        self.__remove(path,'test_max')
                except IOError as e:
-                       if e.errno is not ENODATA:
-                               raise e
+                       if e.errno != errno.ENODATA:
+                               raise
 
                return result
 
@@ -87,7 +88,7 @@ class database(fs_template.FsBased):
                try:
                        return xattr.get(path,key,namespace=self.ns)
                except IOError as e:
-                       if not default is None and ENODATA == e.errno:
+                       if not default is None and errno.ENODATA == e.errno:
                                return default
                        else:
                                raise NoValueException()