Skip to content

Commit

Permalink
Simplify HTTPResponse.excecption
Browse files Browse the repository at this point in the history
- simplify comparison
- remove redundant parenthesis
- delete unused code

modified:   src/ZPublisher/HTTPResponse.py
  • Loading branch information
jugmac00 committed May 1, 2019
1 parent a7c915e commit 5aa7ab9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/ZPublisher/HTTPResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,29 +855,26 @@ def exception(self, fatal=0, info=None, abort=1):
self._unauthorized()

self.setStatus(t)
if self.status >= 300 and self.status < 400:
if 300 <= self.status < 400:
if isinstance(v, str) and absuri_match(v) is not None:
if self.status == 300:
self.setStatus(302)
self.setHeader('location', v)
tb = None # just one path covered
return self
elif isinstance(v, Redirect):
if self.status == 300:
self.setStatus(302)
self.setHeader('location', v.args[0])
self.setBody(b'')
tb = None
return self
else:
try:
l, b = v
if (isinstance(l, str) and absuri_match(l) is not None):
if isinstance(l, str) and absuri_match(l) is not None:
if self.status == 300:
self.setStatus(302)
self.setHeader('location', l)
self.setBody(b)
tb = None # one more patch covered
return self
except Exception:
pass # tb is not cleared in this case
Expand Down

0 comments on commit 5aa7ab9

Please sign in to comment.