mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Check in Daniel Stutzbach's _fileio.c and test_fileio.py
(see SF#1671314) with small tweaks. The io module now uses this instead of its own implementation of the FileIO class, if it can import _fileio.
This commit is contained in:
parent
4d0f5a4934
commit
a9e2024b84
5 changed files with 1002 additions and 1 deletions
14
Lib/io.py
14
Lib/io.py
|
@ -177,7 +177,7 @@ class RawIOBase:
|
|||
raise IOError(".fileno() not supported")
|
||||
|
||||
|
||||
class FileIO(RawIOBase):
|
||||
class _PyFileIO(RawIOBase):
|
||||
|
||||
"""Raw I/O implementation for OS files."""
|
||||
|
||||
|
@ -243,6 +243,18 @@ class FileIO(RawIOBase):
|
|||
return self._fd
|
||||
|
||||
|
||||
try:
|
||||
import _fileio
|
||||
except ImportError:
|
||||
# Let's use the Python version
|
||||
FileIO = _PyFileIO
|
||||
else:
|
||||
# Create a trivial subclass with the proper inheritance structure
|
||||
class FileIO(_fileio._FileIO, RawIOBase):
|
||||
"""Raw I/O implementation for OS files."""
|
||||
# XXX More docs
|
||||
|
||||
|
||||
class SocketIO(RawIOBase):
|
||||
|
||||
"""Raw I/O implementation for stream sockets."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue