classification
Title: backport of pickle fixes to Python 3.5.7 uses C99 for loops
Type: Stage: patch review
Components: Build Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, larry, thehesiod, vstinner
Priority: normal Keywords: patch

Created on 2019-03-29 21:24 by Anthony Sottile, last changed 2019-04-08 22:53 by thehesiod.

Pull Requests
URL Status Linked Edit
PR 12622 merged Anthony Sottile, 2019-03-29 21:31
Messages (5)
msg339152 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-03-29 21:24
While building python 3.5.7 for https://github.com/deadsnakes

../Modules/_pickle.c: In function 'PyMemoTable_Copy':
../Modules/_pickle.c:677:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < self->mt_allocated; i++) {
     ^
../Modules/_pickle.c:677:5: note: use option -std=c99 or -std=gnu99 to compile your code
../Modules/_pickle.c: In function '_pickle_PicklerMemoProxy_copy_impl':
../Modules/_pickle.c:4207:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (size_t i = 0; i < memo->mt_allocated; ++i) {
     ^
../Modules/_pickle.c: In function 'Unpickler_set_memo':
../Modules/_pickle.c:6794:9: error: 'for' loop initial declarations are only allowed in C99 mode
         for (size_t i = 0; i < new_memo_size; i++) {
         ^
../Modules/_pickle.c:6842:9: error: 'for' loop initial declarations are only allowed in C99 mode
         for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
         ^
make[1]: *** [Modules/_pickle.o] Error 1


This cherry-pick caused the regression: https://github.com/python/cpython/commit/ef33dd6036aafbd3f06c1d56e2b1a81dae3da63c
msg339605 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-08 10:23
> ../Modules/_pickle.c:677:5: error: 'for' loop initial declarations are only allowed in C99 mode

Why do you get an error? Which compiler do you use to build deadsnakes?
msg339606 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-04-08 10:23
> Which compiler do you use to build deadsnakes?

Sorry, which compiler *flags*.
msg339639 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-04-08 13:48
It's a rather oldish gcc in this case. (4.8.4 + whatever ubuntu patches). Here's a full (successful) build log (including the combinations of flags) after patching: https://launchpadlibrarian.net/416985438/buildlog_ubuntu-trusty-amd64.python3.5_3.5.7-1+trusty1_BUILDING.txt.gz

iirc this version of gcc defaults to "gnu89" as the standard c target
msg339680 - (view) Author: Alexander Mohr (thehesiod) * Date: 2019-04-08 22:53
I hit this as well in debian:jessie, and if I enabled -std=c99 I hit this issue: https://github.com/dvarrazzo/py-setproctitle/issues/62
History
Date User Action Args
2019-04-08 22:53:28thehesiodsetnosy: + thehesiod
messages: + msg339680
2019-04-08 13:48:04Anthony Sottilesetmessages: + msg339639
2019-04-08 10:23:40vstinnersetmessages: + msg339606
2019-04-08 10:23:23vstinnersetmessages: + msg339605
2019-03-30 02:18:35xtreaksetnosy: + vstinner, larry
2019-03-29 21:31:18Anthony Sottilesetkeywords: + patch
stage: patch review
pull_requests: + pull_request12556
2019-03-29 21:24:56Anthony Sottilecreate