[yum-commits] Branch 'yum-3_2_X' - yum/rpmsack.py

Panu Matilainen pmatilai at osuosl.org
Thu Feb 17 19:00:54 UTC 2011


 yum/rpmsack.py |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 8335c09a3a400911250c7a7025dc826ce48aa695
Author: Panu Matilainen <pmatilai at laiskiainen.org>
Date:   Thu Feb 17 20:57:09 2011 +0200

    Avoid unwanted header loads from RPMInstalledPackage() __getattr__()
    
    At least hasattr() calls for _cache_prco_names_* and _prco_lookup
    were causing headers to be loaded when not wanted at all, causing
    headers for all to-be updated packages to be kept in memory throughout
    the entire transaction.

diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 227ed89..3830339 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -67,13 +67,13 @@ class RPMInstalledPackage(YumInstalledPackage):
             raise Errors.PackageSackError, 'Rpmdb changed underneath us'
 
     def __getattr__(self, varname):
-        self.hdr = val = self._get_hdr()
-        self._has_hdr = True
-        # If these existed, then we wouldn't get here ... and nothing in the DB
-        # starts and ends with __'s. So these are missing.
-        if varname.startswith('__') and varname.endswith('__'):
+        # If these existed, then we wouldn't get here...
+        # Prevent access of __foo__, _cached_foo etc from loading the header 
+        if varname.startswith('_'):
             raise AttributeError, "%s has no attribute %s" % (self, varname)
             
+        self.hdr = val = self._get_hdr()
+        self._has_hdr = True
         if varname != 'hdr':   #  This is unusual, for anything that happens
             val = val[varname] # a lot we should preload at __init__.
                                # Also note that pkg.no_value raises KeyError.


More information about the Yum-commits mailing list