[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-08-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

r83416 broke the 3.1 buildbots.


==
ERROR: test_userpass_inurl (test.test_urllib.urlopen_HttpTests)
--
Traceback (most recent call last):
  File 
/srv/buildbot/buildarea/3.1.bolen-ubuntu/build/Lib/test/test_urllib.py, line 
197, in test_userpass_inurl
fp = urlopen(http://user:p...@python.org/;)
  File 
/srv/buildbot/buildarea/3.1.bolen-ubuntu/build/Lib/test/test_urllib.py, line 
33, in urlopen
return opener.open(url)
  File /srv/buildbot/buildarea/3.1.bolen-ubuntu/build/Lib/urllib/request.py, 
line 1468, in open
return getattr(self, name)(url)
  File /srv/buildbot/buildarea/3.1.bolen-ubuntu/build/Lib/urllib/request.py, 
line 1642, in open_http
return self._open_generic_http(http.client.HTTPConnection, url, data)
  File /srv/buildbot/buildarea/3.1.bolen-ubuntu/build/Lib/urllib/request.py, 
line 1612, in _open_generic_http
headers[Authorization] =  Basic %s % auth
BytesWarning: str() on a bytes instance

--
nosy: +pitrou
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-08-04 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

Surprising that it was not observed in my system (Ubuntu).

There was mistake where in the bytes value was being coerced to a string.
bauth = Basic: %s % auth // with auth was bytes.

Fixed it in r83729 and r83730.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-08-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Yes, you would have had to use python -bb to evidence it:

$ ./python -bb
Python 3.2a1+ (py3k:83718M, Aug  4 2010, 17:10:53) 
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.
 b == 
Traceback (most recent call last):
  File stdin, line 1, in module
BytesWarning: Comparison between bytes and string

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-08-01 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

Fixed in r83415 and r83416.

--
resolution: accepted - fixed
stage: unit test needed - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-07-23 Thread Dmitry Jemerov

Dmitry Jemerov intelliy...@gmail.com added the comment:

Patch (with unittest) attached.

--
keywords: +patch
Added file: http://bugs.python.org/file18139/8123.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-03-14 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

Yes, that seems to be case. When username:password is present in the url 
string, opener bytes string not being passed to the base64encode function.

--
assignee:  - orsenthil
nosy: +orsenthil
resolution:  - accepted

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-03-13 Thread Dmitry Jemerov

Dmitry Jemerov intelliy...@gmail.com added the comment:

from urllib.request import *

opener = FancyURLopener()
opener.retrieve(http://username:passw...@google.com/index.html;, index.html)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-03-12 Thread Dmitry Jemerov

New submission from Dmitry Jemerov intelliy...@gmail.com:

I'm trying to download a file from a site using HTTP authentication. I'm 
subclassing FancyURLOpener, returning my credentials from the 
prompt_user_passwd() method, and using opener.retrieve() to download the file. 
I get the following error:

  File C:/JetBrains/IDEA/build/eap/downandup.py, line 36, in download
opener.retrieve(url, os.path.join(target_path, name))
  File C:\Python31\lib\urllib\request.py, line 1467, in retrieve
fp = self.open(url, data)
  File C:\Python31\lib\urllib\request.py, line 1435, in open
return getattr(self, name)(url)
  File C:\Python31\lib\urllib\request.py, line 1609, in open_http
return self._open_generic_http(http.client.HTTPConnection, url, data)
  File C:\Python31\lib\urllib\request.py, line 1605, in _open_generic_http
response.status, response.reason, response.msg, data)
  File C:\Python31\lib\urllib\request.py, line 1621, in http_error
result = method(url, fp, errcode, errmsg, headers)
  File C:\Python31\lib\urllib\request.py, line 1859, in http_error_401
return getattr(self,name)(url, realm)
  File C:\Python31\lib\urllib\request.py, line 1931, in retry_http_basic_auth
return self.open(newurl)
  File C:\Python31\lib\urllib\request.py, line 1435, in open
return getattr(self, name)(url)
  File C:\Python31\lib\urllib\request.py, line 1609, in open_http
return self._open_generic_http(http.client.HTTPConnection, url, data)
  File C:\Python31\lib\urllib\request.py, line 1571, in _open_generic_http
auth = base64.b64encode(user_passwd).strip()
  File C:\Python31\lib\base64.py, line 56, in b64encode
raise TypeError(expected bytes, not %s % s.__class__.__name__)
TypeError: expected bytes, not str

The problem happens because _open_generic_http extracts the user password from 
the string URL, and passes the string to the b64encode method, which only 
accepts bytes and not strings. The problem happens with Python 3.1.1 for me, 
but as far as I can see it's still not fixed in the py3k branch as of now.

--
components: Library (Lib)
messages: 100938
nosy: Dmitry.Jemerov
severity: normal
status: open
title: TypeError in urllib when trying to use HTTP authentication
versions: Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8123] TypeError in urllib when trying to use HTTP authentication

2010-03-12 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Could you provide a script (or even better a unittest) to reproduce the problem?

--
nosy: +ezio.melotti
priority:  - normal
stage:  - test needed
type:  - behavior
versions: +Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8123
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com