Skip to content

Store the status exactly once on the HTTPRedirect#1615

Merged
jaraco merged 5 commits intomasterfrom
hotfix/one-status
Oct 28, 2017
Merged

Store the status exactly once on the HTTPRedirect#1615
jaraco merged 5 commits intomasterfrom
hotfix/one-status

Conversation

@jaraco
Copy link
Copy Markdown
Member

@jaraco jaraco commented Jul 26, 2017

While reviewing #1611, I noticed that the 'status' of an HTTPRedirect is stored in two places on the class, once in the Exception.args and again in the HTTPRedirect.status. This approach is sloppy, and could lead to situations where the two values don't match. Better would be to either store the value in the args and refer to it when referencing the status (as proposed here) or to only store it in the status property. I feel like this proposed change is less invasive than removing the status from the args.

One backward-incompatible effect this proposal introduces is that the status can no longer be set after the redirect is constructed:

r = HTTPRedirect('/go-here')
r.status = 302

Previously, that would have worked but no longer will. I suggest this usage was never supported (not captured in tests) and so may be changed without formally introducing a backward-incompatibility.

I don't feel strongly about one approach or another, but I do feel strongly that this status should be stored exactly once.

@jaraco jaraco force-pushed the hotfix/one-status branch from 77ef858 to 3e24195 Compare August 29, 2017 00:41
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 28, 2017

Codecov Report

Merging #1615 into master will increase coverage by 0.24%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1615      +/-   ##
==========================================
+ Coverage    76.7%   76.94%   +0.24%     
==========================================
  Files         106      106              
  Lines       14280    14374      +94     
==========================================
+ Hits        10953    11060     +107     
+ Misses       3327     3314      -13
Impacted Files Coverage Δ
cherrypy/_cperror.py 94.41% <100%> (-0.17%) ⬇️
cherrypy/lib/gctools.py 35.03% <0%> (-48.91%) ⬇️
cherrypy/lib/jsontools.py 80.55% <0%> (-2.78%) ⬇️
cherrypy/test/test_refleaks.py 95% <0%> (-2.5%) ⬇️
cherrypy/test/webtest.py 56.84% <0%> (-1.47%) ⬇️
cherrypy/lib/reprconf.py 86.43% <0%> (-0.64%) ⬇️
cherrypy/test/test_conn.py 90.36% <0%> (-0.37%) ⬇️
cherrypy/lib/httpauth.py 78.81% <0%> (-0.32%) ⬇️
cherrypy/_cpconfig.py 77.1% <0%> (-0.28%) ⬇️
cherrypy/_cpdispatch.py 92.46% <0%> (-0.27%) ⬇️
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13dc1d7...d421e04. Read the comment docs.

@jaraco jaraco merged commit b66ec33 into master Oct 28, 2017
@jaraco jaraco deleted the hotfix/one-status branch December 17, 2017 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants