Appengine urlfetch debugging - python

I'm trying to do what should be a fairly simple url fetch with google appengine. However, it keeps failing.
result = urlfetch.fetch(url=apiurl, method=urlfetch.POST)
I also tried using httplib:
conn = httplib.HTTPConnection("api.eve-online.com")
conn.request("POST", "/char/CharacterSheet.xml.aspx", params, headers)
response = conn.getresponse()
self.response.out.write(response.read())
Both of these return very similar errors,
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 515, in __call__
handler.get(*groups)
File "C:\Users\Martin\Documents\google_appengine\martindevans\eveapi.py", line 24, in get
method=urlfetch.POST)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 241, in fetch
return rpc.get_result()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 530, in get_result
return self.__get_result_hook(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch.py", line 315, in _get_fetch_result
rpc.check_success()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub_map.py", line 502, in check_success
self.__rpc.CheckSuccess()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_rpc.py", line 149, in _WaitImpl
self.request, self.response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\apiproxy_stub.py", line 80, in MakeSyncCall
method(request, response)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch_stub.py", line 133, in _Dynamic_Fetch
deadline=deadline)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\api\urlfetch_stub.py", line 223, in _RetrieveURL
connection.request(method, full_path, payload, adjusted_headers)
File "C:\Python27\lib\httplib.py", line 946, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 986, in _send_request
self.putheader(hdr, value)
File "C:\Python27\lib\httplib.py", line 924, in putheader
str = '%s: %s' % (header, '\r\n\t'.join(values))
TypeError: sequence item 0: expected string, int found
I have no idea what's going on here. I'm not providing any sequences to the urlfetch method, so I'm unsure where to start debugging this.
edit: As asked, here are the headers:
headers = { "Content-type": "application/x-www-form-urlencoded" }
This can't be the problem though, because the first approach doesn't even set any headers!

Are you using Python 2.7 ? It supports only 2.5.2. While 2.6 mostly works, 2.7 don't.

Related

error while installing pip for windows 8 (hebrew)

Hi Im trying to install pip on my pc - windows 8 in hebrew.
I installed python 2.7. I added python to my path.
I ran some random printing in python file and its work. so python is ok.
when i try to install get-pip.py I get this error:
C:\Users\yogi>python get-pip.py
Exception:
Traceback (most recent call last):
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\basecommand.py",
line 232, in main
status = self.run(options, args)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\commands\install.
py", line 339, in run
requirement_set.prepare_files(finder)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\req\req_set.py",
line 235, in prepare_files
req_to_install, self.upgrade)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\index.py", line 3
05, in find_requirement
page = self._get_page(main_index_url, req)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\index.py", line 7
83, in _get_page
return HTMLPage.get_page(link, req, session=self.session)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\index.py", line 8
72, in get_page
"Cache-Control": "max-age=600",
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
sessions.py", line 473, in get
return self.request('GET', url, **kwargs)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\download.py", lin
e 365, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
sessions.py", line 461, in request
resp = self.send(prep, **send_kwargs)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
sessions.py", line 610, in send
r.content
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
models.py", line 728, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes
()
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
models.py", line 653, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
packages\urllib3\response.py", line 256, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\requests\
packages\urllib3\response.py", line 186, in read
data = self._fp.read(amt)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\cachecont
rol\filewrapper.py", line 54, in read
self.__callback(self.__buf.getvalue())
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\cachecont
rol\controller.py", line 213, in cache_response
self.serializer.dumps(request, response, body=body),
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\download.py", lin
e 268, in set
return super(SafeFileCache, self).set(*args, **kwargs)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\cachecont
rol\caches\file_cache.py", line 83, in set
with FileLock(name) as lock:
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\lockfile\
mkdirlockfile.py", line 18, in __init__
LockBase.__init__(self, path, threaded, timeout)
File "c:\users\yogi\appdata\local\temp\tmppowtnc\pip.zip\pip\_vendor\lockfile\
__init__.py", line 189, in __init__
hash(self.path)))
File "C:\Python27\lib\ntpath.py", line 84, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 0: ordinal
not in range(128)
any help would appreciated
Thought you may wanna try these since you are installing it in Hebrew.
1.) Open path "C:\Python27\Lib\" and search for python file "mimetypes.py".
2.) Open and Edit that file. Search for line "default_encoding = sys.getdefaultencoding()"
3.) And add these lines before the searched line in (step 2):
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
The UnicodeDecode Error might be because you are using wrong version of get-pip.py.
All the strings in Python3 are unicode by default, but in Python2 it is not so.
If you are trying to use get-pip of Python3 with Python2, it might likely be the cause of your error.Try checking for/ obtaining the correct version! :)

Google GMail API `installed` app shows IOError 13 from module SSL.py w/o sudo

