Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:mcepl:branches:devel:languages:python:Factory
python36
bpo30697-restore-PyExc_RecursionErrorInst.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bpo30697-restore-PyExc_RecursionErrorInst.patch of Package python36
From a2270a9f17f510c476d687c9ed89bb04b8bd149a Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis <cstratak@redhat.com> Date: Fri, 19 Jun 2020 17:06:08 +0200 Subject: [PATCH] restore PyExc_RecursionErrorInst symbol Restore the public PyExc_RecursionErrorInst symbol that was removed from the 3.6.4 release upstream. Fixes: bpo#30697 Patch: bpo30697-restore-PyExc_RecursionErrorInst.patch --- Include/pyerrors.h | 2 ++ Objects/exceptions.c | 32 ++++++++++++++++++++++++++++++++ PC/python3.def | 1 + 3 files changed, 35 insertions(+) diff --git a/Include/pyerrors.h b/Include/pyerrors.h index 44f20303c29..8b5c2748deb 100644 --- a/Include/pyerrors.h +++ b/Include/pyerrors.h @@ -219,6 +219,8 @@ PyAPI_DATA(PyObject *) PyExc_IOError; PyAPI_DATA(PyObject *) PyExc_WindowsError; #endif +PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; + /* Predefined warning categories */ PyAPI_DATA(PyObject *) PyExc_Warning; PyAPI_DATA(PyObject *) PyExc_UserWarning; diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 6f3b986d324..76bb1a46970 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2434,6 +2434,12 @@ SimpleExtendsException(PyExc_Warning, ResourceWarning, +/* Pre-computed RecursionError instance for when recursion depth is reached. + Meant to be used when normalizing the exception for exceeding the recursion + depth will cause its own infinite recursion. +*/ +PyObject *PyExc_RecursionErrorInst = NULL; + #define PRE_INIT(TYPE) \ if (!(_PyExc_ ## TYPE.tp_flags & Py_TPFLAGS_READY)) { \ if (PyType_Ready(&_PyExc_ ## TYPE) < 0) \ @@ -2695,11 +2701,37 @@ _PyExc_Init(PyObject *bltinmod) ADD_ERRNO(TimeoutError, ETIMEDOUT); preallocate_memerrors(); + + if (!PyExc_RecursionErrorInst) { + PyExc_RecursionErrorInst = BaseException_new(&_PyExc_RecursionError, NULL, NULL); + if (!PyExc_RecursionErrorInst) + Py_FatalError("Cannot pre-allocate RecursionError instance for " + "recursion errors"); + else { + PyBaseExceptionObject *err_inst = + (PyBaseExceptionObject *)PyExc_RecursionErrorInst; + PyObject *args_tuple; + PyObject *exc_message; + exc_message = PyUnicode_FromString("maximum recursion depth exceeded"); + if (!exc_message) + Py_FatalError("cannot allocate argument for RecursionError " + "pre-allocation"); + args_tuple = PyTuple_Pack(1, exc_message); + if (!args_tuple) + Py_FatalError("cannot allocate tuple for RecursionError " + "pre-allocation"); + Py_DECREF(exc_message); + if (BaseException_init(err_inst, args_tuple, NULL)) + Py_FatalError("init of pre-allocated RecursionError failed"); + Py_DECREF(args_tuple); + } + } } void _PyExc_Fini(void) { + Py_CLEAR(PyExc_RecursionErrorInst); free_preallocated_memerrors(); Py_CLEAR(errnomap); } diff --git a/PC/python3.def b/PC/python3.def index 4fc4a6814ee..ff70718fc37 100644 --- a/PC/python3.def +++ b/PC/python3.def @@ -224,6 +224,7 @@ EXPORTS PyExc_PermissionError=python36.PyExc_PermissionError DATA PyExc_ProcessLookupError=python36.PyExc_ProcessLookupError DATA PyExc_RecursionError=python36.PyExc_RecursionError DATA + PyExc_RecursionErrorInst=python36.PyExc_RecursionErrorInst DATA PyExc_ReferenceError=python36.PyExc_ReferenceError DATA PyExc_ResourceWarning=python36.PyExc_ResourceWarning DATA PyExc_RuntimeError=python36.PyExc_RuntimeError DATA -- 2.46.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor