[Python-Dev] syntax warnings don't go through warnings.warn?
dinov at microsoft.com
Mon Jun 1 19:44:45 CEST 2009
I work on IronPython so I am asking a question about development of
Python. In particular my goal is to make sure that IronPython is behaving
the same as CPython. If the normal discussion list is more appropriate
for these questions I'd be happy to take it there.
But before I do that please consider nt.tempnam - a built-in function. This
goes through the normal warning mechanism but the parser doesn't. I
would assume that this would go through PyErr_WarnEx (sorry, I can't actually
look at the CPython code) given that tempnam is implemented in C. Why
wouldn't the parser also go through PyErr_WarnEx?
And warnings.catch_warnings doesn't work w/ parse warnings either so I'm
not sure what the point of bringing that up is.
From: Matthew Wilkes [mailto:matthew at matthewwilkes.co.uk]
Sent: Monday, June 01, 2009 10:29 AM
To: Dino Viehland
Subject: Re: [Python-Dev] syntax warnings don't go through warnings.warn?
On 1 Jun 2009, at 17:50, Dino Viehland wrote:
> I'm just a little surprised by this - Is there a reason why syntax
> warnings are special and untrappable via warnings.warn?
Why should this work? From the docs... "Python programmers issue
warnings by calling the warn() function defined in this module. (C
programmers use PyErr_WarnEx; see Exception Handling for details)."
Check out the warnings.catch_warnings context manager, but if you have
any further questions please direct them to the normal Python mailing
list, this is for development _of_ Python only.
More information about the Python-Dev