mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix error spotted by @andrewsg
This commit is contained in:
parent
f7b9a08c9c
commit
e4fbc805b6
@ -1,6 +1,7 @@
|
||||
# Create your views here.
|
||||
|
||||
import csv
|
||||
import io
|
||||
import os
|
||||
from django import forms
|
||||
from django.http import HttpResponse
|
||||
@ -28,10 +29,15 @@ def home(request):
|
||||
subject = form.cleaned_data['subject']
|
||||
message = form.cleaned_data['message']
|
||||
f = request.FILES['f']
|
||||
|
||||
|
||||
if not hasattr(f, "fileno"):
|
||||
size = len(f.read())
|
||||
else:
|
||||
size = int(os.fstat(f.fileno())[6])
|
||||
try:
|
||||
size = int(os.fstat(f.fileno())[6])
|
||||
except io.UnsupportedOperation:
|
||||
size = len(f.read())
|
||||
else:
|
||||
form = MsgForm()
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ class Response(object):
|
||||
self.send_headers()
|
||||
|
||||
if isinstance(arg, text_type):
|
||||
arg = arg.decode('utf-8')
|
||||
arg = arg.encode('utf-8')
|
||||
|
||||
assert isinstance(arg, binary_type), "%r is not a byte." % arg
|
||||
|
||||
|
||||
@ -225,9 +225,9 @@ except ImportError:
|
||||
|
||||
def write_chunk(sock, data):
|
||||
if isinstance(data, text_type):
|
||||
data = data.decode('utf-8')
|
||||
data = data.encode('utf-8')
|
||||
chunk_size = "%X\r\n" % len(data)
|
||||
chunk = b"".join([chunk_size.decode('utf-8'), data, b"\r\n"])
|
||||
chunk = b"".join([chunk_size.encode('utf-8'), data, b"\r\n"])
|
||||
sock.sendall(chunk)
|
||||
|
||||
def write(sock, data, chunked=False):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user