I am playing around with GMAIL API to create an app to send auto emails from my server. Running my application as a simple user has the following results:
pankgeorg#snf-25181:~/tomotech/gmailer$ python mailer.py
Traceback (most recent call last):
File "mailer.py", line 36, in <module>
gmail_service = build('gmail', 'v1', http=http)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.3.1-py2.7.egg/googleapiclient/discovery.py", line 198, in build
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/client.py", line 547, in new_request
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1593, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1335, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1257, in _conn_request
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1021, in connect
self.disable_ssl_certificate_validation, self.ca_certs)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 80, in _ssl_wrap_socket
cert_reqs=cert_reqs, ca_certs=ca_certs)
File "/usr/lib/python2.7/ssl.py", line 886, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 496, in __init__
self._context.load_verify_locations(ca_certs)
IOError: [Errno 13] Permission denied
On the other hand, running with sudo works perfectly
pankgeorg#snf-25181:~/tomotech/gmailer$ sudo python mailer.py
Message Id: 14ad0aea05e*****
To be completely honest, in order to authenicate using --noauth_local_webserver, I run the command with sudo, authenticated and chown the gmail.storage to myself again.
Also, I installed using easy_install because pip install was giving me the following error:
pankgeorg#snf-25181:~/tomotech/gmailer$ sudo pip install --upgrade google_api_python_client
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1096, in prepare_files
req_to_install, self.upgrade)
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_page
session=self.session,
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 670, in get_page
resp = session.get(url, headers={"Accept": "text/html"})
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 506, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 168, in resolve_redirects
allow_redirects=False,
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/adapters.py", line 330, in send
timeout=timeout
File "/usr/local/lib/python2.7/dist- packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 480, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 285, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 826, in send
self.sock.sendall(data)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 323, in sendall
return self.connection.sendall(data)
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 969, in sendall
raise TypeError("buf must be a byte string")
TypeError: buf must be a byte string
Storing debug log for failure in /root/.pip/pip.logrom oath2client import tool
It is my understanding that the root of the problem is the same in both cases.
I also have to note that my laptop (on which I can authenticate normally, on webbrowser, instead of --noauth_local_webserver) it works just fine, even though the installation is done the same way (the problem with pip appears there too).
Thanks in advance and sorry for the long post!
Tutorials I used:
parse arg
code for sending mails
application body is pretty much the quickstart for gmail api.
The httplib2 installer sets incorrect permissions for its httplib2/cacerts.txt file. One solution is to simply make its files readable by anyone by running
chmod o+r -R /usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg
However, it may be better to uninstall the version installed by pip, and use your operating system's package manager instead, which probably has the correct permissions for all files. On Debian, this could be accomplished with
pip uninstall httplib2
apt-get install python-httplib2

Cannot use Google Native Client SDK on Windows 7

I am trying Google's Native Client SDK.
OS is Windows 7, I've already installed python 2.7.9 and setup the environment variable path accordingly.
I also downloaded nacl_sdk.zip from https://developer.chrome.com/native-client/sdk/download and extracted it.
However, as I run the command "naclsdk list" as it is described on the download page, I got the following messages:
C:\Temp\nacl_sdk>naclsdk list
Traceback (most recent call last):
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 759, in
sys.exit(main(sys.argv[1:]))
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 752, in main
InvokeCommand(args)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 741, in InvokeCommand
command(options, args[1:], config)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 510, in Update
manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources())
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 238, in LoadManifestFromURLs
url_stream = UrlOpen(url)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 114, in UrlOpen
return url_opener.open(request)
File "C:\python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
Traceback (most recent call last):
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 759, in
sys.exit(main(sys.argv[1:]))
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 752, in main
InvokeCommand(args)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 741, in InvokeCommand
command(options, args[1:], config)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 444, in List
manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources())
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 238, in LoadManifestFromURLs
url_stream = UrlOpen(url)
File "C:\Temp\nacl_sdk\sdk_tools\sdk_update_main.py", line 114, in UrlOpen
return url_opener.open(request)
File "C:\python27\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\python27\lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\python27\lib\urllib2.py", line 1240, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
In fact, no matter what command I use, it doesn't seem to work at all.
Does anyone know the solution?
having the same issue.
Found this link: http://forums.udacity.com/questions/100247273/urllib2-may-be-a-bug-to-find-the-appropriate-method-overload
Solved by editing python27/lib/urllib2.py...
Hope it helps!

Urllib2 - Django - Broken Pipe

