MCPcopy Index your code
hub / github.com/python/cpython / _raise_error

Method _raise_error

Lib/_pydecimal.py:4005–4025  ·  view source on GitHub ↗

Handles an error If the flag is in _ignored_flags, returns the default response. Otherwise, it sets the flag, then, if the corresponding trap_enabler is set, it reraises the exception. Otherwise, it returns the default value after setting the flag.

(self, condition, explanation = None, *args)

Source from the content-addressed store, hash-verified

4003 __copy__ = copy
4004
4005 def _raise_error(self, condition, explanation = None, *args):
4006 """Handles an error
4007
4008 If the flag is in _ignored_flags, returns the default response.
4009 Otherwise, it sets the flag, then, if the corresponding
4010 trap_enabler is set, it reraises the exception. Otherwise, it returns
4011 the default value after setting the flag.
4012 """
4013 error = _condition_map.get(condition, condition)
4014 if error in self._ignored_flags:
4015 # Don't touch the flag
4016 return error().handle(self, *args)
4017
4018 self.flags[error] = 1
4019 if not self.traps[error]:
4020 # The errors define how to handle themselves.
4021 return condition().handle(self, *args)
4022
4023 # Errors should only be risked on copies of the context
4024 # self._ignored_flags = []
4025 raise error(explanation)
4026
4027 def _ignore_all_flags(self):
4028 """Ignore all flags, if they are raised"""

Callers 15

create_decimalMethod · 0.95
__new__Method · 0.80
_check_nansMethod · 0.80
_compare_check_nansMethod · 0.80
__add__Method · 0.80
__mul__Method · 0.80
__truediv__Method · 0.80
_divideMethod · 0.80
__divmod__Method · 0.80
__mod__Method · 0.80
remainder_nearMethod · 0.80
__floordiv__Method · 0.80

Calls 3

errorFunction · 0.70
getMethod · 0.45
handleMethod · 0.45

Tested by 1

raise_errorMethod · 0.64