[issue35622] Add support for Linux SCHED_DEADLINE
New submission from Michael Büsch : Are there plans to support Linux SCHED_DEADLINE in the os module? If not, would changes to add such support be welcome? Support for SCHED_DEADLINE would also need support for sched_setattr/sched_getattr. -- components: Library (Lib) messages: 332772 nosy: mb_ priority: normal severity: normal status: open title: Add support for Linux SCHED_DEADLINE type: enhancement ___ Python tracker <https://bugs.python.org/issue35622> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35622] RFE: Add os.sched_setattr() and os.sched_getattr() functions
Michael Büsch added the comment: I would like to implement this feature. So if somebody thinks that it's a bad idea to have this feature, please speak up now. -- nosy: +vstinner ___ Python tracker <https://bugs.python.org/issue35622> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22103] bdist_wininst does not run install script
New submission from Michael Büsch: The bdist_wininst installer does not run the specified --install-script. Attached is an example project foo.zip. setup.py is invoked as follows: py setup.py bdist_wininst --install-script foo_postinstall.py The installer shows that it successfully ran the install script, but it did not do this. The file C:\foo.txt is not created. If I add print()s to the install script, these messages are not shown either. I tested this on Python 3.4, 64-bit (Win7) and 32-bit (XP) -- components: Installation files: foo.zip messages: 224258 nosy: mb_ priority: normal severity: normal status: open title: bdist_wininst does not run install script type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file36154/foo.zip ___ Python tracker <http://bugs.python.org/issue22103> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
New submission from Michael Büsch: This adds a whitelist parameter with the name 'unless' to contextlib.suppress, so one can specify exceptions that will not be suppressed. This is useful for specifying single sub-exceptions that we still want to catch, even of we want to suppress all other siblings. Or it can be used to suppress all exceptions except some very specific ones by suppressing BaseException and whitelisting things like SyntaxError, NameError and the like. Usage looks like this: with suppress(OSError, unless = PermissionError): with open("foobar", "wb") as f: f.write(... I selected the name 'unless' instead of 'whitelist' or such, because I think that pronounces nicely in the 'with' line context. However please feel free to make better suggestions. -- components: Library (Lib) files: contextlib-suppress-whitelist.patch keywords: patch messages: 273206 nosy: mb_, ncoghlan, yselivanov priority: normal severity: normal status: open title: contextlib.suppress: Add whitelist argument type: enhancement Added file: http://bugs.python.org/file44168/contextlib-suppress-whitelist.patch ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Changes by Michael Büsch : -- nosy: +rhettinger ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Michael Büsch added the comment: >Could you please produce a patch that conforms to PEP-8. I tried hard to do so. Could you please tell me what parts are not compliant, so I can fix them? -- ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Michael Büsch added the comment: Thanks for your comments. Here's version 2 of the patch. Changes: - A typo in the docstring was fixed. - Space was removed in keyword assignments. - Documentation was added. (Note that I signed and sent the contributor agreement. It should arrive soon.) -- Added file: http://bugs.python.org/file44170/contextlib-suppress-whitelist-v2.patch ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Michael Büsch added the comment: >and instead point you towards https://bugs.python.org/issue12029 Fair enough. But how would a 'suppress OSError, but catch FileNotFoundError' look like with this for example? (Note that I can't subclass the exception) >I'm also not sure it's an idiom we really want to encourage, as it tends to >age poorly as new exception subclasses are added, I partially agree. But there's one important spot where I need this behaviour: It is cleanup paths where I cannot react to most exceptions. For example because I already am handling exceptions and am already trying to tear the whole thing down anyway. >as well as confusing exception flow logic like the example given in the >documentation I disagree. The control flow does not change with this patch at all. It either pops out of the with-statement with an exception, or it does not. The only thing this patch does is _reduce_ the set of exceptions it suppresses. >For folks that do need this capability, building it themselves is pretty >straightforward, Nah. The whole point of contextlib.suppress is to avoid boilerplate code. People could do their own stuff. In fact, that is what I did. But I prefer a standard solution in the standard library for this really common problem instead. -- ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Michael Büsch added the comment: >when particular instances of "catch this exception, but not these ones" become >common, we tend to *change the standard exception hierarchy* to eliminate them >(e.g. StopIteration, KeyboardError, GeneratorExit no longer inheriting from >Exception). But my patch does not change that behaviour. We already have "catch this exception, but not these ones". It's called contextlib.suppress. I'm not adding this behaviour to the library/language. This patch just improves contextlib.suppress in the way that we can now easily remove exceptions from the suppress-set. >So if you have new cases where that's happening frequently for you Ok, let me explain the real world scenario that I have here. Imagine some application that does something over the network and an exception occurs. We catch that and decide that the program must die. However before doing so we need to send stuff over the network to cleanly tear down things. This is done on a best-effort basis. So we try to send these messages, but we silently ignore _all_ failures. What would we do anyway? We are exiting already. And that's what I do. Wrap these actions in helpers that ignore all exceptions, except for SyntaxError and NameError and such, so that I can still see programming errors in the source code. So I would do 'with suppress(Exception, unless=(SyntaxError, ...)'. I do think that tearing down stuff and ignoring every exception really is a common thing to do. See __del__ for example. There's a reason we must make sure to ignore all exceptions before we return from __del__. We could actually use suppress with unless for this. If we try to handle exceptions in a tear-down situation instead, we will end in an infinite loop most of the time. But suppress.unless is useful for other things, too. It's a way to say: I want to ignore this set of errors, except this/these single ones from the set. This patch adds the 'except' part of this sentence to contextlib.suppress. -- ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27814] contextlib.suppress: Add whitelist argument
Michael Büsch added the comment: >an implementation of the vastly *less* common pattern: Ok, here are some numbers. My codebase is about 32 kLOC. $ git grep suppressAllExc |wc -l 20 $ git grep contextlib\\.suppress |wc -l 17 (suppressAllExc being my local version to suppress Exception, but exclude a few) So _neither_ one is pretty common. And that's not surprising, as exceptions ought to be properly handled most of the time. However the ratio between the two forms is about 1:1. So I don't agree that it would be "vastly *less* common". But I do accept if such a thing is not wanted upsteam, Altough it basically is a twoliner. I'll simply have to ship my own (I'll have to do that anyway for older Python versions. meh :) Thanks for the discussion. -- ___ Python tracker <http://bugs.python.org/issue27814> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com