Skip to content

Commit 69bb885

Browse files
committed
Move caching to pgSurface_UnlockBy
1 parent b8584ff commit 69bb885

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src_c/pixelcopy.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,8 @@ surface_to_array(PyObject *self, PyObject *args, PyObject *kwds)
815815
if (view_p->ndim == 2) {
816816
if (view_kind == VIEWKIND_RGB) {
817817
if (_copy_mapped(view_p, surf)) {
818-
int error_occurred = (PyErr_Occurred() != NULL);
819-
if (error_occurred) {
820-
CACHE_EXCEPTION
821-
}
822818
pgBuffer_Release(&pg_view);
823819
pgSurface_Unlock(surfobj);
824-
if (error_occurred)
825-
RESTORE_EXCEPTION
826820
return 0;
827821
}
828822
}
@@ -1164,10 +1158,7 @@ map_array(PyObject *self, PyObject *args)
11641158
if (is_tar_alloc) {
11651159
pgBuffer_Release(&tar_pg_view);
11661160
}
1167-
CACHE_EXCEPTION
1168-
PyErr_Clear();
11691161
pgSurface_Unlock(format_surf);
1170-
RESTORE_EXCEPTION
11711162
return 0;
11721163
}
11731164

src_c/surflock.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ pgSurface_UnlockBy(pgSurfaceObject *surfobj, PyObject *lockobj)
131131
}
132132
if (weakref_getref_result == 1) {
133133
if (ref == lockobj) {
134+
CACHE_EXCEPTION
134135
if (PySequence_DelItem(surf->locklist, len) == -1) {
135136
Py_DECREF(ref);
137+
RESTORE_EXCEPTION
136138
return 0;
137139
}
138140
else {
139141
found = 1;
140142
}
143+
RESTORE_EXCEPTION
141144
}
142145
Py_DECREF(ref);
143146
}
@@ -153,12 +156,14 @@ pgSurface_UnlockBy(pgSurfaceObject *surfobj, PyObject *lockobj)
153156
noerror = 0;
154157
}
155158
else if (weakref_getref_result == 0) {
159+
CACHE_EXCEPTION
156160
if (PySequence_DelItem(surf->locklist, len) == -1) {
157161
noerror = 0;
158162
}
159163
else {
160164
found++;
161165
}
166+
RESTORE_EXCEPTION
162167
}
163168
else if (weakref_getref_result == 1) {
164169
Py_DECREF(ref);

0 commit comments

Comments
 (0)