Skip to content

Fix the In-Depth Example in the docs to return bytes - #338

Open
fjvbn2003 wants to merge 1 commit into
Kludex:mainfrom
fjvbn2003:docs-in-depth-example-bytes
Open

fjvbn2003 wants to merge 1 commit into
Kludex:mainfrom
fjvbn2003:docs-in-depth-example-bytes

Conversation

@fjvbn2003

@fjvbn2003 fjvbn2003 commented Oct 16, 2026 •

Copy link
Copy Markdown

The two "In-Depth Example" snippets on the docs index page (docs/index.md) return str objects from a WSGI app. On Python 3, wsgiref rejects them with AssertionError: write() argument must be a bytes instance, so both snippets answer 500 Internal Server Error instead of the output shown on the page. The same problem was reported for the old docs site in #36.

This makes the snippets return bytes and starts the final example with the Hashes: line that the sample output already shows.

I extracted the three Python blocks from docs/index.md, ran each in a thread instead of serve_forever(), and hit them with curl. I used python-multipart 0.0.31 and CPython 3.12.14.

example before after
Simple Example (-F foo=bar) 200 Parsed value parameter named: foo unchanged
In-Depth, first app (GET /) 500 (write() argument must be a bytes instance) 200 Hashes:
In-Depth, final app (-F file=@test.txt) 500 (same) 200 Hashes: / Part hash: 0b64696c…d931 (matches shasum -a 256 in the docs)

I used an AI assistant (Claude) to help find and draft this change. I reviewed and tested it myself.

🤖 Generated with Claude Code

🤖 Generated with Claude Code

View guided diff

Both "In-Depth Example" snippets returned str from a WSGI app, which
wsgiref rejects with "write() argument must be a bytes instance", so
they answered 500 instead of the output shown on the page. Return
bytes and start the final example with the "Hashes:" line that the
sample output already shows.

Signed-off-by: YoungjuKim <fjvbn2003@gmail.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

View guided diff | Re-trigger cubic

@codspeed

codspeed Bot commented Oct 16, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing fjvbn2003:docs-in-depth-example-bytes (ca7f893) with main (51ff1a4)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

This branch has not been deployed

No deployments
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.

1 participant