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: An OSError subclass for "no space left on device" would be nice: NoSpaceError
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, barry, bochecha, iritkatriel, martin.panter, pitrou, tshepang, vstinner
Priority: normal Keywords: patch

Created on 2014-10-20 16:27 by bochecha, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
0001-New-NoSpaceError.patch bochecha, 2014-10-20 16:28 New NoSpaceError review
0002-Use-the-new-NoSpaceError.patch bochecha, 2014-10-20 16:29 Use the new NoSpaceError
Messages (4)
msg229729 - (view) Author: Mathieu Bridon (bochecha) * Date: 2014-10-20 16:27
I found myself writing the following code the other day:

        try:
            os.mkdir(path)
            
        except PermissionError:
            do_something()

        except FileExistsError:
            do_something_else()

        except FileNotFoundError:
            do_yet_another_thing()

        except OSError as e:
            import errno
            if e.errno == errno.ENOSPC:
                and_do_one_more_different_thing()

            else:
                raise e

The OSError subclasses in Python 3 are amazing, I love them.

I just wish there'd be more of them. :)
msg230072 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-10-27 13:36
The PEP 3151 introduced "specialized" subclasses of OSError. Antoine Pitrou conducted a survey to decide which errors are common enough to merit a builtin exception:
http://legacy.python.org/dev/peps/pep-3151/#appendix-a-survey-of-common-errnos

ENOSPC is not mentionned in the PEP. According to 0002-Use-the-new-NoSpaceError.patch the error is rare: only used *once* in Python... and only in a very specific unit test (to workaround an issue on a specific buildbot...).

It looks like ENOSPC is available on Linux, Windows, FreeBSD and Mac OS X. It is part of the POSIX standad, ex:
http://pubs.opengroup.org/onlinepubs/009604599/basedefs/errno.h.html
msg230074 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-10-27 14:16
That said I am not against adding a new error for this, but I agree the need is probably rather rare (the error is rare in itself, and there's not much to do if you hit a disk space issue, usually).

I'm going to wait for other people to come with comments and possible use cases. In any case, thank you for submitting a patch, this is appreciated.
msg404797 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-10-22 17:14
Shall we conclude from 7 years of no activity that there isn't much interest in this exception?
History
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66868
2021-11-05 19:47:46iritkatrielsetstatus: pending -> closed
resolution: rejected
stage: patch review -> resolved
2021-10-22 17:14:44iritkatrielsetstatus: open -> pending
nosy: + iritkatriel
messages: + msg404797

2014-10-31 18:50:39Arfreversetnosy: + Arfrever
2014-10-28 21:41:04vstinnersettitle: An OSError subclass for "no space left on device" would be nice -> An OSError subclass for "no space left on device" would be nice: NoSpaceError
2014-10-27 14:16:38pitrousetmessages: + msg230074
2014-10-27 13:36:48vstinnersetnosy: + vstinner
messages: + msg230072
2014-10-26 23:37:03martin.pantersetnosy: + martin.panter
2014-10-25 11:51:50tshepangsetnosy: + tshepang
2014-10-22 07:45:55pitrousetnosy: + barry, pitrou
2014-10-21 00:16:19berker.peksagsetstage: patch review
type: enhancement
components: + Interpreter Core, - Library (Lib)
versions: + Python 3.5, - Python 3.4
2014-10-20 16:29:17bochechasetfiles: + 0002-Use-the-new-NoSpaceError.patch
2014-10-20 16:28:40bochechasetfiles: + 0001-New-NoSpaceError.patch
keywords: + patch
2014-10-20 16:27:15bochechacreate