Skip to content
Myr

Simplify PreparedRequest.prepare API

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Do not require that hooks be passed as an empty list to PreparedRequest.prepare. In the event hooks is None in prepare or prepare_hooks, use an empty list as a default. Related to #2552

authored by Ian Cordasco · committed by Ian Cordasco · parent a0632d8 · Browse files · 2 files+4 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−1 removed

  • other:+4 added−1 removed

2 files+4 added−1 removed

modified:requests/models.py+4 added
521 unmodified lines
522 self.headers['Cookie'] = cookie_header523524 def prepare_hooks(self, hooks):525 """Prepares the given hooks."""526 # hooks can be passed as None to the prepare method and to this527 # method. To prevent iterating over None, simply use an empty list528 # if hooks is False-y529 hooks = hooks or []530 for event in hooks:531 self.register_hook(event, hooks[event])532533
326 unmodified lines
modified:test_requests.py-1 removed
1611 unmodified lines
1612 p = PreparedRequest()1613 p.prepare(1614 method='GET',1615 url=u('http://www.example.com/üniçø∂é'),1616 hooks=[]1616 )1617 assert_copy(p, p.copy())16181619
19 unmodified lines