Skip to content

Conversation

@JelleZijlstra
Copy link
Member

No description provided.

@github-actions

This comment has been minimized.

]

_DataType: TypeAlias = bytes | IO[Any] | Iterable[bytes] | str
_DataType: TypeAlias = SupportsRead[bytes] | Iterable[ReadableBuffer] | ReadableBuffer
Copy link
Collaborator

Choose a reason for hiding this comment

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

HTTPConnection.send() also allows str:

 def request(self, method, url, body=None, headers={}, *, encode_chunked=False): """Send a complete request to the server.""" self._send_request(method, url, body, headers, encode_chunked) def _send_request(self, method, url, body, headers, encode_chunked): # ... # It also gets passed to _get_content_length(), which also supports str # ... if isinstance(body, str): # RFC 2616 Section 3.7.1 says that text default has a # default charset of iso-8859-1. body = _encode(body, 'body') self.endheaders(body, encode_chunked=encode_chunked)

I think the best solution is just to add str to the body argument of request manually.

Comment on lines 57 to 59
server: socketserver.BaseServer,
directory: str | None = ...,
index_pages: Sequence[str] | None = ...,
Copy link
Collaborator

Choose a reason for hiding this comment

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

As directory is keyword only and I can't find index_pages anywhere (on 3.9):

Suggested change
server: socketserver.BaseServer,
directory: str | None = ...,
index_pages: Sequence[str] | None = ...,
server: socketserver.BaseServer,
*,
directory: str | None = ...,

(directory is also passed to os.fspath() in later version (but not 3.7), but that's out of scope for this PR, since it needs overloads.)

Copy link
Member

@AlexWaygood AlexWaygood Nov 1, 2022

Choose a reason for hiding this comment

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

index_pages is new in 3.12: python/cpython#31985. So we should branch on if sys.version_info >= (3, 12).

@JelleZijlstra JelleZijlstra requested a review from srittau November 3, 2022 03:39
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 6b70245 into python:main Nov 3, 2022
AlexWaygood added a commit that referenced this pull request Nov 3, 2022
The stub currently implies that the index_pages parameter has been removed in 3.12. Actually, it was only added in 3.12 :) See python/cpython#31985. (This is a follow-up to #9055 — cc. @JelleZijlstra.)
@JelleZijlstra JelleZijlstra deleted the http branch November 3, 2022 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants