Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending 0 byte files now triggers an exception in 3.7.0 #5124

Closed
bdraco opened this issue Oct 24, 2020 · 0 comments · Fixed by #5125
Closed

Sending 0 byte files now triggers an exception in 3.7.0 #5124

bdraco opened this issue Oct 24, 2020 · 0 comments · Fixed by #5125
Labels

Comments

@bdraco
Copy link
Member

bdraco commented Oct 24, 2020

🐞 Describe the bug

#4517 caused a regression with 0 byte files.

💡 To Reproduce

Send a 0 byte file with aiohttp.web.FileResponse on python 3.7 or later

💡 Expected behavior

No exception

📋 Logs/tracebacks

Traceback (most recent call last):
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 461, in start
    resp, reset = await task
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 414, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 568, in finish_response
    await prepare_meth(request)
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_fileresponse.py", line 373, in prepare
    return await self._sendfile(request, fobj, offset, count)
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_fileresponse.py", line 191, in _sendfile_system
    await writer.sendfile()
  File "/__w/core/core/venv/lib/python3.7/site-packages/aiohttp/web_fileresponse.py", line 107, in sendfile
    self._count
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1044, in sendfile
    offset, count)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 551, in _sendfile_native
    fallback=False)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 788, in sock_sendfile
    self._check_sendfile_params(sock, file, offset, count)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 842, in _check_sendfile_params
    "count must be a positive integer (got {!r})".format(count))
ValueError: count must be a positive integer (got 0)

📋 Your version of the Python

$ python --version
Python 3.8.1
...

📋 Your version of the aiohttp/yarl/multidict distributions

$ python -m pip show aiohttp
...
$ python -m pip show multidict
...
$ python -m pip show yarl
...

📋 Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant