exceptioncontext-1.0.9
توضیحات
Context managers for controlling exception chaining.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | exceptioncontext-1.0.9 |
| نام | exceptioncontext |
| نسخه کتابخانه | 1.0.9 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Alexander Kozhevnikov |
| ایمیل نویسنده | mentalisttraceur@gmail.com |
| آدرس صفحه اصلی | https://github.com/mentalisttraceur/python-exceptioncontext |
| آدرس اینترنتی | https://pypi.org/project/exceptioncontext/ |
| مجوز | 0BSD |
Context Managers for Controlling Exception Chaining
===================================================
Provides a different way of controlling exception chaining
(the implicit ``__context__`` and explicit ``__cause__``)
beyond just ``raise ... from ...``.
Versioning
----------
This library's version numbers follow the `SemVer 2.0.0
specification <https://semver.org/spec/v2.0.0.html>`_.
Installation
------------
::
pip install exceptioncontext
Usage
-----
Import as needed:
.. code:: python
from exceptioncontext import cause, context, suppress_context
Explicitly chain exception (set ``__cause__``):
.. code:: python
with cause(Exception("foo")):
raise Exception("bar")
Override implicitly chained exception (set ``__context__``):
.. code:: python
with context(Exception("foo")):
raise Exception("bar")
Manually control context suppression (set ``__suppress_context__``):
.. code:: python
with suppress_context(False):
raise Exception("foo")
``exceptioncontext`` makes exception chaining fully independent of
the ``raise`` statement, and freely composable with other code:
.. code:: python
with cause(earlier_exception):
helper_function()
Portability
-----------
Portable to all releases of both Python 3 and Python 2.
(The oldest tested is 2.5, but it will likely work as far
back as 2.2 when paired with something like |with|_.)
.. |with| replace:: ``with-as-a-function``
.. _with: https://pypi.org/project/with-as-a-function
On implementations of Python where setting the exception chaining
attributes on an exception raises an ``AttributeError``,
``exceptioncontext`` gracefully degrades to doing nothing.
نحوه نصب
نصب پکیج whl exceptioncontext-1.0.9:
pip install exceptioncontext-1.0.9.whl
نصب پکیج tar.gz exceptioncontext-1.0.9:
pip install exceptioncontext-1.0.9.tar.gz