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

HTTPConnection.send #61775

Closed
dspublicfreemailhu mannequin opened this issue Mar 29, 2013 · 3 comments
Closed

HTTPConnection.send #61775

dspublicfreemailhu mannequin opened this issue Mar 29, 2013 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@dspublicfreemailhu
Copy link
Mannequin

dspublicfreemailhu mannequin commented Mar 29, 2013

BPO 17575
Nosy @Rosuav

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 = None
closed_at = <Date 2013-04-14.20:13:05.000>
created_at = <Date 2013-03-29.16:25:03.779>
labels = ['type-bug']
title = 'HTTPConnection.send'
updated_at = <Date 2013-04-14.20:13:04.998>
user = 'https://bugs.python.org/dspublicfreemailhu'

bugs.python.org fields:

activity = <Date 2013-04-14.20:13:04.998>
actor = 'dspublic@freemail.hu'
assignee = 'none'
closed = True
closed_date = <Date 2013-04-14.20:13:05.000>
closer = 'dspublic@freemail.hu'
components = []
creation = <Date 2013-03-29.16:25:03.779>
creator = 'dspublic@freemail.hu'
dependencies = []
files = []
hgrepos = []
issue_num = 17575
keywords = []
message_count = 3.0
messages = ['185501', '186794', '186949']
nosy_count = 3.0
nosy_names = ['Rosuav', 'dspublic@freemail.hu', 'Stephen.Tu']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue17575'
versions = ['Python 3.2', 'Python 3.3']

@dspublicfreemailhu
Copy link
Mannequin Author

dspublicfreemailhu mannequin commented Mar 29, 2013

http.client modul, HTTPConnection object, send method

Missing an "else" for self.sock.sendall(data) try block.

...
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: #missing else
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))

@dspublicfreemailhu dspublicfreemailhu mannequin added the type-bug An unexpected behavior, bug, or error label Mar 29, 2013
@StephenTu
Copy link
Mannequin

StephenTu mannequin commented Apr 13, 2013

I don't think this is a bug anymore in the codebase- looking at Lib/http/client.py, if hasattr(data, "read") is true, then the branch will return unconditionally.

        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)
            return

@dspublicfreemailhu
Copy link
Mannequin Author

dspublicfreemailhu mannequin commented Apr 14, 2013

Thank you Stephen.Tu for information. I think so, the "return" has been found ;-)

@dspublicfreemailhu dspublicfreemailhu mannequin closed this as completed Apr 14, 2013
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

0 participants