<[email protected]> wrote on 2015-Jan-07 at 08:15 PM:>
File "/usr/lib/python2.7/rfc822.py", line 155, in readheaders
> line = self.fp.readline()
> File "/usr/lib/python2.7/site-packages/trac/web/modpython_frontend.py",
> line 52, in readline
> return self.req.readline(size)
> MemoryError
It seems that to be a mod_python issue. I believe mod_wsgi doesn't
have the issue.
Try to switch mod_wsgi. Otherwise, please try the following patch
(sorry, untested).
diff --git a/trac/web/modpython_frontend.py b/trac/web/modpython_frontend.py
index 60daa89..bddc0ae 100644
--- a/trac/web/modpython_frontend.py
+++ b/trac/web/modpython_frontend.py
@@ -39,6 +39,8 @@ from trac.web.wsgi import WSGIGateway, _ErrorsWrapper
class InputWrapper(object):
+ CHUNK_SIZE = 8192
+
def __init__(self, req):
self.req = req
@@ -49,7 +51,17 @@ class InputWrapper(object):
return self.req.read(size)
def readline(self, size=-1):
- return self.req.readline(size)
+ if size >= 0:
+ return self.req.readline(size)
+ else:
+ # avoid MemoryError when an uploaded file is huge
+ buf = []
+ while True:
+ line = self.req.readline(self.CHUNK_SIZE)
+ buf.append(line)
+ if not line or line.endswith('\n'):
+ break
+ return ''.join(buf)
def readlines(self, hint=-1):
return self.req.readlines(hint)
--
Jun Omae <[email protected]> (大前 潤)
--
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.