Skip to content

Commit 7ebb084

Browse files
committed
Fix deprecation warning
The built-in open has supported an encoding argument for a very long time. Resolve the deprecation warning emitted by using the unnecessary codecs.open implementation. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent ab4241e commit 7ebb084

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

‎patchwork/tests/utils.py‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
# SPDX-License-Identifier: GPL-2.0-or-later
55

6-
import codecs
76
from datetime import timedelta
87
from email.utils import make_msgid
98
import os
@@ -36,13 +35,8 @@
3635
def read_patch(filename, encoding=None):
3736
"""Read a diff from a file."""
3837
file_path = os.path.join(TEST_PATCH_DIR, filename)
39-
if encoding is not None:
40-
f = codecs.open(file_path, encoding=encoding)
41-
else:
42-
f = open(file_path)
43-
44-
result = f.read()
45-
f.close()
38+
with open(file_path, encoding=encoding) as fh:
39+
result = fh.read()
4640
return result
4741

4842

0 commit comments

Comments
 (0)