Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42248
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'correct.': 0.07; 'problem:': 0.07; '"if': 0.09; '"or': 0.09; 'data:': 0.09; 'encode': 0.09; 'exception.': 0.09; 'method,': 0.09; 'mode:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'bug': 0.12; '<>.': 0.14; '!!!!': 0.16; '"b"': 0.16; '%r"': 0.16; 'attribute,': 0.16; 'attribute.': 0.16; 'file-like': 0.16; 'iterable,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-dialin.net': 0.16; 'send()': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:X-Complaints-To:1': 0.27; 'url:bugs': 0.29; 'raise': 0.29; 'mode': 0.30; 'file': 0.32; 'url:python': 0.33; 'guess': 0.33; 'skip:d 20': 0.34; 'problem': 0.35; 'except': 0.35; 'objects': 0.35; 'false': 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'break': 0.61; 'real': 0.63; 'analysis': 0.75; 'discovered': 0.83; 'investigated': 0.84; 'subject:skip:H 10': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: HTTPConnection.send |
| Date | Fri, 29 Mar 2013 15:49:05 +0100 |
| Organization | None |
| References | <64ae9389-ef1b-4852-94a9-7cc5c228238c@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p508492c7.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3951.1364568526.2939.python-list@python.org> (permalink) |
| Lines | 50 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1364568526 news.xs4all.nl 6883 [2001:888:2000:d::a6]:50039 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:42248 |
Show key headers only | View raw
dspublic@freemail.hu wrote:
> I have a problem with HTTPConnection object send() method (pyver3.3.1). I
> want to send data from file-like object with HTTPConnection.send( f ), and
> I get a "data should be a bytes-like object or an iterable, ..."
> exception. I have investigated a send method, and discovered a problem: if
> data has a read attribute, send it , and try send it again with
> self.sock.sendall(data). My opinion is need an "else" after the "if
> hasattr(data, "read")"
>
> Please, somebody help me. Does it a real BUG or my mistake?
I think your analysis is correct. Please file a bug report on
<http://bugs.python.org>.
> http.client.py >
>
> if hasattr(data, "read") :
> if self.debuglevel > 0:
> print("sendIng a read()able")
> encode = False
> try:
> mode = data.mode
> except AttributeError:
> # io.BytesIO and other file-like objects don't have a
> # `mode` attribute.
> pass
> else:
> if "b" not in mode:
> encode = True
> if self.debuglevel > 0:
> print("encoding file using iso-8859-1")
> while 1:
> datablock = data.read(blocksize)
> if not datablock:
> break
> if encode:
> datablock = datablock.encode("iso-8859-1")
> self.sock.sendall(datablock)
> ELSE: #!!!! i guess missing !!!!
> try:
> self.sock.sendall(data)
> except TypeError:
> if isinstance(data, collections.Iterable):
> for d in data:
> self.sock.sendall(d)
> else:
> raise TypeError("data should be a bytes-like object "
> "or an iterable, got %r" % type(data))
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
HTTPConnection.send dspublic@freemail.hu - 2013-03-29 05:27 -0700 Re: HTTPConnection.send dspublic@freemail.hu - 2013-03-29 06:40 -0700 Re: HTTPConnection.send Peter Otten <__peter__@web.de> - 2013-03-29 15:49 +0100 Re: HTTPConnection.send Chris Angelico <rosuav@gmail.com> - 2013-03-30 01:58 +1100 Re: HTTPConnection.send dspublic@freemail.hu - 2013-03-29 09:32 -0700
csiph-web