@@ -27,13 +27,17 @@ def get_gecko_info(self, path):
27
27
for type , section in INI_DATA_MAPPING :
28
28
config_file = os .path .join (path , "%s.ini" % type )
29
29
if os .path .exists (config_file ):
30
- self ._parse_ini_file (open (config_file ), type , section )
30
+ try :
31
+ with open (config_file ) as fp :
32
+ self ._parse_ini_file (fp , type , section )
33
+ except OSError :
34
+ self ._logger .warning ("Unable to read %s" % config_file )
31
35
else :
32
36
self ._logger .warning ("Unable to find %s" % config_file )
33
37
34
38
def _parse_ini_file (self , fp , type , section ):
35
39
config = configparser .RawConfigParser ()
36
- config .readfp (fp )
40
+ config .read_file (fp )
37
41
name_map = {
38
42
"codename" : "display_name" ,
39
43
"milestone" : "version" ,
@@ -61,14 +65,14 @@ def get_gecko_info(self, path):
61
65
for type , section in INI_DATA_MAPPING :
62
66
filename = "%s.ini" % type
63
67
if filename in archive_list :
64
- fp = io .TextIOWrapper (archive .open (filename ))
65
- self ._parse_ini_file (fp , type , section )
68
+ with io .TextIOWrapper (archive .open (filename )) as fp :
69
+ self ._parse_ini_file (fp , type , section )
66
70
else :
67
71
self ._logger .warning ("Unable to find %s" % filename )
68
72
69
73
if "package-name.txt" in archive_list :
70
- fp = io .TextIOWrapper (archive .open ("package-name.txt" ))
71
- self ._info ["package_name" ] = fp .readlines ()[0 ].strip ()
74
+ with io .TextIOWrapper (archive .open ("package-name.txt" )) as fp :
75
+ self ._info ["package_name" ] = fp .readlines ()[0 ].strip ()
72
76
73
77
74
78
class LocalVersion (Version ):
0 commit comments