From fb05ca420da1341c0d39cf1f0e2fb659be836c92 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Mon, 27 Sep 2021 09:55:02 +0200 Subject: [PATCH] Used Path.read_text() in jinja2.get_exception_info(). --- django/template/backends/jinja2.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/django/template/backends/jinja2.py b/django/template/backends/jinja2.py index d1e5217b51..f0540d389c 100644 --- a/django/template/backends/jinja2.py +++ b/django/template/backends/jinja2.py @@ -99,8 +99,7 @@ def get_exception_info(exception): if source is None: exception_file = Path(exception.filename) if exception_file.exists(): - with open(exception_file, 'r') as fp: - source = fp.read() + source = exception_file.read_text() if source is not None: lines = list(enumerate(source.strip().split('\n'), start=1)) during = lines[lineno - 1][1]