Issue 14689: make PYTHONWARNINGS variable work in libpython (original) (raw)

Issue14689

Created on 2012-04-28 09:56 by petere, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py-pythonwarnings-envvar.patch petere,2012-04-28 09:56 patch review
Messages (5)
msg159514 - (view) Author: Peter Eisentraut (petere) * Date: 2012-04-28 09:56
The environment variable PYTHONWARNINGS only works with the python interpreter binary, but not with programs embedding libpython. This could be changed by moving the code from Modules/main.c to Python/pythonrun.c. See attached patch (compiles cleanly, tests pass, not tested on Windows). (I have checked all the other environment variables listed on the python man page for whether those that could be usable in the library are actually processed in the library, and all but PYTHONWARNINGS appear to behave reasonably.)
msg223290 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-16 22:19
Can we have a patch review please, I'm not touching C code at that level within Python. Are people happy with the concept of moving code from main.c to pythonrun.c ?
msg351219 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-09-05 18:55
@petere do you want to open a PR with your patch here: https://github.com/python/cpython/pulls
msg351247 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-06 13:29
I refactored deeply Modules/main.c and moved the code to Python/initconfig.c and Python/preconfig.c. There is now a public C API to access to all configuration parameters documented at: https://docs.python.org/dev/c-api/init_config.html The design document is the PEP 587 which has been implemented in Python 3.8. If you use the "Python Configuration", you now get the same behaviour than system Python program ("python"). Or you can use "Isolated Configuration" but opt-in for environment variables. Or you can modify PyConfig.warnoptions: https://docs.python.org/dev/c-api/init_config.html#c.PyConfig.warnoptions So you know have plently of choices to use PYTHONWARNINGS env var when you embed Python. Good news: Python 3.8 beta4 is now available for testing!
msg351248 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-06 13:30
I close the issue since it's now fixed ;-)
History
Date User Action Args
2022-04-11 14:57:29 admin set github: 58894
2019-09-06 13:30:02 vstinner set status: open -> closedversions: + Python 3.8, - Python 3.5messages: + resolution: fixedstage: patch review -> resolved
2019-09-06 13:29:51 vstinner set nosy: + vstinnermessages: +
2019-09-05 18:55:34 nanjekyejoannah set nosy: + nanjekyejoannahmessages: +
2019-04-26 19:48:46 BreamoreBoy set nosy: - BreamoreBoy
2014-07-16 22:19:56 BreamoreBoy set nosy: + BreamoreBoymessages: + versions: + Python 3.5, - Python 3.3
2013-02-01 22:31:09 brett.cannon set nosy: - brett.cannon
2012-04-28 14:40:25 Arfrever set nosy: + Arfrever
2012-04-28 12:27:08 pitrou set nosy: + brett.cannonstage: patch review
2012-04-28 09:56:05 petere create