mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
fix tests
This commit is contained in:
parent
87c88faa88
commit
3f7259fa7d
1 changed files with 11 additions and 3 deletions
|
|
@ -468,7 +468,15 @@ def _sendfile_use_transmitfile(self, file, offset=0, count=None):
|
||||||
offset_low = offset & 0xffff_ffff
|
offset_low = offset & 0xffff_ffff
|
||||||
offset_high = (offset >> 32) & 0xffff_ffff
|
offset_high = (offset >> 32) & 0xffff_ffff
|
||||||
count = count or 0
|
count = count or 0
|
||||||
ov.TransmitFile(self.fileno(), msvcrt.get_osfhandle(file.fileno()),
|
try:
|
||||||
|
fileno = file.fileno()
|
||||||
|
except (AttributeError, io.UnsupportedOperation) as err:
|
||||||
|
raise _GiveupOnSendfile(err) # not a regular file
|
||||||
|
try:
|
||||||
|
os.fstat(fileno)
|
||||||
|
except OSError as err:
|
||||||
|
raise _GiveupOnSendfile(err) # not a regular file
|
||||||
|
ov.TransmitFile(self.fileno(), msvcrt.get_osfhandle(fileno),
|
||||||
offset_low, offset_high, count, 0, 0)
|
offset_low, offset_high, count, 0, 0)
|
||||||
timeout_ms = _overlapped.INFINITE
|
timeout_ms = _overlapped.INFINITE
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
|
|
@ -514,9 +522,9 @@ def sendfile(self, file, offset=0, count=None):
|
||||||
The socket must be of SOCK_STREAM type.
|
The socket must be of SOCK_STREAM type.
|
||||||
Non-blocking sockets are not supported.
|
Non-blocking sockets are not supported.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
return self._sendfile_use_transmitfile(file, offset, count)
|
return self._sendfile_use_transmitfile(file, offset, count)
|
||||||
try:
|
|
||||||
return self._sendfile_use_sendfile(file, offset, count)
|
return self._sendfile_use_sendfile(file, offset, count)
|
||||||
except _GiveupOnSendfile:
|
except _GiveupOnSendfile:
|
||||||
return self._sendfile_use_send(file, offset, count)
|
return self._sendfile_use_send(file, offset, count)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue