-
Notifications
You must be signed in to change notification settings - Fork 203
Python 2.x 3.x compatibility notes
Alex Willmer edited this page Dec 9, 2025
·
6 revisions
Python <= 3.2
- BaseException
- Exception
- StandardError
- EnvironmentError
- IOError
- socket.error
- OSError
- IOError
- EnvironmentError
- select.error
- StandardError
- Exception
Python >= 3.3
- BaseException
- Exception
- OSError
- BlockingIOError
- EnvironmentError
- IOError
- select.error
- socket.error
- OSError
- Exception
Refs
- https://docs.python.org/2/library/exceptions.html#exception-hierarchy
- https://docs.python.org/3/library/exceptions.html#exception-hierarchy
- https://docs.python.org/3/whatsnew/3.3.html#pep-3151
Python 3.5+ automatically retries system calls that return EINTR.
- https://docs.python.org/3/library/exceptions.html#InterruptedError
- https://docs.python.org/3/whatsnew/3.5.html#pep-475-retry-system-calls-failing-with-eintr
-
open(),os.fdopen(), etc return-
fileinstances in Python 2.x -
io.*instances in Python 3.x
-
-
iomodule requires Python >= 2.6 -
BlockingIOErrorrequires Python >= 3.3 (first doc mention Python 3.4)
In non-blocking mode, if n > 0 is specified, and no bytes are available
-
io.RawIOBase.read(n)returnsNone -
io.BufferedIOBase.read(n)is allowed to returnNoneor raiseBlockingIOError.iocode returnsNone -
io.BufferedReader.read(n)is the same asio.BufferedIOBase.read(n)
- Python >= 2.4
- Python >= 2.6: Popen.send_signal(s), Popen.terminate(), Popen.kill()
- Python >= 3.3: Popen.communicate(..., timeout)