8000 Fix compatibility with ISO C89 needed by "gnu89" standard of GCC 4.8:… · stackless-dev/stackless@43a0ae9 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 43a0ae9

Browse files
asottilelarryhastings
authored andcommitted
Fix compatibility with ISO C89 needed by "gnu89" standard of GCC 4.8: use C89 for loops in backported pickle patch (python#12622)
1 parent 221178a commit 43a0ae9

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix compatibility with ISO C89 needed by "gnu89" standard of GCC 4.8: use C89 for loops in backported pickle patch. Patch by Anthony Sottile.

Modules/_pickle.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ PyMemoTable_New(void)
658658
static PyMemoTable *
659659
PyMemoTable_Copy(PyMemoTable *self)
660660
{
661+
size_t i;
661662
PyMemoTable *new = PyMemoTable_New();
662663
if (new == NULL)
663664
return NULL;
@@ -674,7 +675,7 @@ PyMemoTable_Copy(PyMemoTable *self)
674675
PyErr_NoMemory();
675676
return NULL;
676677
}
677-
for (size_t i = 0; i < self->mt_allocated; i++) {
678+
for (i = 0; i < self->mt_allocated; i++) {
678679
Py_XINCREF(self->mt_table[i].me_key);
679680
}
680681
memcpy(new->mt_table, self->mt_table,
@@ -4198,13 +4199,14 @@ static PyObject *
41984199
_pickle_PicklerMemoProxy_copy_impl(PicklerMemoProxyObject *self)
41994200
/*[clinic end generated code: output=bb83a919d29225ef input=b73043485ac30b36]*/
42004201
{
4202+
size_t i;
42014203
PyMemoTable *memo;
42024204
PyObject *new_memo = PyDict_New();
42034205
if (new_memo == NULL)
42044206
return NULL;
42054207

42064208
memo = self->pickler->memo;
4207-
for (size_t i = 0; i < memo->mt_allocated; ++i) {
4209+
for (i = 0; i < memo->mt_allocated; ++i) {
42084210
PyMemoEntry entry = memo->mt_table[i];
42094211
if (entry.me_key != NULL) {
42104212
int status;
@@ -6773,6 +6775,7 @@ Unpickler_get_memo(UnpicklerObject *self)
67736775
static int
67746776
Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
67756777
{
6778+
size_t i;
67766779
PyObject **new_memo;
67776780
size_t new_memo_size = 0;
67786781

@@ -6791,7 +6794,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
67916794
if (new_memo == NULL)
67926795
return -1;
67936796

6794-
for (size_t i = 0; i < new_memo_size; i++) {
6797+
for (i = 0; i < new_memo_size; i++) {
67956798
Py_XINCREF(unpickler->memo[i]);
67966799
new_memo[i] = unpickle 74FD r->memo[i];
67976800
}
@@ -6839,7 +6842,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
68396842

68406843
error:
68416844
if (new_memo_size) {
6842-
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
6845+
for (i = new_memo_size - 1; i != SIZE_MAX; i--) {
68436846
Py_XDECREF(new_memo[i]);
68446847
}
68456848
PyMem_FREE(new_memo);

0 commit comments

Comments
 (0)
0