Skip to content

Commit e007845

Browse files
authored
Add a minimal CI (#13)
* Add a minimal CI * Apply static to internal functions. * Regened files and added a missing entry. * Change error to fix tests. * Manually allowing exception.
1 parent 759fbf8 commit e007845

12 files changed

Lines changed: 643 additions & 21 deletions

File tree

.github/workflows/build_min.yml

Lines changed: 613 additions & 0 deletions
Large diffs are not rendered by default.

Doc/data/stable_abi.dat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_abstract.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_object_setattr(self):
116116
self.assertRaises(RuntimeError, xsetattr, obj, 'evil', NULL)
117117

118118
self.assertRaises(RuntimeError, xsetattr, obj, 'evil', 'good')
119-
self.assertRaises(NotWriteableError, xsetattr, 42, 'a', 5)
119+
self.assertRaises(AttributeError, xsetattr, 42, 'a', 5)
120120
self.assertRaises(TypeError, xsetattr, obj, 1, 5)
121121
# CRASHES xsetattr(obj, NULL, 5)
122122
# CRASHES xsetattr(NULL, 'a', 5)
@@ -136,7 +136,7 @@ def test_object_setattrstring(self):
136136
self.assertRaises(RuntimeError, setattrstring, obj, b'evil', NULL)
137137

138138
self.assertRaises(RuntimeError, setattrstring, obj, b'evil', 'good')
139-
self.assertRaises(NotWriteableError, setattrstring, 42, b'a', 5)
139+
self.assertRaises(AttributeError, setattrstring, 42, b'a', 5)
140140
self.assertRaises(TypeError, setattrstring, obj, 1, 5)
141141
self.assertRaises(UnicodeDecodeError, setattrstring, obj, b'\xff', 5)
142142
# CRASHES setattrstring(obj, NULL, 5)
@@ -153,7 +153,7 @@ def test_object_delattr(self):
153153
xdelattr(obj, '\U0001f40d')
154154
self.assertFalse(hasattr(obj, '\U0001f40d'))
155155

156-
self.assertRaises(NotWriteableError, xdelattr, 42, 'numerator')
156+
self.assertRaises(AttributeError, xdelattr, 42, 'numerator')
157157
self.assertRaises(RuntimeError, xdelattr, obj, 'evil')
158158
self.assertRaises(TypeError, xdelattr, obj, 1)
159159
# CRASHES xdelattr(obj, NULL)
@@ -170,7 +170,7 @@ def test_object_delattrstring(self):
170170
delattrstring(obj, '\U0001f40d'.encode())
171171
self.assertFalse(hasattr(obj, '\U0001f40d'))
172172

173-
self.assertRaises(NotWriteableError, delattrstring, 42, b'numerator')
173+
self.assertRaises(AttributeError, delattrstring, 42, b'numerator')
174174
self.assertRaises(RuntimeError, delattrstring, obj, b'evil')
175175
self.assertRaises(UnicodeDecodeError, delattrstring, obj, b'\xff')
176176
# CRASHES delattrstring(obj, NULL)

Lib/test/test_descr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ class SubType(types.ModuleType):
10761076

10771077
class MyInt(int):
10781078
__slots__ = ()
1079-
with self.assertRaises(NotWriteableError):
1079+
with self.assertRaises(TypeError):
10801080
(1).__class__ = MyInt
10811081

10821082
class MyFloat(float):
@@ -1091,7 +1091,7 @@ class MyComplex(complex):
10911091

10921092
class MyStr(str):
10931093
__slots__ = ()
1094-
with self.assertRaises(NotWriteableError):
1094+
with self.assertRaises(TypeError):
10951095
"a".__class__ = MyStr
10961096

10971097
class MyBytes(bytes):

Lib/test/test_stable_abi_ctypes.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Misc/stable_abi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,3 +2406,6 @@
24062406
added = '3.12'
24072407
[const.Py_TPFLAGS_ITEMS_AT_END]
24082408
added = '3.12'
2409+
2410+
[data.PyExc_NotWriteableError]
2411+
added = '4.0'

Objects/exceptions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3430,7 +3430,9 @@ PyObject *PyExc_MemoryError = (PyObject *) &_PyExc_MemoryError;
34303430
*/
34313431
SimpleExtendsException(PyExc_Exception, BufferError, "Buffer error.");
34323432

3433-
3433+
/*
3434+
* NotWriteableError extends Exception
3435+
*/
34343436
SimpleExtendsException(PyExc_Exception, NotWriteableError, "Object is not writeable.");
34353437

34363438

Objects/regions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef struct stack_s {
2020
node* head;
2121
} stack;
2222

23-
stack* stack_new(void){
23+
static stack* stack_new(void){
2424
stack* s = (stack*)malloc(sizeof(stack));
2525
if(s == NULL){
2626
return NULL;
@@ -31,7 +31,7 @@ stack* stack_new(void){
3131
return s;
3232
}
3333

34-
bool stack_push(stack* s, PyObject* object){
34+
static bool stack_push(stack* s, PyObject* object){
3535
node* n = (node*)malloc(sizeof(node));
3636
if(n == NULL){
3737
Py_DECREF(object);
@@ -48,7 +48,7 @@ bool stack_push(stack* s, PyObject* object){
4848
return false;
4949
}
5050

51-
PyObject* stack_pop(stack* s){
51+
static PyObject* stack_pop(stack* s){
5252
if(s->head == NULL){
5353
return NULL;
5454
}
@@ -61,7 +61,7 @@ PyObject* stack_pop(stack* s){
6161
return object;
6262
}
6363

64-
void stack_free(stack* s){
64+
static void stack_free(stack* s){
6565
while(s->head != NULL){
6666
PyObject* op = stack_pop(s);
6767
Py_DECREF(op);
@@ -70,11 +70,11 @@ void stack_free(stack* s){
7070
free(s);
7171
}
7272

73-
bool stack_empty(stack* s){
73+
static bool stack_empty(stack* s){
7474
return s->head == NULL;
7575
}
7676

77-
void stack_print(stack* s){
77+
static void stack_print(stack* s){
7878
_Py_VPYDBG("stack: ");
7979
node* n = s->head;
8080
while(n != NULL){
@@ -84,7 +84,7 @@ void stack_print(stack* s){
8484
}
8585
}
8686

87-
bool is_c_wrapper(PyObject* obj){
87+
static bool is_c_wrapper(PyObject* obj){
8888
return PyCFunction_Check(obj) || Py_IS_TYPE(obj, &_PyMethodWrapper_Type) || Py_IS_TYPE(obj, &PyWrapperDescr_Type);
8989
}
9090

@@ -97,7 +97,7 @@ bool is_c_wrapper(PyObject* obj){
9797
} \
9898
} while(0)
9999

100-
PyObject* make_global_immutable(PyObject* globals, PyObject* name)
100+
static PyObject* make_global_immutable(PyObject* globals, PyObject* name)
101101
{
102102
PyObject* value = PyDict_GetItem(globals, name); // value.rc = x
103103
_Py_VPYDBG("value(");
@@ -127,7 +127,7 @@ PyObject* make_global_immutable(PyObject* globals, PyObject* name)
127127
* just those, and prevent those keys from being updated in the global dictionary
128128
* from this point onwards.
129129
*/
130-
PyObject* walk_function(PyObject* op, stack* frontier)
130+
static PyObject* walk_function(PyObject* op, stack* frontier)
131131
{
132132
PyObject* builtins;
133133
PyObject* globals;
@@ -360,7 +360,7 @@ PyObject* walk_function(PyObject* op, stack* frontier)
360360
} \
361361
} while(0)
362362

363-
int _makeimmutable_visit(PyObject* obj, void* frontier)
363+
static int _makeimmutable_visit(PyObject* obj, void* frontier)
364364
{
365365
_Py_VPYDBG("visit(");
366366
_Py_VPYDBGPRINT(obj);

PC/python3dll.c

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bltinmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ Make 'obj' and its entire reachable object graph immutable.
27702770

27712771
static PyObject *
27722772
builtin_makeimmutable(PyObject *module, PyObject *obj)
2773-
/*[clinic end generated code: output=4e665122542dfd24 input=21a50256fa4fb099]*/
2773+
/*[clinic end generated code: output=4e665122542dfd24 input=bec4cf1797c848d4]*/
27742774
{
27752775
return Py_MakeImmutable(obj);
27762776
}

0 commit comments

Comments
 (0)