Skip to content

Commit ce43400

Browse files
committed
bugfix: finally addressed failing Python 2 bug - critical error was silenced
1 parent fd38c97 commit ce43400

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

config2/config.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from attributedict.collections import AttributeDict
2222

23-
from six import string_types
23+
from six import PY2, string_types
2424

2525
from config2.serializers import json_ as json
2626
from config2.serializers import yaml_ as yaml
@@ -117,6 +117,11 @@ def __init__(self,
117117
this_file_path = os.path.abspath(__file__)
118118

119119
for frame in inspect.stack():
120+
frame_filename = None
121+
122+
if PY2:
123+
frame = inspect.getframeinfo(frame[0])
124+
120125
caller_file_path = os.path.abspath(frame.filename)
121126

122127
is_not_this_file = (frame.filename != this_file_path)
@@ -128,7 +133,7 @@ def __init__(self,
128133

129134
break
130135

131-
except:
136+
except Exception as error:
132137
path = os.getcwd()
133138

134139
path = os.path.abspath(path)
@@ -159,7 +164,7 @@ def __init__(self,
159164
else:
160165
logger = logger or self.__class__.logger('base')
161166

162-
self.__config_data__ = None
167+
self.__config_data__ = {}
163168
self.__config_directory_name__ = config_directory_name
164169
self.__config_files__ = []
165170
self.__config_path__ = config_path
@@ -269,7 +274,7 @@ def reload(self):
269274
raise error
270275

271276
config_datas = map((lambda _config_file:
272-
_config_file and _config_file.data and _config_file.data.copy()
277+
_config_file and _config_file.data and _config_file.data.copy() or {}
273278
), config_files)
274279
config_datas = list(config_datas)
275280

0 commit comments

Comments
 (0)