Merge lp:~deej/charm-helpers/fix-fetch-python3 into lp:charm-helpers

Proposed by David Lawson
Status: Merged
Merged at revision: 504
Proposed branch: lp:~deej/charm-helpers/fix-fetch-python3
Merge into: lp:charm-helpers
Diff against target: 12 lines (+1/-1)
1 file modified
charmhelpers/fetch/archiveurl.py (+1/-1)
To merge this branch: bzr merge lp:~deej/charm-helpers/fix-fetch-python3
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Cory Johns (community) Approve
Review via email: mp+280076@code.launchpad.net

Description of the change

Archive URL fetching doesn't work with python3, you get a TypeError: must be str, not bytes at line 112 in archiveurl.py, switching to writing the file in binary mode fixes this with python3 and should (I think) be innocuous in python2.

To post a comment you must log in.
Revision history for this message
Cory Johns (johnsca) wrote :

+1

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

Its a bug in Python2 as well, although it will only fail there under Windows.

I've fixed the test you missed and landed this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/fetch/archiveurl.py'
2--- charmhelpers/fetch/archiveurl.py 2015-07-15 09:35:46 +0000
3+++ charmhelpers/fetch/archiveurl.py 2015-12-09 20:58:28 +0000
4@@ -108,7 +108,7 @@
5 install_opener(opener)
6 response = urlopen(source)
7 try:
8- with open(dest, 'w') as dest_file:
9+ with open(dest, 'wb') as dest_file:
10 dest_file.write(response.read())
11 except Exception as e:
12 if os.path.isfile(dest):

Subscribers

People subscribed via source and target branches