faultless


Namefaultless JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/dzshn/faultless
SummaryCatch segfaults as normal exceptions
upload_time2023-01-16 03:14:13
maintainer
docs_urlNone
authorSofia Lima
requires_python>=3.8,<4.0
licenseMIT
keywords segfault
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # faultless: catch 'em segfaults!

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dzshn/faultless/test.yml?style=for-the-badge)](https://github.com/dzshn/faultless/actions)
[![Codecov](https://img.shields.io/codecov/c/github/dzshn/faultless?style=for-the-badge)](https://app.codecov.io/gh/dzshn/faultless)
[![PyPI](https://img.shields.io/pypi/v/faultless?style=for-the-badge)](https://pypi.org/project/faultless)
![GitHub top language](https://img.shields.io/github/languages/top/dzshn/faultless?style=for-the-badge)

```py
import ctypes
from faultless import faultless, SegmentationFault


@faultless
def nullptr():
    return ctypes.c_void_p.from_address(0).value


try:
    nullptr()
except SegmentationFault:
    print("Safe!")
```

## Installation

Install with pip: (only requires python 3.8 or higher)

```sh
$ pip install faultless
```

Install from source with [poetry](https://python-poetry.org/): (includes test tools)

```sh
$ git clone https://github.com/dzshn/faultless
$ cd faultless
$ poetry install
```

> **Note**
> Windows is currently unsupported. Other OSes (Linux, BSD, MacOS, anything POSIX) 
> will work fine and Cygwin and WSL likely work. Contributions are welcome!

## Usage

A complete summary of the library is as follows:

```py
from faultless import Interrupt, SignalInterrupt, SegmentationFault, faultless

@faultless
def dangerous_function():
    ...

try:
    result = dangerous_function()

except SegmentationFault:
    # the function segfaulted
    ...
except SignalInterrupt:
    # the function was killed by a signal (e.g. `SIGKILL`)
    ...
except Interrupt:
    # the function has exit abruptly (e.g. `exit()`)
    ...
except Exception:
    # the function itself raised an exception
    ...
```

Functions wrapped by `faultless` will be unable to crash the interpreter
directly. It does, in short, execute the function in a fork, so that any sort
of fault can be handled. Currently, return values and exceptions are handled
correctly, but non-local variables aren't, so be wary of changing global state.

## wait what do you mean segfaults and python w-

uhhhhhhhhh

yeah you can do that

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dzshn/faultless",
    "name": "faultless",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "segfault",
    "author": "Sofia Lima",
    "author_email": "me@dzshn.xyz",
    "download_url": "https://files.pythonhosted.org/packages/a1/59/d529a59706b07751689aef464e3ca02e49f916ad9155f47632cfba00b255/faultless-1.0.1.tar.gz",
    "platform": null,
    "description": "# faultless: catch 'em segfaults!\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dzshn/faultless/test.yml?style=for-the-badge)](https://github.com/dzshn/faultless/actions)\n[![Codecov](https://img.shields.io/codecov/c/github/dzshn/faultless?style=for-the-badge)](https://app.codecov.io/gh/dzshn/faultless)\n[![PyPI](https://img.shields.io/pypi/v/faultless?style=for-the-badge)](https://pypi.org/project/faultless)\n![GitHub top language](https://img.shields.io/github/languages/top/dzshn/faultless?style=for-the-badge)\n\n```py\nimport ctypes\nfrom faultless import faultless, SegmentationFault\n\n\n@faultless\ndef nullptr():\n    return ctypes.c_void_p.from_address(0).value\n\n\ntry:\n    nullptr()\nexcept SegmentationFault:\n    print(\"Safe!\")\n```\n\n## Installation\n\nInstall with pip: (only requires python 3.8 or higher)\n\n```sh\n$ pip install faultless\n```\n\nInstall from source with [poetry](https://python-poetry.org/): (includes test tools)\n\n```sh\n$ git clone https://github.com/dzshn/faultless\n$ cd faultless\n$ poetry install\n```\n\n> **Note**\n> Windows is currently unsupported. Other OSes (Linux, BSD, MacOS, anything POSIX) \n> will work fine and Cygwin and WSL likely work. Contributions are welcome!\n\n## Usage\n\nA complete summary of the library is as follows:\n\n```py\nfrom faultless import Interrupt, SignalInterrupt, SegmentationFault, faultless\n\n@faultless\ndef dangerous_function():\n    ...\n\ntry:\n    result = dangerous_function()\n\nexcept SegmentationFault:\n    # the function segfaulted\n    ...\nexcept SignalInterrupt:\n    # the function was killed by a signal (e.g. `SIGKILL`)\n    ...\nexcept Interrupt:\n    # the function has exit abruptly (e.g. `exit()`)\n    ...\nexcept Exception:\n    # the function itself raised an exception\n    ...\n```\n\nFunctions wrapped by `faultless` will be unable to crash the interpreter\ndirectly. It does, in short, execute the function in a fork, so that any sort\nof fault can be handled. Currently, return values and exceptions are handled\ncorrectly, but non-local variables aren't, so be wary of changing global state.\n\n## wait what do you mean segfaults and python w-\n\nuhhhhhhhhh\n\nyeah you can do that\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Catch segfaults as normal exceptions",
    "version": "1.0.1",
    "split_keywords": [
        "segfault"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "34fb85c4b99b2f264ac3d92b7e9ea92f9872cc016c0bac094055be8141a80540",
                "md5": "121075a68f327312d96d83fcf7b90e13",
                "sha256": "6d0f0214fa9fa3b2e382e99e128aca668a4eaa2906ac36e2463054a93f131bd6"
            },
            "downloads": -1,
            "filename": "faultless-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "121075a68f327312d96d83fcf7b90e13",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 4643,
            "upload_time": "2023-01-16T03:14:12",
            "upload_time_iso_8601": "2023-01-16T03:14:12.403544Z",
            "url": "https://files.pythonhosted.org/packages/34/fb/85c4b99b2f264ac3d92b7e9ea92f9872cc016c0bac094055be8141a80540/faultless-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a159d529a59706b07751689aef464e3ca02e49f916ad9155f47632cfba00b255",
                "md5": "033bed48bcee59861bce835f53bb5c03",
                "sha256": "e126a55e4025fd1da5f90122118eed9cb062dd05519ca04e42eb7d334bda29ca"
            },
            "downloads": -1,
            "filename": "faultless-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "033bed48bcee59861bce835f53bb5c03",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 4689,
            "upload_time": "2023-01-16T03:14:13",
            "upload_time_iso_8601": "2023-01-16T03:14:13.700354Z",
            "url": "https://files.pythonhosted.org/packages/a1/59/d529a59706b07751689aef464e3ca02e49f916ad9155f47632cfba00b255/faultless-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-16 03:14:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dzshn",
    "github_project": "faultless",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "faultless"
}
        
Elapsed time: 0.09084s