Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem when applying Patch from issue1424152 to get https over authenticating proxies working with urllib2 in Python 2.5

27 views
Skip to first unread message

tvashtar

unread,
Jul 20, 2009, 11:11:34 AM7/20/09
to
Hi,
I'm trying to get https requests working through an authenticating
proxy with urllib2 in Python 2.5, I'm aware that this isn't supported
"out of the box", so applied the patch http://bugs.python.org/file9753/http-tunnel-urllib
linked from http://bugs.python.org/issue1424152 , my baseline test
program is the following:

p = "user:pass@proxy:port"
proxy_handler = urllib2.ProxyHandler({"http": p, "https": p})
urllib2.install_opener( urllib2.build_opener( urllib2.HTTPHandler,

urllib2.HTTPSHandler,

proxy_handler))

request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

Unfortunately this doesn't work, the call stack being:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 374, in open
response = self._open(req, data)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 392, in _open
'_open', req)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 353, in _call_chain
result = func(*args)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1108, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1075, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error (1, 'error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown protocol')>

Does anyone know why I might be hitting this issue?
Any help is greatly appreciated,
thanks

Nike

unread,
Jul 20, 2009, 11:42:15 AM7/20/09
to
On Jul 20, 11:11 pm, tvashtar <tvash...@gmail.com> wrote:
> Hi,
> I'm trying to get https requests working through an authenticating
> proxy with urllib2 in Python 2.5, I'm aware that this isn't supported
> "out of the box", so applied the patchhttp://bugs.python.org/file9753/http-tunnel-urllib
> linked fromhttp://bugs.python.org/issue1424152, my baseline test

hi!
It's looks like a ssl error . Under the following step to help u :
1. takes a simple code to confirm your pupose without ssl protocol.
2. to confirm python version and extended libs work well
3. to confirm ssl work well.

goog luck!

nikekoo

tvashtar

unread,
Jul 20, 2009, 1:58:53 PM7/20/09
to
On Jul 20, 4:42 pm, Nike <nike...@gmail.com> wrote:
> hi!
>  It's looks like a ssl error . Under the following step to help u :
>   1. takes a simple code to confirm your pupose without ssl protocol.
>   2. to confirm python version and extended libs work well
>   3. to confirm ssl work well.
>
> goog luck!
>
> nikekoo

I've reduced my code to the following:

import urllib2

p = "https://user:pass@myproxy:port"
proxy_handler = urllib2.ProxyHandler({"https": p})
urllib2.install_opener(urllib2.build_opener(proxy_handler))


request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

and it is now failing with:

Traceback (most recent call last):

File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem

\test.py", line 12, in <module>
response = urllib2.urlopen(request)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 379, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'_open', req)
File "C:\Python25\lib\urllib2.py", line 358, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1115, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python25\lib\urllib2.py", line 1082, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error Tunnel connection failed: 407 Proxy
Authentication Required>

I thought the proxy_handler should take care of the authentication?

Thanks for your help

harish....@gmail.com

unread,
Dec 10, 2013, 8:35:09 AM12/10/13
to
Is this issue fixed. I am also facing the same issue of tunneling in https request. Please suggest how to proceed further

Chris Angelico

unread,
Dec 10, 2013, 8:47:27 AM12/10/13
to pytho...@python.org
On Wed, Dec 11, 2013 at 12:35 AM, <harish....@gmail.com> wrote:
> Is this issue fixed. I am also facing the same issue of tunneling in https request. Please suggest how to proceed further

You're responding to something from 2009. It's highly likely things
have changed.

Does the same code cause an error in Python 2.7? That would be the
first thing to check.

Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:

https://mail.python.org/mailman/listinfo/python-list

It's probably a good idea also to search the bug tracker before
posting. It may well be that this has been fixed, in which case the
tracker issue would tell you when the fix went out. Of course, it may
also state that it's not a bug, in which case you'd know why.

http://bugs.python.org/

ChrisA

Mark Lawrence

unread,
Dec 10, 2013, 8:48:09 AM12/10/13
to pytho...@python.org
Please read the whole history of this here
http://bugs.python.org/issue1424152

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Mark Lawrence

unread,
Dec 10, 2013, 9:06:19 AM12/10/13
to pytho...@python.org
On 10/12/2013 13:47, Chris Angelico wrote:
> On Wed, Dec 11, 2013 at 12:35 AM, <harish....@gmail.com> wrote:
>> Is this issue fixed. I am also facing the same issue of tunneling in https request. Please suggest how to proceed further
>
> You're responding to something from 2009. It's highly likely things
> have changed.
>

Says who? Sadly IMHO this has been one of the worst aspects of Python
development. I've seen 10 year old bugs happily sitting on the bug
tracker. Thankfully that is slowly changing. The core mentorship
program is helping, plus the gradual reduction in the number of versions
that need supporting as 2.6 is now out of support and we move towards
3.4. However there are still 4275 open issues on the bug tracker.
Anyone up to help out, the pay and perks are really good? :)

Chris Angelico

unread,
Dec 10, 2013, 9:14:15 AM12/10/13
to pytho...@python.org
On Wed, Dec 11, 2013 at 1:06 AM, Mark Lawrence <bream...@yahoo.co.uk> wrote:
> On 10/12/2013 13:47, Chris Angelico wrote:
>>
>> On Wed, Dec 11, 2013 at 12:35 AM, <harish....@gmail.com> wrote:
>>>
>>> Is this issue fixed. I am also facing the same issue of tunneling in
>>> https request. Please suggest how to proceed further
>>
>>
>> You're responding to something from 2009. It's highly likely things
>> have changed.
>>
>
> Says who? Sadly IMHO this has been one of the worst aspects of Python
> development. I've seen 10 year old bugs happily sitting on the bug tracker.
> Thankfully that is slowly changing. The core mentorship program is helping,
> plus the gradual reduction in the number of versions that need supporting as
> 2.6 is now out of support and we move towards 3.4. However there are still
> 4275 open issues on the bug tracker. Anyone up to help out, the pay and
> perks are really good? :)

There've been two minor versions since the version cited in the post
(2.5), not counting Python 3 at all. It's definitely worth rechecking
on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
read the tracker issue, which in this case was known and needn't be
searched for, a fact that I missed noticing when I went reading.) Yes,
four years' worth of bug fixes does make it at least somewhat likely
that something's changed.

ChrisA

Mark Lawrence

unread,
Dec 10, 2013, 9:54:35 AM12/10/13
to pytho...@python.org
On 10/12/2013 14:14, Chris Angelico wrote:
> On Wed, Dec 11, 2013 at 1:06 AM, Mark Lawrence <bream...@yahoo.co.uk> wrote:
>> On 10/12/2013 13:47, Chris Angelico wrote:
>>>
>>> On Wed, Dec 11, 2013 at 12:35 AM, <harish....@gmail.com> wrote:
>>>>
>>>> Is this issue fixed. I am also facing the same issue of tunneling in
>>>> https request. Please suggest how to proceed further
>>>
>>>
>>> You're responding to something from 2009. It's highly likely things
>>> have changed.
>>>
>>
>> Says who? Sadly IMHO this has been one of the worst aspects of Python
>> development. I've seen 10 year old bugs happily sitting on the bug tracker.
>> Thankfully that is slowly changing. The core mentorship program is helping,
>> plus the gradual reduction in the number of versions that need supporting as
>> 2.6 is now out of support and we move towards 3.4. However there are still
>> 4275 open issues on the bug tracker. Anyone up to help out, the pay and
>> perks are really good? :)
>
> There've been two minor versions since the version cited in the post
> (2.5), not counting Python 3 at all. It's definitely worth rechecking
> on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
> read the tracker issue, which in this case was known and needn't be
> searched for, a fact that I missed noticing when I went reading.) Yes,
> four years' worth of bug fixes does make it at least somewhat likely
> that something's changed.
>
> ChrisA
>

How many minor versions since this was created on 2002-01-16 at 04:56
http://bugs.python.org/issue504219 ? The issue originally referenced
is closed, this is still open. Age on the bug tracker is no guarantee
of anything, except that the issue exists.

ru...@yahoo.com

unread,
Dec 10, 2013, 10:48:52 AM12/10/13
to
On 12/10/2013 06:47 AM, Chris Angelico wrote:
> On Wed, Dec 11, 2013 at 12:35 AM, <harish....@gmail.com> wrote:
> Also: You appear to be using Google Groups, which is the Mos Eisley of
> the newsgroup posting universe. You'll do far better to instead use
> some other means of posting, such as the mailing list:

Using Google Groups is also fine. I and many other posters here
use it. Chris and some others here dislike Google Groups and want
everyone to not use it, but that is their personal opinion.

If Google Groups is most convenient for you please feel free to
continue using it. You might want to take a look at this page
which describes how to reduce some of things that annoy people
like Chris:

https://wiki.python.org/moin/GoogleGroupsPython

Mark Lawrence

unread,
Dec 10, 2013, 11:22:47 AM12/10/13
to pytho...@python.org
There is no "you might want to" about it. There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.

rusi

unread,
Dec 10, 2013, 11:49:20 AM12/10/13
to
On Tuesday, December 10, 2013 9:52:47 PM UTC+5:30, Mark Lawrence wrote:
> On 10/12/2013 15:48, rurpy wrote:
> > On 12/10/2013 06:47 AM, Chris Angelico wrote:
> >> On Wed, Dec 11, 2013 at 12:35 AM, harish.barvekar wrote:
> >> Also: You appear to be using Google Groups, which is the Mos Eisley of
> >> the newsgroup posting universe. You'll do far better to instead use
> >> some other means of posting, such as the mailing list:
> > Using Google Groups is also fine. I and many other posters here
> > use it. Chris and some others here dislike Google Groups and want
> > everyone to not use it, but that is their personal opinion.
> > If Google Groups is most convenient for you please feel free to
> > continue using it. You might want to take a look at this page
> > which describes how to reduce some of things that annoy people
> > like Chris:
> > https://wiki.python.org/moin/GoogleGroupsPython

> There is no "you might want to" about it. There are two options here,
> either read and action the page so we don't see double spaced crap
> amongst other things, use another tool, or don't post.

There are 10 kinds of people in the world: those who understand
binary and those who dont.

Chris Angelico

unread,
Dec 10, 2013, 11:54:46 AM12/10/13
to pytho...@python.org
On Wed, Dec 11, 2013 at 3:49 AM, rusi <rusto...@gmail.com> wrote:
> There are 10 kinds of people in the world: those who understand
> binary and those who dont.

There are 10 kinds of people in the world: those who understand Gray
Code, those who don't, and those who confuse it with binary.

ChrisA

Mark Lawrence

unread,
Dec 10, 2013, 11:58:05 AM12/10/13
to pytho...@python.org
There are 10 kinds of people in the world: those who understand that
google groups sends out double spaced crap and those who don't.

ru...@yahoo.com

unread,
Dec 10, 2013, 11:59:53 AM12/10/13
to
On 12/10/2013 09:22 AM, Mark Lawrence wrote:
> On 10/12/2013 15:48, ru...@yahoo.com wrote:
> [...]
> There is no "you might want to" about it. There are two options here,
> either read and action the page so we don't see double spaced crap
> amongst other things, use another tool, or don't post.

Mark is one of the resident trolls here. Among his other traits
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).

Mark Lawrence

unread,
Dec 10, 2013, 12:05:49 PM12/10/13
to pytho...@python.org
That is entirely correct. I also spend a lot of my time defending the
indefensible, like defending people who use crap tools to send double
spaced crap around the whole world. Not.

Grant Edwards

unread,
Dec 10, 2013, 12:12:12 PM12/10/13
to
Let me pause and reflect on that for a moment...

--
Grant Edwards grant.b.edwards Yow! All of life is a blur
at of Republicans and meat!
gmail.com

David Robinow

unread,
Dec 10, 2013, 12:36:50 PM12/10/13
to pytho...@python.org
On Tue, Dec 10, 2013 at 11:59 AM, <ru...@yahoo.com> wrote:
> On 12/10/2013 09:22 AM, Mark Lawrence wrote:
...
> Mark is one of the resident trolls here. Among his other traits
> is his delusion that he is Lord High Commander of this list.
> Like with other trolls, the best advice is to ignore him (which
> I'm not doing this once as a public service).
Please don't do this. I can decide for myself whether I prefer to read
Mark's posts.
[By the way, I don't consider Mark Lawrence a troll. He's just a guy
who can't help himself. I've chosen not to listen any more but others
are entitled to their own choices.]+

ru...@yahoo.com

unread,
Dec 10, 2013, 1:15:55 PM12/10/13
to
On 12/10/2013 10:36 AM, David Robinow wrote:
> On Tue, Dec 10, 2013 at 11:59 AM, <ru...@yahoo.com> wrote:
>> On 12/10/2013 09:22 AM, Mark Lawrence wrote:
> ...
>> Mark is one of the resident trolls here. Among his other traits
>> is his delusion that he is Lord High Commander of this list.
>> Like with other trolls, the best advice is to ignore him (which
>> I'm not doing this once as a public service).
>
> Please don't do this. I can decide for myself whether I prefer to read
> Mark's posts.

I didn't post it for you, I posted it for the OP who
may be new here (or may not, I didn't check) and for
others from Google Groups who may erroneously think
that Mark/Chris et.al. have some kind of authority or
speak for everyone here.

Nor was it a suggestion to not read Mark's posts but
a suggestion to not add to the flamage.
0 new messages