Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
613 changes: 613 additions & 0 deletions .github/workflows/build_min.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Lib/test/test_capi/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_object_setattr(self):
self.assertRaises(RuntimeError, xsetattr, obj, 'evil', NULL)

self.assertRaises(RuntimeError, xsetattr, obj, 'evil', 'good')
self.assertRaises(NotWriteableError, xsetattr, 42, 'a', 5)
self.assertRaises(AttributeError, xsetattr, 42, 'a', 5)
self.assertRaises(TypeError, xsetattr, obj, 1, 5)
# CRASHES xsetattr(obj, NULL, 5)
# CRASHES xsetattr(NULL, 'a', 5)
Expand All @@ -136,7 +136,7 @@ def test_object_setattrstring(self):
self.assertRaises(RuntimeError, setattrstring, obj, b'evil', NULL)

self.assertRaises(RuntimeError, setattrstring, obj, b'evil', 'good')
self.assertRaises(NotWriteableError, setattrstring, 42, b'a', 5)
self.assertRaises(AttributeError, setattrstring, 42, b'a', 5)
self.assertRaises(TypeError, setattrstring, obj, 1, 5)
self.assertRaises(UnicodeDecodeError, setattrstring, obj, b'\xff', 5)
# CRASHES setattrstring(obj, NULL, 5)
Expand All @@ -153,7 +153,7 @@ def test_object_delattr(self):
xdelattr(obj, '\U0001f40d')
self.assertFalse(hasattr(obj, '\U0001f40d'))

self.assertRaises(NotWriteableError, xdelattr, 42, 'numerator')
self.assertRaises(AttributeError, xdelattr, 42, 'numerator')
self.assertRaises(RuntimeError, xdelattr, obj, 'evil')
self.assertRaises(TypeError, xdelattr, obj, 1)
# CRASHES xdelattr(obj, NULL)
Expand All @@ -170,7 +170,7 @@ def test_object_delattrstring(self):
delattrstring(obj, '\U0001f40d'.encode())
self.assertFalse(hasattr(obj, '\U0001f40d'))

self.assertRaises(NotWriteableError, delattrstring, 42, b'numerator')
self.assertRaises(AttributeError, delattrstring, 42, b'numerator')
self.assertRaises(RuntimeError, delattrstring, obj, b'evil')
self.assertRaises(UnicodeDecodeError, delattrstring, obj, b'\xff')
# CRASHES delattrstring(obj, NULL)
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ class SubType(types.ModuleType):

class MyInt(int):
__slots__ = ()
with self.assertRaises(NotWriteableError):
with self.assertRaises(TypeError):
(1).__class__ = MyInt

class MyFloat(float):
Expand All @@ -1091,7 +1091,7 @@ class MyComplex(complex):

class MyStr(str):
__slots__ = ()
with self.assertRaises(NotWriteableError):
with self.assertRaises(TypeError):
"a".__class__ = MyStr

class MyBytes(bytes):
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_stable_abi_ctypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2406,3 +2406,6 @@
added = '3.12'
[const.Py_TPFLAGS_ITEMS_AT_END]
added = '3.12'

[data.PyExc_NotWriteableError]
added = '4.0'
4 changes: 3 additions & 1 deletion Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3430,7 +3430,9 @@ PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError;
*/
SimpleExtendsException(PyExc_Exception, BufferError, "Buffer error.");


/*
* NotWriteableError extends Exception
*/
SimpleExtendsException(PyExc_Exception, NotWriteableError, "Object is not writeable.");


Expand Down
20 changes: 10 additions & 10 deletions Objects/regions.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef struct stack_s {
node* head;
} stack;

stack* stack_new(void){
static stack* stack_new(void){
stack* s = (stack*)malloc(sizeof(stack));
if(s == NULL){
return NULL;
Expand All @@ -31,7 +31,7 @@ stack* stack_new(void){
return s;
}

bool stack_push(stack* s, PyObject* object){
static bool stack_push(stack* s, PyObject* object){
node* n = (node*)malloc(sizeof(node));
if(n == NULL){
Py_DECREF(object);
Expand All @@ -48,7 +48,7 @@ bool stack_push(stack* s, PyObject* object){
return false;
}

PyObject* stack_pop(stack* s){
static PyObject* stack_pop(stack* s){
if(s->head == NULL){
return NULL;
}
Expand All @@ -61,7 +61,7 @@ PyObject* stack_pop(stack* s){
return object;
}

void stack_free(stack* s){
static void stack_free(stack* s){
while(s->head != NULL){
PyObject* op = stack_pop(s);
Py_DECREF(op);
Expand All @@ -70,11 +70,11 @@ void stack_free(stack* s){
free(s);
}

bool stack_empty(stack* s){
static bool stack_empty(stack* s){
return s->head == NULL;
}

void stack_print(stack* s){
static void stack_print(stack* s){
_Py_VPYDBG("stack: ");
node* n = s->head;
while(n != NULL){
Expand All @@ -84,7 +84,7 @@ void stack_print(stack* s){
}
}

bool is_c_wrapper(PyObject* obj){
static bool is_c_wrapper(PyObject* obj){
return PyCFunction_Check(obj) || Py_IS_TYPE(obj, &_PyMethodWrapper_Type) || Py_IS_TYPE(obj, &PyWrapperDescr_Type);
}

Expand All @@ -97,7 +97,7 @@ bool is_c_wrapper(PyObject* obj){
} \
} while(0)

PyObject* make_global_immutable(PyObject* globals, PyObject* name)
static PyObject* make_global_immutable(PyObject* globals, PyObject* name)
{
PyObject* value = PyDict_GetItem(globals, name); // value.rc = x
_Py_VPYDBG("value(");
Expand Down Expand Up @@ -127,7 +127,7 @@ PyObject* make_global_immutable(PyObject* globals, PyObject* name)
* just those, and prevent those keys from being updated in the global dictionary
* from this point onwards.
*/
PyObject* walk_function(PyObject* op, stack* frontier)
static PyObject* walk_function(PyObject* op, stack* frontier)
{
PyObject* builtins;
PyObject* globals;
Expand Down Expand Up @@ -360,7 +360,7 @@ PyObject* walk_function(PyObject* op, stack* frontier)
} \
} while(0)

int _makeimmutable_visit(PyObject* obj, void* frontier)
static int _makeimmutable_visit(PyObject* obj, void* frontier)
{
_Py_VPYDBG("visit(");
_Py_VPYDBGPRINT(obj);
Expand Down
2 changes: 1 addition & 1 deletion PC/python3dll.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,7 @@ Make 'obj' and its entire reachable object graph immutable.

static PyObject *
builtin_makeimmutable(PyObject *module, PyObject *obj)
/*[clinic end generated code: output=4e665122542dfd24 input=21a50256fa4fb099]*/
/*[clinic end generated code: output=4e665122542dfd24 input=bec4cf1797c848d4]*/
{
return Py_MakeImmutable(obj);
}
Expand Down
4 changes: 2 additions & 2 deletions Python/clinic/bltinmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Tools/c-analyzer/cpython/ignored.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ Modules/timemodule.c init_timezone YEAR -
Objects/bytearrayobject.c - _PyByteArray_empty_string -
Objects/complexobject.c - c_1 -
Objects/exceptions.c - static_exceptions -
Objects/exceptions.c - _PyExc_NotWriteableError -
Objects/exceptions.c - PyExc_NotWriteableError -
Objects/genobject.c - ASYNC_GEN_IGNORED_EXIT_MSG -
Objects/genobject.c - NON_INIT_CORO_MSG -
Objects/longobject.c - _PyLong_DigitValue -
Expand Down