[Python-Dev] switching on -3 from within a program? (original) (raw)
Benjamin Peterson musiccomposition at gmail.com
Tue Sep 16 22:45:45 CEST 2008
- Previous message: [Python-Dev] switching on -3 from within a program?
- Next message: [Python-Dev] switching on -3 from within a program?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 16, 2008 at 10:32 AM, Anthon van der Neut <avanderneut at avid.com> wrote:
With a minor modification to the Makefile I was able to get modwsgi v2.3 to work with python2.6rc1. I promptly got a warning in my apache log files on the depcrecated use of 'sha' in the paste's cookie module, good! And easily fixed.
After that I was looking for a way to switch on the -3 warnings from within my code to have extra warnings show up in my apache log file. After reading some documentation I tried from the python2.6 prompt: import sys sys.py3kwarning = True x = { 'abc': 1 }; x.haskey('abc') which does not give a warning (starting python2.6 with the -3 option of course does). Is there anyway to switch this on from within a program with a Python statement? If not, would I need to make a small C-extension module (to be imported as the first module) that sets PyPy3WarningFlag or something else at the C level, or would that better be done by modwsgi's C code.
You could also utilize a nifty ctypes trick:
import ctypes
def engage_py3k_warning(): flag = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Py3kWarningFlag") flag.value = 1
-- Cheers, Benjamin Peterson "There's no place like 127.0.0.1."
- Previous message: [Python-Dev] switching on -3 from within a program?
- Next message: [Python-Dev] switching on -3 from within a program?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]