[Twisted-Python] Twisted throws error for more or less no reason

Stefan Hesse stefan.hesse at tu-dortmund.de
Sat Aug 30 13:45:59 MDT 2014


Thank you!

the problem was caused by an unicode string. Changing this line:

|                              "attachment; filename=\"" + os.path.basename(video['title'] + "." + video['format']) + "\"")
to this:
||                              "attachment; filename=\"" + str(os.path.basename(video['title']) + "." + video['format']) + "\"")|

fixes it.

Thanks again!
On 30.08.2014 21:38, Wolfgang Rohdewald wrote:
> Am Samstag, 30. August 2014, 21:28:19 schrieb Stefan Hesse:
>> I hope it is ok when I post the link to stackoverflow, where I already
>> explained the problem.
>> File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 1001, in write
>     value = networkString('%s' % (value,))
>   File "/usr/lib/python2.7/dist-packages/twisted/python/compat.py", line 364, in networkString
>     raise TypeError("Can only pass-through bytes on Python 2")
>
> The source code:
>
>        if not isinstance(s, str):
>             raise TypeError("Can only pass-through bytes on Python 2")
>        # Ensure we're limited to ASCII subset:
>        s.decode('ascii')
>
>
> You could check if what you get here is not a str but unicode. You
> could change the error message to include the type and value of s
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20140830/5b7e000e/attachment-0002.html>


More information about the Twisted-Python mailing list