classification
Title: PyInit_timezone() must return a value
Type: compile error Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2018-12-01 18:03 by serhiy.storchaka, last changed 2018-12-03 23:27 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10861 merged vstinner, 2018-12-03 10:34
PR 10864 merged vstinner, 2018-12-03 11:10
PR 10865 merged vstinner, 2018-12-03 11:22
PR 10882 merged miss-islington, 2018-12-03 23:09
Messages (8)
msg330858 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-01 18:03
PyInit_timezone() is declared as returning int, but it contains return statements without value.

From compiler output on Windows:

  timemodule.c
..\Modules\timemodule.c(1584): warning C4033: 'PyInit_timezone' must return a value [C:\py\cpython3.8\PCbuild\pythoncore.vcxproj]
..\Modules\timemodule.c(1589): warning C4033: 'PyInit_timezone' must return a value [C:\py\cpython3.8\PCbuild\pythoncore.vcxproj]
..\Modules\timemodule.c(1593): warning C4033: 'PyInit_timezone' must return a value [C:\py\cpython3.8\PCbuild\pythoncore.vcxproj]
c:\py\cpython3.8\modules\timemodule.c(1647): warning C4715: 'PyInit_timezone': not all control paths return a value [C:\py\cpython3.8\PCbuild\pythoncore.vcxproj]
msg330928 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 10:38
Crap. My commit 503ce5c482cb267b0770bc46c315d5cf822bdca9 was supposed to fix on of the latest compiler warning in master, but I introduced a new warning :-( What a shame on me :-( I was too quick... PR 10861 should fix the new warning.
msg330934 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 11:02
New changeset ab6614969301b238fcc27f43923a0189a57a2a3c by Victor Stinner in branch 'master':
bpo-35373: Fix PyInit_timezone() if HAVE_DECL_TZNAME is defined (GH-10861)
https://github.com/python/cpython/commit/ab6614969301b238fcc27f43923a0189a57a2a3c
msg330935 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 11:13
Hum. By the way, PyInit_time() calls PyModule_AddObject() without checking for errors :-/

PyMODINIT_FUNC
PyInit_time(void)
{
    PyObject *m;
    m = PyModule_Create(&timemodule);
    if (m == NULL)
        return NULL;
    ...
    PyModule_AddObject(m, "struct_time", (PyObject*) &StructTimeType);
    ...
    return m;
}

It should have at least one final generic:

    if (PyErr_Occurred()) {
        return -1;
    }
msg330942 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 12:45
New changeset 3bb150d8148e3cc08418077a58f43e064b9fde61 by Victor Stinner in branch 'master':
bpo-35373: Fix PyInit_time() error handling (GH-10865)
https://github.com/python/cpython/commit/3bb150d8148e3cc08418077a58f43e064b9fde61
msg330998 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 23:09
New changeset 5eb78c75128187a36d8e983027632fa51cc2ff4d by Victor Stinner in branch '3.7':
[3.7] bpo-35373: Fix PyInit_timezone() error handling (GH-10864)
https://github.com/python/cpython/commit/5eb78c75128187a36d8e983027632fa51cc2ff4d
msg331000 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-12-03 23:12
In Python 2.7, inittimezone() is simpler and so less likely to fail. I propose to leave Python 2.7 unchanged.
msg331001 - (view) Author: miss-islington (miss-islington) Date: 2018-12-03 23:22
New changeset f455353bc0d195e092f09fec92ed16e9be02b7b1 by Miss Islington (bot) in branch '3.6':
[3.7] bpo-35373: Fix PyInit_timezone() error handling (GH-10864)
https://github.com/python/cpython/commit/f455353bc0d195e092f09fec92ed16e9be02b7b1
History
Date User Action Args
2018-12-03 23:27:06vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-03 23:22:37miss-islingtonsetnosy: + miss-islington
messages: + msg331001
2018-12-03 23:12:36vstinnersetmessages: + msg331000
versions: + Python 3.6, Python 3.7, Python 3.8
2018-12-03 23:09:51miss-islingtonsetpull_requests: + pull_request10122
2018-12-03 23:09:06vstinnersetmessages: + msg330998
2018-12-03 12:45:41vstinnersetmessages: + msg330942
2018-12-03 11:22:44vstinnersetpull_requests: + pull_request10101
2018-12-03 11:13:59vstinnersetmessages: + msg330935
2018-12-03 11:10:09vstinnersetpull_requests: + pull_request10100
2018-12-03 11:02:47vstinnersetmessages: + msg330934
2018-12-03 10:38:03vstinnersetmessages: + msg330928
2018-12-03 10:34:35vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request10096
2018-12-01 18:03:04serhiy.storchakacreate