This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make PYTHONWARNINGS variable work in libpython
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Arfrever, nanjekyejoannah, petere, vstinner
Priority: normal Keywords: patch

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:29adminsetgithub: 58894
2019-09-06 13:30:02vstinnersetstatus: open -> closed
versions: + Python 3.8, - Python 3.5
messages: + msg351248

resolution: fixed
stage: patch review -> resolved
2019-09-06 13:29:51vstinnersetnosy: + vstinner
messages: + msg351247
2019-09-05 18:55:34nanjekyejoannahsetnosy: + nanjekyejoannah
messages: + msg351219
2019-04-26 19:48:46BreamoreBoysetnosy: - BreamoreBoy
2014-07-16 22:19:56BreamoreBoysetnosy: + BreamoreBoy

messages: + msg223290
versions: + Python 3.5, - Python 3.3
2013-02-01 22:31:09brett.cannonsetnosy: - brett.cannon
2012-04-28 14:40:25Arfreversetnosy: + Arfrever
2012-04-28 12:27:08pitrousetnosy: + brett.cannon

stage: patch review
2012-04-28 09:56:05peterecreate