You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cgitb with Py3: TypeError: 'str' does not support the buffer interface #66934
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2014-10-28.04:30:46.251>created_at=<Date2014-10-27.18:41:35.007>labels= ['invalid', 'library', 'type-crash']
title="cgitb with Py3: TypeError: 'str' does not support the buffer interface"updated_at=<Date2014-10-28.04:30:46.250>user='https://bugs.python.org/wrohdewald'
The attached script works with Python2.7. With Python3.4, it produces
Traceback (most recent call last):
File "/usr/lib/python3.4/cgitb.py", line 268, in __call__self.handle((etype, evalue, etb))
File "cgibug.py", line 12, in handle
cgitb.Hook.handle(self, info)
File "/usr/lib/python3.4/cgitb.py", line 273, in handleself.file.write(reset())
TypeError: 'str' does not support the buffer interface
When replacing the file mode 'wb' with 'w', it produces this failure:
File "/usr/lib/python3.4/cgitb.py", line 288, in handle
self.file.write(doc + '\n')
TypeError: can't concat bytes to str
The script works as expected with Python2.7 with both file modes.
Activity
wrohdewald commentedon Oct 27, 2014
The attached script works with Python2.7. With Python3.4, it produces
When replacing the file mode 'wb' with 'w', it produces this failure:
File "/usr/lib/python3.4/cgitb.py", line 288, in handle
self.file.write(doc + '\n')
TypeError: can't concat bytes to str
The script works as expected with Python2.7 with both file modes.
amauryfa commentedon Oct 27, 2014
html is text, so the file mode should be 'w'.
But I don't reproduce the behavior with Python version v3.4.2.
Which version are you using exactly?
bitdancer commentedon Oct 27, 2014
I don't think what html is is relevant here. Hook is going to be dealing with strings, though, so 'w' is indeed correct.
The script works fine for me as well. (Also tested it on 3.3.2 since I had it laying around, so it's not a recent bugfix).
wrohdewald commentedon Oct 28, 2014
This now works with mode 'w' and after reinstalling the packages. My Python is 3.4.0 (ubuntu).