=== modified file 'apport/source_brz.py'
--- old/apport/source_brz.py	2018-11-18 19:48:57 +0000
+++ new/apport/source_brz.py	2022-05-03 18:47:58 +0000
@@ -15,7 +15,8 @@
     if 'BrzLogTail' in report:
         return
 
-    brz_log_lines = open(brz_log).readlines()
+    with open(brz_log) as f:
+        brz_log_lines = f.readlines()
     brz_log_lines.reverse()
 
     brz_log_tail = []

=== modified file 'breezy/bzr/weave.py'
--- old/breezy/bzr/weave.py	2020-07-18 23:14:00 +0000
+++ new/breezy/bzr/weave.py	2022-05-03 18:47:58 +0000
@@ -975,8 +975,8 @@
         self._transport = transport
         self._filemode = filemode
         try:
-            f = self._transport.get(name + WeaveFile.WEAVE_SUFFIX)
-            _read_weave_v5(BytesIO(f.read()), self)
+            with self._transport.get(name + WeaveFile.WEAVE_SUFFIX) as f:
+                _read_weave_v5(BytesIO(f.read()), self)
         except errors.NoSuchFile:
             if not create:
                 raise

=== modified file 'breezy/plugins/news_merge/parser.py'
--- old/breezy/plugins/news_merge/parser.py	2020-02-18 01:57:45 +0000
+++ new/breezy/plugins/news_merge/parser.py	2022-05-03 18:47:58 +0000
@@ -63,6 +63,7 @@
 
 if __name__ == '__main__':
     import sys
-    content = open(sys.argv[1], 'rb').read()
+    with open(sys.argv[1], 'rb') as f:
+        content = f.read()
     for result in simple_parse(content):
         print(result)

=== modified file 'breezy/plugins/rewrite/tests/test_blackbox.py'
--- old/breezy/plugins/rewrite/tests/test_blackbox.py	2020-01-11 17:20:34 +0000
+++ new/breezy/plugins/rewrite/tests/test_blackbox.py	2022-05-03 18:47:58 +0000
@@ -326,14 +326,16 @@
         os.mkdir('main')
         os.chdir('main')
         self.run_bzr('init')
-        open('bar', 'w').write('42')
+        with open('bar', 'w') as f:
+            f.write('42')
         self.run_bzr('add')
         self.run_bzr('commit -m that')
         os.mkdir('../feature')
         os.chdir('../feature')
         self.run_bzr('init')
         branch = Branch.open('.')
-        open('hello', 'w').write("my data")
+        with open('hello', 'w') as f:
+            f.write("my data")
         self.run_bzr('add')
         self.run_bzr('commit -m this')
         self.assertEquals(1, branch.revno())
@@ -345,16 +347,19 @@
         os.mkdir('main')
         os.chdir('main')
         self.run_bzr('init')
-        open('bar', 'w').write('42')
+        with open('bar', 'w') as f:
+            f.write('42')
         self.run_bzr('add')
         self.run_bzr('commit -m that')
-        open('bar', 'w').write('84')
+        with open('bar', 'w') as f:
+            f.write('84')
         self.run_bzr('commit -m blathat')
         os.mkdir('../feature')
         os.chdir('../feature')
         self.run_bzr('init')
         branch = Branch.open('.')
-        open('hello', 'w').write("my data")
+        with open('hello', 'w') as f:
+            f.write("my data")
         self.run_bzr('add')
         self.run_bzr('commit -m this')
         self.assertEquals(1, branch.revno())

=== modified file 'breezy/plugins/rewrite/tests/test_rebase.py'
--- old/breezy/plugins/rewrite/tests/test_rebase.py	2020-08-09 18:10:01 +0000
+++ new/breezy/plugins/rewrite/tests/test_rebase.py	2022-05-03 18:47:58 +0000
@@ -444,7 +444,8 @@
         wt.add(['sfile'])
         wt.add(["afile"], [b"somefileid"])
         wt.commit("bla", rev_id=b"oldgrandparent")
-        open("old/afile", "w").write("data")
+        with open("old/afile", "w") as f:
+            f.write("data")
         wt.commit("bla", rev_id=b"oldparent")
         wt.add(["notherfile"])
         wt.commit("bla", rev_id=b"oldcommit")
@@ -455,7 +456,8 @@
         wt.add(['sfile'])
         wt.add(["afile"], [b"afileid"])
         wt.commit("bla", rev_id=b"newgrandparent")
-        open("new/afile", "w").write("data")
+        with open("new/afile", "w") as f:
+            f.write("data")
         wt.commit("bla", rev_id=b"newparent")
         wt.branch.repository.fetch(oldrepos)
         wt.branch.repository.lock_write()

=== modified file 'breezy/tests/blackbox/test_pull.py'
--- old/breezy/tests/blackbox/test_pull.py	2020-01-19 13:07:15 +0000
+++ new/breezy/tests/blackbox/test_pull.py	2022-05-03 18:47:58 +0000
@@ -500,11 +500,12 @@
             err,
             ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
 
-        self.assertEqualDiff('<<<<<<< TREE\n'
-                             'fie||||||| BASE-REVISION\n'
-                             'foo=======\n'
-                             'fee>>>>>>> MERGE-SOURCE\n',
-                             open(osutils.pathjoin('b', 'hello')).read())
+        with open(osutils.pathjoin('b', 'hello')) as f:
+            self.assertEqualDiff('<<<<<<< TREE\n'
+                                 'fie||||||| BASE-REVISION\n'
+                                 'foo=======\n'
+                                 'fee>>>>>>> MERGE-SOURCE\n',
+                                 f.read())
 
     def test_pull_warns_about_show_base_when_no_working_tree(self):
         """--show-base is useless if there's no working tree

=== modified file 'breezy/tests/blackbox/test_remerge.py'
--- old/breezy/tests/blackbox/test_remerge.py	2018-11-11 04:08:32 +0000
+++ new/breezy/tests/blackbox/test_remerge.py	2022-05-03 18:47:58 +0000
@@ -51,7 +51,8 @@
         self.create_conflicts()
         self.run_bzr('merge ../other --show-base',
                      retcode=1, working_dir='this')
-        conflict_text = open('this/hello').read()
+        with open('this/hello') as f:
+            conflict_text = f.read()
         self.assertTrue('|||||||' in conflict_text)
         self.assertTrue('hi world' in conflict_text)
 

=== modified file 'breezy/tests/test_atomicfile.py'
--- old/breezy/tests/test_atomicfile.py	2018-08-14 21:37:46 +0000
+++ new/breezy/tests/test_atomicfile.py	2022-05-03 18:47:58 +0000
@@ -72,7 +72,8 @@
         f.write(b'foo\n')
         f.commit()
 
-        contents = open('test', 'rb').read()
+        with open('test', 'rb') as f:
+            contents = f.read()
         if sys.platform == 'win32':
             self.assertEqual(b'foo\r\n', contents)
         else:

