Skip to content
Commit 553bdc9f authored by Simon McVittie's avatar Simon McVittie
Browse files

When handling errors according to errno, catch both IOError and OSError



Different Python versions are not completely consistent about the
error that is raised and its class hierarchy:

Python 3.5.3rc1 (default, Jan  3 2017, 04:40:57)
>>> try: open('/foo')
... except Exception as e: print(e.__class__.__mro__)
(<class 'FileNotFoundError'>, <class 'OSError'>, <class 'Exception'>, <class 'BaseException'>, <class 'object'>)

Python 2.7.13 (default, Dec 18 2016, 20:19:42)
>>> try: open('/foo')
... except Exception as e: print e.__class__.__mro
(<type 'exceptions.IOError'>, <type 'exceptions.EnvironmentError'>, <type 'exceptions.StandardError'>, <type 'exceptions.Exception'>, <type 'exceptions.BaseException'>, <type 'object'>)

This can lead to a race condition during cache cleaning, where two
processes both try to delete the same file, and the one that loses
the race fails.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
Reviewed-by: default avatarIain Lane <laney@ubuntu.com>
Reviewed-by: default avatarColin Walters <walters@verbum.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=772173
parent e8f39a0a
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment