Skip to content

fix: properly decode binary strings in builtin_str function#112

Open
label-hook[bot] wants to merge 1522 commits into
mainfrom
phoenix/issue-111
Open

fix: properly decode binary strings in builtin_str function#112
label-hook[bot] wants to merge 1522 commits into
mainfrom
phoenix/issue-111

Conversation

@label-hook

@label-hook label-hook Bot commented Apr 19, 2026

Copy link
Copy Markdown

Summary

Fixes an issue where binary string HTTP methods like b'GET' were being converted to their string representation "b'GET'" instead of being properly decoded to 'GET'. This caused 404 Not Found responses when using libraries that encode method names as binary strings.

Changes

  • Modified builtin_str() function in requests/compat.py to detect binary strings and decode them using UTF-8 encoding
  • Added proper handling for bytes type in Python 3 to ensure binary strings are decoded rather than converted to their string representation
  • Maintains backward compatibility with existing string inputs

Testing

The fix was verified to handle binary string methods correctly:

  • Binary strings like b'GET' are now properly decoded to 'GET'
  • Existing string methods continue to work as expected
  • No new test failures were introduced to the baseline test suite

Closes #111


Closes #111

Kenneth Reitz and others added 30 commits April 26, 2014 09:28
Don't repopulate proxies if we don't trust the environment.
There's not a lot of good reason to actually call out easy_install at all.
Anyone who prefers it already knows it exists and everyone else should be
directed unambiguously towards pip.
Remove the easy_install section
ImportError: No module named 'requests.packages.urllib3.util'
Improved decoding support for Response.iter_content and iter_lines
Add __str__ to case insensitive dict
Catch errors while handling redirects
`Sesssion` -> `Session`
Fix typo in advanced.rst docs
kennethreitz and others added 27 commits October 6, 2014 05:39
Re-order params for backwards compat
Fixed -2250
Fix issue psf#2279. "Gittip" changed to "Gratipay". Tip button extended from 48px to 60px.
Fix psf#2288 . Change urllib3 and chardet workflow
Adding a custom line delimiter to iter_lines()
…e_unicode_url

Fix failing test test_prepare_unicode_url
@label-hook label-hook Bot added the ai:review Phoenix AI: PR ready for review label Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:review Phoenix AI: PR ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SWE-bench] psf__requests-2317