Skip to content

Use duck-typing to set a quasi-integer response status. - #191

Closed
perey wants to merge 3 commits into
Pylons:masterfrom
perey:master
Closed

Use duck-typing to set a quasi-integer response status.#191
perey wants to merge 3 commits into
Pylons:masterfrom
perey:master

Conversation

@perey

@perey perey commented Apr 7, 2015

Copy link
Copy Markdown
Contributor

This change checks for integer values when setting response.status by calling int() on the supplied value, instead of explicitly checking for a subclass of int.

This is helpful to me, because I'm writing code that wraps HTTP statuses in a class that defines __int__(). I'd like to be able to use WebOb together with this class without having to check whether the Response object accepted the status, or whether I need to call int() (or str() for that matter) and try again.

This change additionally removes the need for the "if ' ' not in value" check, which assumed value was interpretable by int() anyway and then performed the same string substitution as the setter for response.status_code.

@mmerickel

Copy link
Copy Markdown
Member

Can you please fix the failing tests.

@digitalresistor digitalresistor added this to the Version 1.5 milestone Apr 7, 2015
Comment thread webob/response.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are losing some validation here I think.

response.status = 'InvalidStatusCodeString' will pass here and be set when it should fail, right?

@digitalresistor

Copy link
Copy Markdown
Member

I pulled your changes, and rebased them on top of master.

digitalresistor pushed a commit that referenced this pull request Apr 14, 2015
Rebased PR #191, but apparently missed part of the patch. This fixes
that.
@digitalresistor

Copy link
Copy Markdown
Member

Thanks for your contribution!

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.

3 participants