Skip to content

Commit 1200179

Browse files
committed
Replace deprecated URLopener with OpenerDirector
We lose the 'Accept: */*' header but this does not seem to matter
1 parent 8d5218e commit 1200179

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/test.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@
4444
ircmsgs, ircutils, log, plugin, registry, utils, world)
4545
from .utils import minisix
4646

47-
if minisix.PY2:
48-
from httplib import HTTPConnection
49-
from urllib import splithost, splituser
50-
from urllib import URLopener
51-
else:
52-
from http.client import HTTPConnection
53-
from urllib.parse import splithost, splituser
54-
from urllib.request import URLopener
47+
from http.client import HTTPConnection
48+
from urllib.parse import splithost, splituser
49+
from urllib.request import OpenerDirector
5550

5651
class verbosity:
5752
NONE = 0
@@ -614,7 +609,7 @@ def open_http(url, data=None):
614609
if proxy_auth: c.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
615610
if auth: c.putheader('Authorization', 'Basic %s' % auth)
616611
if realhost: c.putheader('Host', realhost)
617-
for args in URLopener().addheaders: c.putheader(*args)
612+
for args in OpenerDirector().addheaders: c.putheader(*args)
618613
c.endheaders()
619614
return c
620615

0 commit comments

Comments
 (0)