Merge lp:~ballot/codetree/fix_httphandler_write into lp:codetree

Proposed by Benjamin Allot
Status: Merged
Approved by: Stuart Bishop
Approved revision: 118
Merged at revision: 118
Proposed branch: lp:~ballot/codetree/fix_httphandler_write
Merge into: lp:codetree
Diff against target: 34 lines (+3/-3)
2 files modified
codetree/handlers/basic.py (+1/-1)
tests/test_basic_handlers.py (+2/-2)
To merge this branch: bzr merge lp:~ballot/codetree/fix_httphandler_write
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Codetree Maintainers Pending
Review via email: mp+385693@code.launchpad.net

Commit message

Write the file as binary blob when read from HTTP response

To post a comment you must log in.
Revision history for this message
Benjamin Allot (ballot) wrote :

This fixes the issue seen here: https://pastebin.canonical.com/p/YgF4Q7Jxvh/

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Stuart Bishop (stub) wrote :

+1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 118

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'codetree/handlers/basic.py'
2--- codetree/handlers/basic.py 2020-04-08 09:27:18 +0000
3+++ codetree/handlers/basic.py 2020-06-12 20:36:17 +0000
4@@ -97,7 +97,7 @@
5 logging.error("Failed to download {}: {}".format(self.source, e.reason))
6 result.success = False
7 return result
8- with open(dest, "w") as f:
9+ with open(dest, "wb") as f:
10 f.write(response.read())
11 return result
12
13
14=== modified file 'tests/test_basic_handlers.py'
15--- tests/test_basic_handlers.py 2020-04-08 09:27:18 +0000
16+++ tests/test_basic_handlers.py 2020-06-12 20:36:17 +0000
17@@ -212,7 +212,7 @@
18 with patch('codetree.handlers.basic.open', _open, create=True):
19 self.assertTrue(hh.get(destfile, {}))
20 self.assertFalse(_unlink.called)
21- _open.assert_called_with(destfile, "w")
22+ _open.assert_called_with(destfile, "wb")
23 _urlopen.assert_called_with(HttpURLs[0])
24
25 @patch('codetree.handlers.basic.os.unlink')
26@@ -248,7 +248,7 @@
27 with patch('codetree.handlers.basic.open', _open, create=True):
28 self.assertTrue(hh.get(destfile, options={"overwrite": True}))
29 _unlink.assert_called_with(destfile)
30- _open.assert_called_with(destfile, "w")
31+ _open.assert_called_with(destfile, "wb")
32 _urlopen.assert_called_with(HttpURLs[0])
33
34 @patch('codetree.handlers.basic.os.unlink')

Subscribers

People subscribed via source and target branches