A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-September/082450.html below:

[Python-Dev] switching on -3 from within a program?

[Python-Dev] switching on -3 from within a program? [Python-Dev] switching on -3 from within a program?Anthon van der Neut anthon at mnt.org
Wed Sep 17 12:19:03 CEST 2008
Hi Nick,

I am aware of that (but others might not, so you are right to point this
out).

I did follow both Christian's and Benjamin's suggestions. The
implementation at the mod_wsgi C level, which is before any module
loading is more permanent, but the ctypes trick doesn't require an
apache2 restart, which is somewhat more comfortable.

Anthon

Nick Coghlan wrote:
> Benjamin Peterson wrote:
>> def engage_py3k_warning():
>>      flag = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Py3kWarningFlag")
>>      flag.value = 1
> 
> Note that tricks like this won't necessarily enable all python 3
> warnings for modules that have been imported before the flag gets set.
> To avoid unnecessary performance penalties as a result of Py3k warnings,
> modules are permitted to do things like:
> 
> def func():
>   # Do whatever
> 
> if sys.py3kwarning:
>   _orig_func = func
>   def func():
>     warnings.py3kwarn("Goes away in 3.0")
>     _orig_func()
> 
> Modules that are first imported after the flag has been set will
> obviously have all of their warnings properly enabled.
> 
> Cheers,
> Nick.
> 
> 
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4