Skip to content

[Pulse demo] psf/requests PR #5486: Allow for autodection of encoding for scalar values - #26

Open
dominic097 wants to merge 1 commit into
mainfrom
pulse-demo/2026-06-24/pr-5486-4
Open

dominic097 wants to merge 1 commit into
mainfrom
pulse-demo/2026-06-24/pr-5486-4

Conversation

@dominic097

Copy link
Copy Markdown
Owner
    Pulse demo seed recreated this as a synthetic PR in the fork on `2026-06-24`.

    Original PR: https://github.com/psf/requests/pull/5486
    Original number: #5486
    Original author: @blenq
    Original head: `master`
    Original base: `main`
    Original labels: none

    Representative upstream files:
    - `requests/models.py` (MODIFIED)
  • requests/utils.py (MODIFIED)

  • tests/test_utils.py (MODIFIED)

      ---
    
      Since JSON RFC 7158 (and also in 7159 and 8259) scalar values are also valid JSON texts. The json decoder from the Python standard libs also accepts such scalar values.
    

The JSON Unicode detection algorithm in "requests" assumes that the first two characters are always ASCII. That is not true anymore.
Therefore the current detection fails in at least these two edge cases

  • A single digit in UTF-16 encoding
  • A quoted string with the first character having a Unicode value higher than 255 in UTF-16 encoding

Also autodetection by chardet returns the wrong encoding.

This change detects the encoding in case of those two edge cases.

@dominic097 dominic097 added the pulse-demo-seed Generated Pulse demo seed data label Jun 24, 2026

@dominic097 dominic097 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Aziron Pulse PR Review

This PR purports to port psf/requests PR psf#5486 (autodetect encoding for scalar JSON values) but the actual diff only adds a metadata JSON file and a trailing comment to tests/test_utils.py. None of the described source changes (requests/models.py, requests/utils.py) or the 18 lines of new tests are present.

Confidence Score: 5/5

The full diff is small and fully visible: it is unambiguously just a metadata JSON file and a trailing comment, with none of the source/test changes described in the PR metadata.

Field Value
Verdict request_changes
Confidence high
Changed files 2

1 actionable finding(s) were posted inline on the diff (0 suggested change(s), 1 fix-session candidate(s)).

To generate one fix PR for all Pulse findings, comment:

@aziron fix

Aziron Pulse generated this from sandbox/MCP-assisted LLM review with native code intelligence context.

Comment thread tests/test_utils.py
monkeypatch.setattr(winreg, "QueryValueEx", QueryValueEx)
assert should_bypass_proxies("http://example.com/", None) is False

# Pulse demo seed 2026-06-24: metadata from psf/requests PR #5486

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

error: This PR claims to port psf/requests PR psf#5486 (autodetect encoding for scalar JSON values), but the only change to source is this trailing comment plus a blank line — no implementation. The upstream metadata in upstream-pr-5486.json lists edits to requests/utils.py (guess_json_utf, +5/-6), requests/models.py (+5/-5), and 18 new test lines, none of which appear in this diff. Impact: the guess_json_utf bug for UTF-16/UTF-32 scalar values (single digit, quoted string with first char >255) remains unfixed while the PR appears to resolve it. Fix direction: actually add the guess_json_utf/models.py changes and add TestGuessJSONUTF cases for scalar values, and remove this stray demo comment from the test file.

Confidence: high

This requires a sandbox fix session.

Fix task: Port psf/requests PR psf#5486: update requests/utils.py guess_json_utf to handle RFC 7158 scalar JSON values where the first two bytes are not both ASCII (e.g. a single digit or a quoted string whose first char has Unicode value >255 in utf-16/utf-32 BE/LE), update requests/models.py accordingly, add corresponding cases to TestGuessJSONUTF in tests/test_utils.py asserting correct encoding detection, and remove the stray '# Pulse demo seed' comment.

To generate a fix PR, comment:

@aziron fix finding:missing-implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pulse-demo-seed Generated Pulse demo seed data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant