urllib.request.urlopen doesn't work when data is only in Request object

Open
#96,873 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

Start in urllib/request.py around line 518 and reproduce the issue with a Request containing data passed to urllib.request.urlopen. Confirm the request sends the Request object's data when no separate data argument is supplied; check the existing urllib tests for the appropriate place to add regression coverage.

Written by the indexing model from the issue text.

Description

stdlib type-bug

urllib.request.urlopen does not send data contained in the Request object if it is not passed in the call.

req = urllib.request.Request(url="http://site.local", data="foo=bar", method="POST")
urllib.request.urlopen(url=req)

the request is sent with data = None

BUG: urllib/request.py:518
response = self._open(req, data)
should be:
response = self._open(req, req.data)

Dominant language
Python
Stars
77.2k
Forks
36k
Avg merge
1d 9h
Merged PRs (30d)
558

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/cpython

All issues in python/cpython

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.