From 1033e7eb34948b31075cf6328c383b80f08c445a Mon Sep 17 00:00:00 2001 From: "jai.s" Date: Wed, 15 Jan 2020 13:44:30 +0530 Subject: [PATCH] Solved BMConfigParser's safeGetInt method issues --- src/bmconfigparser.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index 3293c5b3..a5574156 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -99,13 +99,11 @@ class BMConfigParser(configparser.ConfigParser): def safeGetInt(self, section, field, default=0): """Return value as integer, default on exceptions, 0 if default missing""" - config = configparser.ConfigParser() - try: # Used in the python2.7 # return self.getint(section, field) - # Used in the python3.5.2 - return config.getint(section, field) + # Used in the python3.7.0 + return int(self.get(section, field)) except (configparser.NoSectionError, configparser.NoOptionError, ValueError, AttributeError): return default