I am new to Django and I am experiencing some troubles posting data to a django webapp.
On the django side I have a form (backed by couchdb - couchdbkit django ext.).
On the client side I post data with urllib2, in bulk (going through a list of data to post one by one)
data = urllib.urlencode(param)
req = urllib2.Request(OBJECT_SERVICE_URL + '/objects/create/', data)
req.add_header('Content-type', 'application/x-www-form-urlencoded')
res = urllib2.urlopen(req)
res.close()
After one record (one post passing), it get the message below, running again the next line passes and I have again this message :
res = urllib2.urlopen(req)
File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR
The server says :
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 284, in run
self.finish_response()
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 324, in finish_response
self.write(data)
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 420, in write
self._write(data)
File "/usr/lib/python2.6/socket.py", line 318, in write
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 59571)
self.flush()
File "/usr/lib/python2.6/socket.py", line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "/usr/lib/python2.6/SocketServer.py", line 283, in _handle_request_noblock
----------------------------------------
self.process_request(request, client_address)
File "/usr/lib/python2.6/SocketServer.py", line 309, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 570, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/usr/lib/python2.6/SocketServer.py", line 618, in __init__
self.finish()
File "/usr/lib/python2.6/SocketServer.py", line 661, in finish
self.wfile.flush()
File "/usr/lib/python2.6/socket.py", line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe
I must state that I am working on the embedded django development web server...
And here is the output of the test :
======================================================================
ERROR: test_create_object (objects.tests.ObjectAppTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/patrick/workspace_py/objects/tests.py", line 21, in test_create_object
rs = c.post('/objects/create/', param)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 455, in post
response = super(Client, self).post(path, data=data, content_type=content_type, **extra)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 256, in post
return self.request(**r)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 387, in request
response = self.handler(environ)
File "/usr/local/lib/python2.6/dist-packages/django/test/client.py", line 84, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception
return callback(request, **param_dict)
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/coffin/views/defaults.py", line 34, in server_error
content = render_to_string(template_name, Context({}))
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/coffin/template/loader.py", line 50, in render_to_string
template = get_template(template_name)
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/coffin/template/loader.py", line 24, in get_template
return env.get_template(template_name)
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/jinja2/environment.py", line 719, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/jinja2/environment.py", line 693, in _load_template
template = self.loader.load(self, name, globals)
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/jinja2/loaders.py", line 115, in load
source, filename, uptodate = self.get_source(environment, name)
File "/home/patrick/workspace_py/env/lib/python2.6/site-packages/jinja2/loaders.py", line 377, in get_source
raise TemplateNotFound(template)
TemplateNotFound: 500.html
----------------------------------------------------------------------
Does anyone know how to fix ?
Patrick
Some times I found weird errors and quick connection resets using development server (like in your log). If your application is about http, REST and webservices you should use Apache or Gunicorn so you feel a more realistic enviroment while developing.

FancyURLOpener failing since moving to python 3.1.2

I had an application that was downloading a .CSV file from a password-protected website then processing it futher.
I was using FancyURLOpener, and simply hardcoding the username and password. (Obviously, security is not a high priority in this particular instance).
Since downloading Python 3.1.2, this code has stopped working. After fixing the obvious issue of it now being in the "request" namespace, it's crashing in a less obvious way.
Does anyone know of the changes that have happened to the implementation, and how to use it now? The documentation seems to be short of examples.
Here is a cut down version of the code:
import urllib.request;
class TracOpener (urllib.request.FancyURLopener) :
def prompt_user_passwd(self, host, realm) :
return ('andrew_ee', '_my_unenctryped_password')
csvUrl='http://mysite/report/19?format=csv#USER=fred_nukre'
opener = TracOpener();
f = opener.open(csvUrl); # This is failing!
s = f.read();
f.close();
s;
For the sake of completeness, here's the entire call stack:
Traceback (most recent call last):
File "C:\reporting\download_csv_file.py", line 12, in <module>
f = opener.open(csvUrl);
File "C:\Program Files\Python31\lib\urllib\request.py", line 1454, in open
return getattr(self, name)(url)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1628, in open_http
return self._open_generic_http(http.client.HTTPConnection, url, data)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1624, in _open_generic_http
response.status, response.reason, response.msg, data)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1640, in http_error
result = method(url, fp, errcode, errmsg, headers)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1878, in http_error_401
return getattr(self,name)(url, realm)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1950, in retry_http_basic_auth
return self.open(newurl)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1454, in open
return getattr(self, name)(url)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1628, in open_http
return self._open_generic_http(http.client.HTTPConnection, url, data)
File "C:\Program Files\Python31\lib\urllib\request.py", line 1590, in _open_generic_http
auth = base64.b64encode(user_passwd).strip()
File "C:\Program Files\Python31\lib\base64.py", line 56, in b64encode
raise TypeError("expected bytes, not %s" % s.__class__.__name__)
TypeError: expected bytes, not str
It's a known bug: http://bugs.python.org/issue8123

Categories