Преглед изворни кода

Correction du warning sur la non fermeture du fichier json du quel est chargé le ME

Driky пре 9 година
родитељ
комит
b94f867764
1 измењених фајлова са 2 додато и 2 уклоњено
  1. 2
    2
      EditorialModel/backend/json_backend.py

+ 2
- 2
EditorialModel/backend/json_backend.py Прегледај датотеку

@@ -44,8 +44,8 @@ class EmBackendJson(object):
44 44
     #
45 45
     # @param json_file str: path to the json_file used as data source
46 46
     def __init__(self, json_file):
47
-        json_data = open(json_file).read()
48
-        self.data = json.loads(json_data)
47
+        with open(json_file).read() as json_data:
48
+            self.data = json.loads(json_data)
49 49
 
50 50
     ## Loads the data in the data source json file
51 51
     #

Loading…
Откажи
Сачувај