Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: write() argument must be str, not bytes (While handling error) #448

Closed
schneidersoft opened this issue Mar 8, 2018 · 7 comments
Assignees

Comments

@schneidersoft
Copy link
Contributor

Using python3 and webpy Version: 0.40.dev1

There is an issue when a specific error occurs that triggers another error.

something like:
jdata = json.loads(web.data())
#say the key data does not exist
foo = jdata['data']

Will cause a never ending error spiral

KeyError: 'data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "env/lib/python3.6/site-packages/web/application.py", line 255, in process
return p(lambda: process(processors))
File "brase/brase.py", line 186, in load_sqlachemy
return handler()
File "env/lib/python3.6/site-packages/web/application.py", line 255, in
return p(lambda: process(processors))
File "env/lib/python3.6/site-packages/web/application.py", line 264, in process
raise self.internalerror()
File "env/lib/python3.6/site-packages/web/application.py", line 545, in internalerror
return debugerror()
File "env/lib/python3.6/site-packages/web/debugerror.py", line 313, in debugerror
return web._InternalError(djangoerror())
File "env/lib/python3.6/site-packages/web/debugerror.py", line 303, in djangoerror
return t(exception_type, exception_value, frames)
File "env/lib/python3.6/site-packages/web/template.py", line 904, in call
return BaseTemplate.call(self, *a, **kw)
File "env/lib/python3.6/site-packages/web/template.py", line 831, in call
return self.t(*a, **kw)
File "env/lib/python3.6/site-packages/web/debugerror.py", line 193, in template

File "env/lib/python3.6/site-packages/web/webapi.py", line 364, in input
out = rawinput(_method)
File "env/lib/python3.6/site-packages/web/webapi.py", line 341, in rawinput
a = cgi.FieldStorage(fp=fp, environ=e, keep_blank_values=1)
File "/usr/lib/python3.6/cgi.py", line 561, in init
self.read_single()
File "/usr/lib/python3.6/cgi.py", line 740, in read_single
self.read_binary()
File "/usr/lib/python3.6/cgi.py", line 762, in read_binary
self.file.write(data)
TypeError: write() argument must be str, not bytes

@schneidersoft
Copy link
Contributor Author

It looks like weby is catching the key error and trying to build the error page but encounters another error while doing so... and another and so on.

@anandology anandology added the Bug label Apr 5, 2018
@anandology anandology self-assigned this Apr 5, 2018
@nokyan
Copy link

nokyan commented Jun 30, 2018

Is there something happening about this issue or is there workaround?

@anandology
Copy link
Member

anandology commented Jul 1, 2018

The work-around is to set:

web.config.debug = False

before creating the application.

Could you please share the a snippet of code to reproduce this issue?

@nokyan
Copy link

nokyan commented Jul 3, 2018

Seems my error is a bit different after all, sorry for that.

@iredmail
Copy link
Contributor

Hi @schneidersoft,

Could you please try again with the latest git version of web.py? we're busy fixing py3 compatibility issues, reply here with related error if it doesn't work.

@iredmail iredmail added this to the Python3 milestone Sep 13, 2019
@iredmail iredmail added the py3 label Sep 13, 2019
@schneidersoft
Copy link
Contributor Author

I was not able to reproduce the error on the latest master.

@iredmail
Copy link
Contributor

Thanks for the feedback. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants