This is a backport of the BaseExceptionGroup and ExceptionGroup classes from Python 3.11.

Overview

This is a backport of the BaseExceptionGroup and ExceptionGroup classes from Python 3.11.

It contains the following:

  • The exceptiongroup.BaseExceptionGroup and exceptiongroup.ExceptionGroup classes
  • A utility function (exceptiongroup.catch()) for catching exceptions possibly nested in an exception group
  • Patches to the TracebackException class that properly formats exception groups (installed on import)
  • An exception hook that handles formatting of exception groups through TracebackException (installed on import)

The only difference with the Python 3.11 standard library implementation is that there is no __note__ attribute in BaseExceptionGroup or ExceptionGroup.

If this package is imported on Python 3.11 or later, the built-in implementations of the exception group classes are used instead, TracebackException is not monkey patched and the exception hook won't be installed.

.. seealso:: https://docs.python.org/3/library/exceptions.html

Catching exceptions

Due to the lack of the except* syntax introduced by PEP 654 in earlier Python versions, you need to use exceptiongroup.catch() to catch exceptions that are potentially nested inside an exception group. This function returns a context manager that calls the given handler for any exceptions matching the first argument.

So, the following Python 3.11+ code:

try:
    ...
except* (ValueError, KeyError) as exc:
    print('Caught exception:', type(exc))

would be written as follows:

from exceptiongroup import catch

def handler(exc: Exception) -> None:
    print('Caught exception:', type(exc))

with catch((ValueError, KeyError), handler):
    ...

Note

Just like with except*, you cannot handle BaseExceptionGroup or ExceptionGroup with catch().

Owner
Alex Gr枚nholm
Alex Gr枚nholm
fast_bss_eval is a fast implementation of the bss_eval metrics for the evaluation of blind source separation.

fast_bss_eval Do you have a zillion BSS audio files to process and it is taking days ? Is your simulation never ending ? Fear no more! fast_bss_eval i

Robin Scheibler 99 Dec 13, 2022
Backend/API for the Mumble.dev, an open source social media application.

Welcome to the Mumble Api Repository Getting Started If you are trying to use this project for the first time, you can get up and running by following

Dennis Ivy 189 Dec 27, 2022
Logging-monitoring-instrumentation - A brief repository on logging monitoring and instrumentation in Python

logging-monitoring-instrumentation A brief repository on logging monitoring and

Noah Gift 6 Feb 17, 2022
馃煡This is an overview of how to set up and use DataStore3 in your Roblox experiences

Welcome to DataStore3 馃憢 This is an overview of how to set up and use DataStore3 in your Roblox experiences What is it? 馃 DataStore3 is a service tha

Reece Harris 7 Aug 19, 2022
Dungeon Dice Rolls is an aplication that the user can roll dices (d4, d6, d8, d10, d12, d20 and d100) and store the results in one of the 6 arrays.

Dungeon Dice Rolls is an aplication that the user can roll dices (d4, d6, d8, d10, d12, d20 and d100) and store the results in one of the 6 arrays.

Bracero 1 Dec 31, 2021
A one place destination to check whatever is trending on the top social and news websites at present.

UpTrend A one place destination to check whatever is trending on the top social and news websites at present. Explore the docs 禄 View Demo 路 Report Bu

Google Developer Student Clubs - JGEC 10 Oct 03, 2021
An alternative app for core Armoury Crate functions.

NoROG DISCLAIMER: Use at your own risk. This is alpha-quality software. It has not been extensively tested, though I personally run it daily on my lap

12 Nov 29, 2022
Bootcamp de Introducci贸n a la Programaci贸n. M贸dulo 6: Matem谩ticas Discretas

M贸dulo 6: Matem谩ticas Discretas 脷ltima actualizaci贸n: 12 de marzo Ir贸nicamente, las matem谩ticas discretas son las matem谩ticas que lo cuentan todo. Si

Cynthia Castillo 34 Sep 29, 2022
An easy way to access the Scratch API!

The majority of people are likely here because they want to easily access the Scratch API!

rgantzos 0 May 04, 2022
My solution for a MARL problem on a Grid Environment with Q-tables.

To run the project, run: conda create --name env python=3.7 pip install -r requirements.txt python run.py To-do: Add direction to the state space Take

Merve Noyan 12 Dec 25, 2021
Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. 馃挍馃挋馃挌

Collection of tools to be more productive in your work environment and to avoid certain repetitive tasks. 馃挍馃挋馃挌

Raja Rakotonirina 2 Jan 10, 2022
A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

A set of scripts for a two-step procedure to measure the value of access to destinations across several modes of travel within a geographic area.

Institute for Transportation and Development Policy 2 Oct 16, 2022
Run Windows Applications on Linux as if they are native, Use linux applications to launch files files located in windows vm without needing to install applications on vm. With easy to use configuration GUI

Run Windows Applications on Linux as if they are native, Use linux applications to launch files files located in windows vm without needing to install applications on vm. With easy to use configurati

Casu Al Snek 2k Jan 02, 2023
Web3 Solidity Connector

With this project, you can compile your sol files and create new transactions including creating contract and calling the state changer functions. You can integrate integrate your sol files with Pyth

Fethi Tekyaygil 3 Oct 09, 2022
Opendrop - An open Apple AirDrop implementation written in Python

OpenDrop: an Open Source AirDrop Implementation OpenDrop is a command-line tool that allows sharing files between devices directly over Wi-Fi. Its uni

Secure Mobile Networking Lab 7.5k Jan 03, 2023
Simple macOS StatusBar app to remind you to unplug your laptop when sufficiently charged

ChargeMon Simple macOS StatusBar app to monitor battery charge status and remind you to unplug your Mac when the battery is sufficiently charged Overv

Rhet Turnbull 5 Jan 25, 2022
Manually Install Python 2.7 pip without any problem !

Python2.7_install_pip Manually Install Python 2.7 pip without any problem ! Download installPip.py to your system and Run the code using this Command

Ali Jafari 1 Dec 09, 2021
Demo Python project using Conda and Poetry

Conda Poetry This is a demonstration of how Conda and Poetry can be used in a Python project for dev dependency management and production deployment.

Ryan Allen 2 Apr 26, 2022
Store Simulation

Almacenes Para clonar el Repositorio: Vaya a la terminal de Linux o Mac, o a la cmd en Windows y ejecute:

Johan Posada 1 Nov 12, 2021
Analysis of ROM image for Norsk Data VDU 301 S

This repository is meant to analyze the ROM images from Norsk Data VDU 301 S as provided at by Torfinn. To combine the two ROM image halves and extrac

Sebastian Rasmussen 1 Oct 21, 2021