Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
40df67f7
Commit
40df67f7
authored
Jul 12, 2007
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1752270, #1750931: complain if urllib2 add_handler called
without handler. (backport from rev. 56293)
parent
ad4b263b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+6
-0
Lib/urllib2.py
Lib/urllib2.py
+4
-0
No files found.
Lib/test/test_urllib2.py
View file @
40df67f7
...
...
@@ -381,6 +381,12 @@ class MockPasswordManager:
class
OpenerDirectorTests
(
unittest
.
TestCase
):
def
test_add_non_handler
(
self
):
class
NonHandler
(
object
):
pass
self
.
assertRaises
(
TypeError
,
OpenerDirector
().
add_handler
,
NonHandler
())
def
test_badly_named_methods
(
self
):
# test work-around for three methods that accidentally follow the
# naming conventions for handler methods
...
...
Lib/urllib2.py
View file @
40df67f7
...
...
@@ -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
"]:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment