瀏覽代碼

Close open files when reading within utils/setup.py

fazledyn 6 月之前
父節點
當前提交
fde2e6f26a
共有 4 個文件被更改,包括 5 次插入3 次删除
  1. 1 0
      CHANGELOG.txt
  2. 1 0
      CONTRIBUTORS.md
  3. 1 1
      docs/releases/6.4.md
  4. 2 2
      wagtail/utils/setup.py

+ 1 - 0
CHANGELOG.txt

@@ -14,6 +14,7 @@ Changelog
  * Docs: Add the `wagtail start` command to the management commands reference page (Damilola Oladele)
  * Docs: Refine the project template page sections and document common issues encountered when creating custom templates (Damilola Oladele)
  * Docs: Refine page titles to better align with the documentation style guide (Srishti Jaiswal)
+ * Maintenance: Close open files when reading within utils/setup.py (Ataf Fazledin Ahamed)
 
 
 6.3 LTS (xx.xx.xxxx) - IN DEVELOPMENT

+ 1 - 0
CONTRIBUTORS.md

@@ -849,6 +849,7 @@
 * Srishti Jaiswal
 * Alessandro Chitarrini
 * Joel William
+* Ataf Fazledin Ahamed
 
 ## Translators
 

+ 1 - 1
docs/releases/6.4.md

@@ -34,7 +34,7 @@ depth: 1
 
 ### Maintenance
 
- * ...
+ * Close open files when reading within utils/setup.py (Ataf Fazledin Ahamed)
 
 
 ## Upgrade considerations - changes affecting all projects

+ 2 - 2
wagtail/utils/setup.py

@@ -29,10 +29,10 @@ class assets_mixin:
         Writes the current Wagtail version number into package.json
         """
         path = os.path.join(".", "client", "package.json")
-        input_file = open(path)
 
         try:
-            package = json.loads(input_file.read().decode("utf-8"))
+            with open(path, "r") as f:
+                package = json.loads(f.read())
         except ValueError as e:
             print("Unable to read " + path + " " + e)  # noqa: T201
             raise SystemExit(1)