response type checking ignores the empty string

Bug #1647880 reported by Jamie Lennox
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
requests-mock
Fix Released
Low
Jamie Lennox

Bug Description

When creating a response we check that a user didn't pass bytes as text= or a string as content=

Unfortunately we check it with a straight bool(text) rather than a text is None check and so the empty string skips these checks. This could be confusing and will break a user anyway so it should be safe to merge.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to requests-mock (master)

Fix proposed to branch: master
Review: https://review.openstack.org/407770

Changed in requests-mock:
assignee: nobody → Jamie Lennox (jamielennox)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to requests-mock (master)

Reviewed: https://review.openstack.org/407770
Committed: https://git.openstack.org/cgit/openstack/requests-mock/commit/?id=86fb33d13d9ad2b3f281e66179b342e00ee07286
Submitter: Jenkins
Branch: master

commit 86fb33d13d9ad2b3f281e66179b342e00ee07286
Author: Jamie Lennox <email address hidden>
Date: Wed Dec 7 11:10:14 2016 +1100

    Type check the empty string when creating repsonse

    When creating a response we type check that the user has passed the
    correct type to content and text, however we check this based on whether
    the value is True and not whether it has been passed at all which means
    that the empty string of the wrong type can incorrectly pass through
    this check.

    Fix this check to test the empty string.

    Anyone relying on this passing will be caught with a more confusing
    TypeError later and so this should be backwards compatible.

    Change-Id: I826da9b7fd83bb88af50e4a96a5e6358ee35e4b2
    Closes-Bug: #1647880

Changed in requests-mock:
status: In Progress → Fix Released
Changed in requests-mock:
milestone: none → 1.3
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.