You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to change Py_FrozenMain() using the new PyConfig C API, but I would prefer to first write tests of its current behavior. Currently, Py_FrozenMain() has no test.
(...)
rm -f libpython3.11.a
ar rcs libpython3.11.a Modules/getbuildinfo.o (...) Python/frozen.o
lto1: error: libpython3.11.a: file too short
(null):0: confused by earlier errors, bailing out
lto-wrapper: gcc returned 1 exit status
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
The tests are now skipped on Windows. It might be better to use a feature check: hasattr(ctypes.pythonapi, 'Py_FrozenMain')
IMO, Py_FrozenMain is quite specific: it's OK if it's exported, but also OK if it's missing. (Unless you're compiling a special build with frozen modules, which won't work at all without Py_FrozenMain.)
The tests are now skipped on Windows. It might be better to use a feature check: hasattr(ctypes.pythonapi, 'Py_FrozenMain')
On Unix, _testembed gets the symbol since it's used. Currently, hasattr(ctypes.pythonapi, 'Py_FrozenMain') returns false if Python is built without --enable-shared, even if _testembed is able to get Py_FrozenMain().
New changeset 68b9c20 by Miss Islington (bot) in branch '3.10': bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI (GH-26241) (GH-26353) 68b9c20
bpo-44131: Py_FrozenMain() uses PyConfig_SetBytesArgv() (GH-26201)
Moreover, Py_FrozenMain() relies on Py_InitializeFromConfig() to
handle the PYTHONUNBUFFERED environment variable and configure C
stdio streams like stdout (make the stream unbuffered).
Activity
vstinner commentedon May 14, 2021
I would like to change Py_FrozenMain() using the new PyConfig C API, but I would prefer to first write tests of its current behavior. Currently, Py_FrozenMain() has no test.
Py_FrozenMain() is used by Tools/freeze/freeze.py. Old freeze.py issues:
I never used freeze.py, but since we get bug reports, it seems like it's used by users :-)
Note: freeze.py has no test neither.
Py_FrozenMain() has been modified recently in bpo-44113:
commit 7565586
Author: Dong-hee Na <donghee.na@python.org>
Date: Thu May 13 10:19:46 2021 +0900
See also: [capi-sig] Py_FrozenMain and the stable ABI
https://mail.python.org/archives/list/capi-sig@python.org/thread/5QLI3NUP3OSGLCCIBAQOTX4GEJQBWJ6F/
See also: [Python-Dev] What's the story on Py_FrozenMain?
https://mail.python.org/pipermail/python-dev/2013-November/130280.html
vstinner commentedon May 17, 2021
commit eaede0d
Author: Victor Stinner <vstinner@python.org>
Date: Mon May 17 23:48:35 2021 +0200
vstinner commentedon May 17, 2021
Compilation failed on s390x RHEL7 LTO + PGO 3.x buildbot:
https://buildbot.python.org/all/#/builders/244/builds/208
(...)
rm -f libpython3.11.a
ar rcs libpython3.11.a Modules/getbuildinfo.o (...) Python/frozen.o
lto1: error: libpython3.11.a: file too short
(null):0: confused by earlier errors, bailing out
lto-wrapper: gcc returned 1 exit status
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [python] Error 1
make[3]: *** Waiting for unfinished jobs....
gcc -pthread -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -fprofile-generate -Xlinker -export-dynamic -o python Programs/python.o libpython3.11.a -lcrypt -lpthread -ldl -lutil -lm -lm
# Regenerate Programs/test_frozenmain.h
# from Programs/test_frozenmain.py
# using Programs/freeze_test_frozenmain.py
./python Programs/freeze_test_frozenmain.py Programs/test_frozenmain.h
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Programs/test_frozenmain.h written
make[4]: Leaving directory
/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build' make[3]: Leaving directory/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build'make[2]: *** [build_all_generate_profile] Error 2
make[2]: Leaving directory
/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build' make[1]: *** [profile-gen-stamp] Error 2 make[1]: Leaving directory/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build'make: *** [profile-run-stamp] Error 2
program finished with exit code 2
elapsedTime=62.919052
encukou commentedon May 18, 2021
The tests are now skipped on Windows. It might be better to use a feature check: hasattr(ctypes.pythonapi, 'Py_FrozenMain')
IMO, Py_FrozenMain is quite specific: it's OK if it's exported, but also OK if it's missing. (Unless you're compiling a special build with frozen modules, which won't work at all without Py_FrozenMain.)
vstinner commentedon May 18, 2021
On Unix, _testembed gets the symbol since it's used. Currently, hasattr(ctypes.pythonapi, 'Py_FrozenMain') returns false if Python is built without --enable-shared, even if _testembed is able to get Py_FrozenMain().
I hope that bpo-44133 will be solved soon.
pablogsal commentedon May 25, 2021
New changeset 68b9c20 by Miss Islington (bot) in branch '3.10':
bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI (GH-26241) (GH-26353)
68b9c20
vstinner commentedon May 25, 2021
commit eaede0d
Author: Victor Stinner <vstinner@python.org>
Date: Mon May 17 23:48:35 2021 +0200
commit 58a9939
Author: Victor Stinner <vstinner@python.org>
Date: Thu May 20 12:08:05 2021 +0200
vstinner commentedon May 26, 2021
I marked bpo-36940 as a duplicate of this issue.