Skip to content

Commit 8b52899

Browse files
committed
Fixed some additional str/bytes issues.
- Legacy-Id: 16342
1 parent 36cac48 commit 8b52899

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

ietf/doc/views_charter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,11 @@ def submit(request, name, option=None):
413413

414414
# Save file on disk
415415
filename = os.path.join(settings.CHARTER_PATH, '%s-%s.txt' % (charter.canonical_name(), charter.rev))
416-
with open(filename, 'wb') as destination:
416+
with open(filename, 'w', encoding='utf-8') as destination:
417417
if form.cleaned_data['txt']:
418418
destination.write(form.cleaned_data['txt'])
419419
else:
420-
destination.write(form.cleaned_data['content'].encode("utf-8"))
420+
destination.write(form.cleaned_data['content'])
421421

422422
if option in ['initcharter','recharter'] and charter.ad == None:
423423
charter.ad = getattr(group.ad_role(),'person',None)

ietf/doc/views_conflict_review.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def clean_txt(self):
159159

160160
def save(self, review):
161161
filename = os.path.join(settings.CONFLICT_REVIEW_PATH, '%s-%s.txt' % (review.canonical_name(), review.rev))
162-
with open(filename, 'wb') as destination:
162+
with open(filename, 'w', encoding='utf-8') as destination:
163163
if self.cleaned_data['txt']:
164164
destination.write(self.cleaned_data['txt'])
165165
else:

ietf/doc/views_status_change.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def clean_txt(self):
124124

125125
def save(self, doc):
126126
filename = os.path.join(settings.STATUS_CHANGE_PATH, '%s-%s.txt' % (doc.canonical_name(), doc.rev))
127-
with open(filename, 'wb') as destination:
127+
with open(filename, 'w', encoding='utf-8') as destination:
128128
if self.cleaned_data['txt']:
129129
destination.write(self.cleaned_data['txt'])
130130
else:

ietf/iesg/views.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from django.http import HttpResponse
5050
from django.shortcuts import render, redirect
5151
from django.contrib.sites.models import Site
52+
from django.utils.encoding import force_bytes
5253
#from django.views.decorators.cache import cache_page
5354
#from django.views.decorators.vary import vary_on_cookie
5455

@@ -454,22 +455,22 @@ def telechat_docs_tarfile(request, date):
454455

455456
tarstream = tarfile.open('', 'w:gz', response)
456457

457-
manifest = io.StringIO()
458+
manifest = io.BytesIO()
458459

459460
for doc in docs:
460-
doc_path = os.path.join(doc.get_file_path(), doc.name + "-" + doc.rev + ".txt")
461+
doc_path = force_bytes(os.path.join(doc.get_file_path(), doc.name + "-" + doc.rev + ".txt"))
461462
if os.path.exists(doc_path):
462463
try:
463464
tarstream.add(doc_path, str(doc.name + "-" + doc.rev + ".txt"))
464-
manifest.write("Included: %s\n" % doc_path)
465+
manifest.write(b"Included: %s\n" % doc_path)
465466
except Exception as e:
466-
manifest.write("Failed (%s): %s\n" % (e, doc_path))
467+
manifest.write(b"Failed (%s): %s\n" % (force_bytes(e), doc_path))
467468
else:
468-
manifest.write("Not found: %s\n" % doc_path)
469+
manifest.write(b"Not found: %s\n" % doc_path)
469470

470471
manifest.seek(0)
471472
t = tarfile.TarInfo(name="manifest.txt")
472-
t.size = len(manifest.buf)
473+
t.size = len(manifest.getvalue())
473474
t.mtime = time.time()
474475
tarstream.addfile(t, manifest)
475476

0 commit comments

Comments
 (0)