Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

settings: do not rely on KeyError from iniparse

iniparse 0.4 will return an Undefined instance for sections or items not found
in the config file. It's best to test for inclusion instead.

Changeset c88dc49032fd

Parent acd6eebad5ce

by Steve Borho

Changes to one file · Browse files at c88dc49032fd Showing diff from parent acd6eebad5ce Diff from another changeset...

 
743
744
745
746
747
748
749
750
 
 
 
751
 
 
 
752
753
754
 
801
802
803
804
805
806
807
 
 
 
 
 
808
809
810
 
743
744
745
 
 
 
 
 
746
747
748
749
750
751
752
753
754
755
 
802
803
804
 
 
 
 
805
806
807
808
809
810
811
812
@@ -743,12 +743,13 @@
    def readCPath(self, cpath):   'Retrieve a value from the parsed config file' - try: - # Presumes single section/key level depth - section, key = cpath.split('.', 1) - return self.ini[section][key] - except KeyError: + # Presumes single section/key level depth + section, key = cpath.split('.', 1) + if section not in self.ini:   return None + if key not in self.ini[section]: + return None + return self.ini[section][key]     def loadIniFile(self, rcpath):   for fn in rcpath: @@ -801,10 +802,11 @@
  # 'newvalue' is in local encoding   section, key = cpath.split('.', 1)   if newvalue == None: - try: - del self.ini[section][key] - except KeyError: - pass + if section not in self.ini: + return + if key not in self.ini[section]: + return + del self.ini[section][key]   return   if section not in self.ini:   if hasattr(self.ini, '_new_namespace'):