Jython

Issue2618

classification
Title: socket.sendall no longer sends all
Type: behaviour Severity: critical
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amak, behackett, kasemir, r_walter
Priority: Keywords:

Created on 2017年08月25日.02:59:17 by behackett, last changed 2021年08月24日.16:16:26 by r_walter.

Files
File name Uploaded Description Edit Remove
sendallrepro.py behackett, 2017年08月25日.02:59:17
Messages
msg11546 (view) Author: Bernie Hackett (behackett) Date: 2017年08月25日.02:59:17
This is a regression from Jython 2.7.0. socket.sendall is just an alias for socket.send. In 2.7.0 this doesn't appear to cause any problems as sendall seems to consistently send all the bytes given to it. This is no longer the case in 2.7.1. The regression seems to be caused by the changes for http://bugs.jython.org/issue2508.
This is a serious regression that will break any library using socket.sendall. socket.sendall in CPython only returns None or raises if there is an error. It blocks until all data is sent.
Repro script attached.
msg12144 (view) Author: Kay Kasemir (kasemir) Date: 2018年10月19日.17:13:50
urllib2.py is affected by this regression.
Data sent with an HTTP 'POST' request is truncated because send == sendall only sends partial data.
msg13160 (view) Author: Roland Walter (r_walter) Date: 2021年08月24日.16:16:26
Try this to replace sendall in _socket.py. This worked for me and https://bugs.jython.org/issue2894
 # Fix for 64k not working https://github.com/gbach/jython/commit/759c042bbf3d38a761430d3a671e2cdf4a1bf61f
 def sendall(self, data, flags=0):
 chunk_size = 8192
 length = len(data)
 data_view = memoryview(data)
 idx = 0
 while idx < length:
 bytes_sent = self.send(data_view[idx:idx + chunk_size], flags=flags)
 idx += bytes_sent
History
Date User Action Args
2021年08月24日 16:16:26r_waltersetnosy: + r_walter
messages: + msg13160
2020年03月02日 08:13:43jeff.allensetmilestone: Jython 2.7.3
2018年10月19日 17:13:51kasemirsetmessages: + msg12144
2018年10月19日 17:09:24kasemirsetnosy: + kasemir
2017年08月25日 16:37:33amaksetnosy: + amak
2017年08月25日 02:59:39behackettsettype: behaviour
2017年08月25日 02:59:18behackettcreate

Supported by Python Software Foundation,
Powered by Roundup

AltStyle によって変換されたページ (->オリジナル) /