Patch #1752270, #1750931: complain if urllib2 add_handler called

without handler.
 (backport from rev. 56293)
This commit is contained in:
Georg Brandl 2007-07-12 08:05:48 +00:00
parent ad4b263ba7
commit 40df67f704
2 changed files with 10 additions and 0 deletions

View file

@ -298,6 +298,10 @@ class OpenerDirector:
self.process_request = {}
def add_handler(self, handler):
if not hasattr(handler, "add_parent"):
raise TypeError("expected BaseHandler instance, got %r" %
type(handler))
added = False
for meth in dir(handler):
if meth in ["redirect_request", "do_open", "proxy_open"]: