Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
8bc2b3cd
Commit
8bc2b3cd
authored
Nov 29, 2018
by
Ricardo Kirkner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cast OSError raised by os.lseek into IOError so we're consistent with Python 2.x stdlib
parent
ce5a9c40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
src/gevent/_fileobjectposix.py
src/gevent/_fileobjectposix.py
+12
-1
src/gevent/tests/test__fileobject.py
src/gevent/tests/test__fileobject.py
+20
-0
No files found.
src/gevent/_fileobjectposix.py
View file @
8bc2b3cd
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
os
import
os
import
sys
import
io
import
io
from
io
import
BufferedReader
from
io
import
BufferedReader
from
io
import
BufferedWriter
from
io
import
BufferedWriter
...
@@ -8,6 +9,7 @@ from io import DEFAULT_BUFFER_SIZE
...
@@ -8,6 +9,7 @@ from io import DEFAULT_BUFFER_SIZE
from
io
import
RawIOBase
from
io
import
RawIOBase
from
io
import
UnsupportedOperation
from
io
import
UnsupportedOperation
from
gevent._compat
import
PY3
,
reraise
from
gevent._fileobjectcommon
import
cancel_wait_ex
from
gevent._fileobjectcommon
import
cancel_wait_ex
from
gevent._fileobjectcommon
import
FileObjectBase
from
gevent._fileobjectcommon
import
FileObjectBase
from
gevent.hub
import
get_hub
from
gevent.hub
import
get_hub
...
@@ -140,7 +142,16 @@ class GreenFileDescriptorIO(RawIOBase):
...
@@ -140,7 +142,16 @@ class GreenFileDescriptorIO(RawIOBase):
self
.
hub
.
wait
(
self
.
_write_event
)
self
.
hub
.
wait
(
self
.
_write_event
)
def
seek
(
self
,
offset
,
whence
=
0
):
def
seek
(
self
,
offset
,
whence
=
0
):
return
os
.
lseek
(
self
.
_fileno
,
offset
,
whence
)
try
:
return
os
.
lseek
(
self
.
_fileno
,
offset
,
whence
)
except
OSError
as
ex
:
if
not
PY3
:
# Python 2.x
# make sure on Python 2.x we raise an IOError
exc_info
=
sys
.
exc_info
()
reraise
(
IOError
,
IOError
(
*
ex
.
args
),
tb
=
exc_info
[
2
])
# otherwise just re-raise the original exception
raise
class
FlushingBufferedWriter
(
BufferedWriter
):
class
FlushingBufferedWriter
(
BufferedWriter
):
...
...
src/gevent/tests/test__fileobject.py
View file @
8bc2b3cd
...
@@ -13,6 +13,7 @@ from gevent.testing.sysinfo import PY3
...
@@ -13,6 +13,7 @@ from gevent.testing.sysinfo import PY3
from
gevent.testing.flaky
import
reraiseFlakyTestRaceConditionLibuv
from
gevent.testing.flaky
import
reraiseFlakyTestRaceConditionLibuv
from
gevent.testing.skipping
import
skipOnLibuvOnCIOnPyPy
from
gevent.testing.skipping
import
skipOnLibuvOnCIOnPyPy
from
gevent.testing.skipping
import
skipOnWindows
from
gevent.testing.skipping
import
skipOnWindows
from
gevent.testing.skipping
import
skipOnPy37
try
:
try
:
ResourceWarning
ResourceWarning
...
@@ -144,6 +145,25 @@ class Test(greentest.TestCase):
...
@@ -144,6 +145,25 @@ class Test(greentest.TestCase):
self
.
assertEqual
(
native_data
,
s
)
self
.
assertEqual
(
native_data
,
s
)
self
.
assertEqual
(
native_data
,
fileobj_data
)
self
.
assertEqual
(
native_data
,
fileobj_data
)
@
skipOnPy37
@
skipOnWindows
(
"FileObject not used on Win32"
)
def
test_seek_raises_ioerror
(
self
):
# Issue #1323
fd
=
sys
.
stdout
with
self
.
assertRaises
(
OSError
)
as
ctx
:
os
.
lseek
(
fd
.
fileno
(),
0
,
0
)
os_ex
=
ctx
.
exception
with
self
.
assertRaises
(
IOError
)
as
ctx
:
f
=
FileObject
(
fd
,
'r'
)
f
.
seek
(
0
)
io_ex
=
ctx
.
exception
self
.
assertEqual
(
io_ex
.
args
,
os_ex
.
args
)
self
.
assertEqual
(
io_ex
.
errno
,
os_ex
.
errno
)
self
.
assertEqual
(
io_ex
.
strerror
,
os_ex
.
strerror
)
self
.
assertEqual
(
str
(
io_ex
),
str
(
os_ex
))
def
test_close_pipe
(
self
):
def
test_close_pipe
(
self
):
# Issue #190, 203
# Issue #190, 203
r
,
w
=
os
.
pipe
()
r
,
w
=
os
.
pipe
()
...
...
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