New submission from W. Trevor King:

Avoid:

    Traceback (most recent call last):
      File "setup.py", line 61, in <module>
        'html2text (>=3.0.1)',
      File "/.../python3.2/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/.../python3.2/distutils/dist.py", line 917, in run_commands
        self.run_command(cmd)
      File "/.../python3.2/distutils/dist.py", line 936, in run_command
        cmd_obj.run()
      File "/.../python3.2/distutils/command/upload.py", line 66, in run
        self.upload_file(command, pyversion, filename)
      File "/.../python3.2/distutils/command/upload.py", line 201, in 
upload_file
        msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
    TypeError: sequence item 1: expected str instance, bytes found

by converting the bytes returned by HTTPResponse.read [1] to a string
before joinging it with other strings.  HTTPResponse.headers supports
the Message interface [2], so we can use get_param to extract the
charset [3], falling back on ISO-8859-1 [4].

[1]: 
http://docs.python.org/3/library/http.client.html#http.client.HTTPResponse.read
[2]: http://docs.python.org/3/library/http.client.html#httpmessage-objects
[3]: 
http://docs.python.org/3/library/email.message.html#email.message.Message.get_param
[4]: http://tools.ietf.org/html/rfc2616#section-3.7.1

----------
assignee: eric.araujo
components: Distutils
files: show-response-string.patch
keywords: patch
messages: 199489
nosy: eric.araujo, labrat, tarek
priority: normal
severity: normal
status: open
title: distutils/command/upload.py show response gives: TypeError: sequence 
item 1: expected str instance, bytes found
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file32045/show-response-string.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19226>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to