This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Get rid of IOError. Use OSError instead
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: asvetlov Nosy List: asvetlov, eric.araujo, koobs, py.user, python-dev, terry.reedy
Priority: normal Keywords:

Created on 2012-12-18 19:36 by asvetlov, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (15)
msg178130 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-25 14:47
New changeset 7d69d04522e3 by Andrew Svetlov in branch 'default':
Replace IOError with OSError (#16715)
http://hg.python.org/cpython/rev/7d69d04522e3
msg178131 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-12-25 14:48
Fixed.
msg179401 - (view) Author: py.user (py.user) * Date: 2013-01-08 23:49
found a typo (removed LoadError)

commit 80f2b1273e8c0e1a28fabe537ae9c5acbbcee187
Author: Andrew Svetlov <andrew.svetlov@gmail.com>
Date:   Tue Dec 25 16:47:37 2012 +0200

    Replace IOError with OSError (#16715)
    
...

diff --git a/Lib/http/cookiejar.py b/Lib/http/cookiejar.py
index a77dc3f..7928e9b 100644
--- a/Lib/http/cookiejar.py
+++ b/Lib/http/cookiejar.py

...

@@ -1786,7 +1786,7 @@ class FileCookieJar(CookieJar):
             self._cookies = {}
             try:
                 self.load(filename, ignore_discard, ignore_expires)
-            except (LoadError, IOError):
+            except OSError:
                 self._cookies = old_state
                 raise
msg179541 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-01-10 13:29
It's not a typo.
1. LoadError is inherited from OSError so LoadError exception is also caught.
2. Pointed code just resets cookie state and reraises exception, exception type is saved.

The code is correct from my perspective.
msg179599 - (view) Author: py.user (py.user) * Date: 2013-01-10 21:55
Andrew Svetlov wrote:
> LoadError is inherited from OSError

the comment for the function doesn't tell it
today it's inherited from OSError and tomorrow it may inherit from ANYError
msg179711 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-01-11 17:43
LoadError was IOError descendant, now OSError is directly specified.
If somebody want to change base class for LoadError he should to update the code in several places in http/cookiejar.py.
The docstring for FileCookieJar.revert directly specifies possible exceptions btw.
msg179747 - (view) Author: py.user (py.user) * Date: 2013-01-12 00:01
Zen:
Explicit is better than implicit.
In the face of ambiguity, refuse the temptation to guess.

I assume that someone changes the LoadError class and goes into the revert function. How he can figure out that the cookies should return to the previous state if LoadError was raised ?

Before the change it was explicit and after the change it became implicit.
msg179950 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2013-01-14 16:17
Please email python-dev if you think LoadError should be directly specified.
msg179990 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-01-14 22:54
Source code says:

# derives from OSError for backwards-compatibility with Python 2.4.0
class LoadError(OSError): pass

In 3.0, LoadError could have been made a direct subclass of Exception.  Now it’s too late, but a best practice IMO would still be to write LoadError in all new code.

This makes no practical difference, unless test_cookiejar does not check that LoadError is properly raised and caught at the right places.  In that case, it may be a little more future-proof to follow py-user’s advice.
msg190702 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-06-05 22:42
Now that 3.2 is off of maintenance and Idle patches are being applied to both 3.3 and 3.4 (and usually 2.7), I plan to backport the Idle subset of changes to 3.3 so patches are more likely to merge forward without incident. (I have already done one where this change was the only problem.)
msg190794 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-06-08 04:38
New changeset 2fe64ce5da05 by Terry Jan Reedy in branch '3.3':
#18151, part 1: Backport idlelilb portion of Andrew Svetlov's 3.4 patch
http://hg.python.org/cpython/rev/2fe64ce5da05
msg190797 - (view) Author: Kubilay Kocak (koobs) (Python triager) Date: 2013-06-08 09:37
Commit to 3.3 broke at least my FreeBSD buildbot:

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.0%20dtrace%203.3/builds/641/steps/test/logs/stdio

Also setting +Version: Python 3.3 on this.
msg190799 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-06-08 09:58
I don't think so. The idle test, test_idle, passed. The patch did not even affect any of the three idle files that it currently tests. Just because a commit triggers a test does not mean that it is the cause of any failure that happens. The log says the failure was in test_subprocess.
'''
FAIL: test_wait_timeout (test.test_subprocess.ProcessTestCaseNoPoll)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.3.koobs-freebsd/build/Lib/test/test_subprocess.py", line 953, in test_wait_timeout
    p.wait(timeout=0.0001)
AssertionError: TimeoutExpired not raised
'''
As I interpret the traceback, this did not fail is the re-run.

I did not set 3.3, nor reopen, because this patch is primarily part of a new issue, #18151. I cross-referenced this one so that if anyone else thought of backporting some of the mega patch, this backport would be recorded here.
msg190800 - (view) Author: Kubilay Kocak (koobs) (Python triager) Date: 2013-06-08 10:49
Apologies for the noise Terry, rebuilding passes. 

Unsetting versions: 3.3

Is the failure on the build I reported worth opening an issue for?
msg190947 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-06-11 05:53
I would wait and see if it happens gain or on other buildbots. As I am sure you know, intermittent failures, not reproducible on demand, are nasty.
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60919
2013-06-11 05:53:37terry.reedysetmessages: + msg190947
2013-06-08 10:49:59koobssetmessages: + msg190800
versions: - Python 3.3
2013-06-08 09:58:40terry.reedysetmessages: + msg190799
2013-06-08 09:37:01koobssetnosy: + koobs

messages: + msg190797
versions: + Python 3.3
2013-06-08 04:38:10python-devsetmessages: + msg190794
2013-06-05 22:42:04terry.reedysetnosy: + terry.reedy
messages: + msg190702
2013-01-14 22:54:35eric.araujosetnosy: + eric.araujo
messages: + msg179990
2013-01-14 16:17:15asvetlovsetmessages: + msg179950
2013-01-12 00:01:30py.usersetmessages: + msg179747
2013-01-11 17:43:24asvetlovsetmessages: + msg179711
2013-01-10 21:55:08py.usersetmessages: + msg179599
2013-01-10 13:29:50asvetlovsetmessages: + msg179541
2013-01-08 23:49:27py.usersetnosy: + py.user
messages: + msg179401
2012-12-25 14:48:26asvetlovsetstatus: open -> closed
resolution: fixed
messages: + msg178131

stage: resolved
2012-12-25 14:47:58python-devsetnosy: + python-dev
messages: + msg178130
2012-12-18 22:33:42pitrousettitle: Get rid of IOrror. Use OSError instead -> Get rid of IOError. Use OSError instead
2012-12-18 19:37:23asvetlovlinkissue16705 dependencies
2012-12-18 19:36:56asvetlovcreate