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

urllib2 cannot make POST with utf-8 content #58765

Closed
ghost opened this issue Apr 12, 2012 · 3 comments
Closed

urllib2 cannot make POST with utf-8 content #58765

ghost opened this issue Apr 12, 2012 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 12, 2012

BPO 14560
Nosy @orsenthil, @ezio-melotti

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 2012-04-12.08:27:40.549>
created_at = <Date 2012-04-12.08:11:59.043>
labels = ['expert-unicode']
title = 'urllib2 cannot make POST with utf-8 content'
updated_at = <Date 2012-04-12.11:15:39.920>
user = None

bugs.python.org fields:

activity = <Date 2012-04-12.11:15:39.920>
actor = 'orsenthil'
assignee = 'none'
closed = True
closed_date = <Date 2012-04-12.08:27:40.549>
closer = '\xd0\x90\xd0\xbd\xd0\xb4\xd1\x80\xd0\xb5\xd0\xb9.\xd0\xa0'
components = ['Unicode']
creation = <Date 2012-04-12.08:11:59.043>
creator = '\xd0\x90\xd0\xbd\xd0\xb4\xd1\x80\xd0\xb5\xd0\xb9.\xd0\xa0'
dependencies = []
files = []
hgrepos = []
issue_num = 14560
keywords = []
message_count = 3.0
messages = ['158114', '158115', '158116']
nosy_count = 3.0
nosy_names = ['orsenthil', 'ezio.melotti', '\xd0\x90\xd0\xbd\xd0\xb4\xd1\x80\xd0\xb5\xd0\xb9.\xd0\xa0']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue14560'
versions = ['Python 2.7']

@ghost
Copy link
Author

ghost commented Apr 12, 2012

Issue can be found only in 2.7, in 2.6.6 it works

System:
Linux strix 3.2.14-1-ARCH x86_64
Python information:
Python 2.7.2 (default, Jan 31 2012, 13:19:49) [GCC 4.6.2 20120120 (prerelease)] on linux2

Snippet to reproduce error:

# -*- encoding: utf-8 -*-
import urllib2

request = urllib2.Request('http://google.com', u'Контент', {'Content-Type': 'text/plain; charset=utf-8'})
urllib2.urlopen(request).read()

Stacktrace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 394, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 412, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 372, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1199, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1168, in do_open
    h.request(req.get_method(), req.get_selector(), req.data, headers)
  File "/usr/lib/python2.7/httplib.py", line 955, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 989, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 951, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 815, in _send_output
    self.send(message_body)
  File "/usr/lib/python2.7/httplib.py", line 787, in send
    self.sock.sendall(data)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)

Repository owner added the topic-unicode label Apr 12, 2012
@ghost
Copy link
Author

ghost commented Apr 12, 2012

# -*- encoding: utf-8 -*-
import urllib2

request = urllib2.Request('http://google.com', u'Контент'.encode("utf-8"), {'Content-Type': 'text/plain; charset=utf-8'})
urllib2.urlopen(request).read()

Repository owner closed this as completed Apr 12, 2012
@ghost
Copy link
Author

ghost commented Apr 12, 2012

Sorry. My fault

@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
Projects
None yet
Development

No branches or pull requests

1 participant