syntax warnings don't go through warnings.warn?

I'm just a little surprised by this - Is there a reason why syntax warnings are special and untrappable via 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. Matthew

Matthew Wilkes wrote:
Dino is developing Python - he's one of the core developers of IronPython and I suspect he is asking whether this is intentional, and IronPython should implement the same behaviour, or whether it is a bug. Michael
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog

On 1 Jun 2009, at 18:42, Michael Foord wrote:
Dino is developing Python - he's one of the core developers of IronPython
Ah, sorry, I'm bad with names, don't always pick up on who is who!
The docs do seem to be clear though, warnings.warn creates a warning, but there are multiple other ways to do it, it's a convenience method. Matt

Ahh, ok, now I think I see... there is clearly some other mechanism that this warning is going through that we're not handling correctly. I'll try and track it down. Thanks! -----Original Message----- From: Matthew Wilkes [mailto:matthew@matthewwilkes.co.uk] Sent: Monday, June 01, 2009 10:49 AM To: Michael Foord Cc: Dino Viehland; Python-Dev Subject: Re: [Python-Dev] syntax warnings don't go through warnings.warn? On 1 Jun 2009, at 18:42, Michael Foord wrote:
Dino is developing Python - he's one of the core developers of IronPython
Ah, sorry, I'm bad with names, don't always pick up on who is who!
The docs do seem to be clear though, warnings.warn creates a warning, but there are multiple other ways to do it, it's a convenience method. Matt

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. -----Original Message----- From: Matthew Wilkes [mailto:matthew@matthewwilkes.co.uk] Sent: Monday, June 01, 2009 10:29 AM To: Dino Viehland Cc: Python-Dev 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. Matthew

On 2009-06-01 11:50, Dino Viehland wrote:
symtable.c uses PyErr_WarnExplicit() to provide file and line number information. You need to stub warnings.warn_explicit().
-- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco

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. Matthew

Matthew Wilkes wrote:
Dino is developing Python - he's one of the core developers of IronPython and I suspect he is asking whether this is intentional, and IronPython should implement the same behaviour, or whether it is a bug. Michael
-- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog

On 1 Jun 2009, at 18:42, Michael Foord wrote:
Dino is developing Python - he's one of the core developers of IronPython
Ah, sorry, I'm bad with names, don't always pick up on who is who!
The docs do seem to be clear though, warnings.warn creates a warning, but there are multiple other ways to do it, it's a convenience method. Matt

Ahh, ok, now I think I see... there is clearly some other mechanism that this warning is going through that we're not handling correctly. I'll try and track it down. Thanks! -----Original Message----- From: Matthew Wilkes [mailto:matthew@matthewwilkes.co.uk] Sent: Monday, June 01, 2009 10:49 AM To: Michael Foord Cc: Dino Viehland; Python-Dev Subject: Re: [Python-Dev] syntax warnings don't go through warnings.warn? On 1 Jun 2009, at 18:42, Michael Foord wrote:
Dino is developing Python - he's one of the core developers of IronPython
Ah, sorry, I'm bad with names, don't always pick up on who is who!
The docs do seem to be clear though, warnings.warn creates a warning, but there are multiple other ways to do it, it's a convenience method. Matt

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. -----Original Message----- From: Matthew Wilkes [mailto:matthew@matthewwilkes.co.uk] Sent: Monday, June 01, 2009 10:29 AM To: Dino Viehland Cc: Python-Dev 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. Matthew

On 2009-06-01 11:50, Dino Viehland wrote:
symtable.c uses PyErr_WarnExplicit() to provide file and line number information. You need to stub warnings.warn_explicit().
-- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (4)
-
Dino Viehland
-
Matthew Wilkes
-
Michael Foord
-
Robert Kern