Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
527a7037
Commit
527a7037
authored
Sep 17, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Plain Diff
Issue #26384: Merge from 3.5
parents
661f941c
8b2a3589
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
Lib/socket.py
Lib/socket.py
+1
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+19
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/socket.py
View file @
527a7037
...
...
@@ -268,7 +268,7 @@ class socket(_socket.socket):
raise
_GiveupOnSendfile
(
err
)
# not a regular file
try
:
fsize
=
os
.
fstat
(
fileno
).
st_size
except
OSError
:
except
OSError
as
err
:
raise
_GiveupOnSendfile
(
err
)
# not a regular file
if
not
fsize
:
return
0
# empty file
...
...
Lib/test/test_socket.py
View file @
527a7037
...
...
@@ -1485,6 +1485,25 @@ class GeneralModuleTests(unittest.TestCase):
self
.
assertEqual
(
s
.
family
,
42424
)
self
.
assertEqual
(
s
.
type
,
13331
)
@
unittest
.
skipUnless
(
hasattr
(
os
,
'sendfile'
),
'test needs os.sendfile()'
)
def
test__sendfile_use_sendfile
(
self
):
class
File
:
def
__init__
(
self
,
fd
):
self
.
fd
=
fd
def
fileno
(
self
):
return
self
.
fd
with
socket
.
socket
()
as
sock
:
fd
=
os
.
open
(
os
.
curdir
,
os
.
O_RDONLY
)
os
.
close
(
fd
)
with
self
.
assertRaises
(
socket
.
_GiveupOnSendfile
):
sock
.
_sendfile_use_sendfile
(
File
(
fd
))
with
self
.
assertRaises
(
OverflowError
):
sock
.
_sendfile_use_sendfile
(
File
(
2
**
1000
))
with
self
.
assertRaises
(
TypeError
):
sock
.
_sendfile_use_sendfile
(
File
(
None
))
@
unittest
.
skipUnless
(
HAVE_SOCKET_CAN
,
'SocketCan required for this test.'
)
class
BasicCANTest
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
527a7037
...
...
@@ -29,6 +29,8 @@ Core and Builtins
Library
-------
- Fix UnboundLocalError in socket._sendfile_use_sendfile.
- Issue #28075: Check for ERROR_ACCESS_DENIED in Windows implementation of
os.stat(). Patch by Eryk Sun.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment