Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26391
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
|---|---|
| From | rahul <rahul03535@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() |
| Date | Thu, 2 Aug 2012 02:50:21 -0700 (PDT) |
| Organization | http://groups.google.com |
| Lines | 81 |
| Message-ID | <d6e4ea1d-53cd-4a50-92ed-79a0b535dbd1@googlegroups.com> (permalink) |
| References | <fa944ed7-8101-4b2f-a49a-363eb8d05d1d@googlegroups.com> <mailman.2856.1343898392.4697.python-list@python.org> <acb579e1-b716-46d9-b732-9dca094cedac@googlegroups.com> <mailman.2860.1343900238.4697.python-list@python.org> |
| NNTP-Posting-Host | 122.248.161.59 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Trace | posting.google.com 1343901021 15556 127.0.0.1 (2 Aug 2012 09:50:21 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Thu, 2 Aug 2012 09:50:21 +0000 (UTC) |
| Cc | python-list@python.org |
| In-Reply-To | <mailman.2860.1343900238.4697.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=122.248.161.59; posting-account=xyzyTgoAAAB2OaRT58zhH9j7aeiDRJa3 |
| User-Agent | G2/1.0 |
| Xref | csiph.com comp.lang.python:26391 |
Show key headers only | View raw
When I use same code base for Python 3.x, then behavior is different. In this when I return false then also it throws exception but only when any other statement get executed after this
like below code:
...
...
b = None
try:
a = testModule.check(None)
except:
b = sys.exc_info()
then code execution doesn't come to except block.
But when I add one statement after calling check function then code execution goes into except block.
...
...
b = None
try:
a = testModule.check(None)
print( a )
except:
b = sys.exc_info()
On Thursday, 2 August 2012 15:07:08 UTC+5:30, Tim Golden wrote:
> On 02/08/2012 10:21, rahul wrote:
>
> >
>
> > Hi TJG,
>
> >
>
> > The above link also doesn't strictly said that return value should be
>
> > NULL only, it only said that usually NULL pointer used. No where I
>
> > saw that it is nessasory t
>
> >
>
> > At http://docs.python.org/c-api/exceptions.html. it is written that
>
> > "Most functions also return an error indicator, usually NULL if they
>
> > are supposed to return a pointer, or -1 if they return an integer
>
> > (exception: the PyArg_*() functions return 1 for success and 0 for
>
> > failure)." this also told that usually NULL is used but we can change
>
> > the return error indicator to any value. As like PyArg_*() used 0 for
>
> > error value.
>
>
>
> The docs you quote are very slightly confusing because they're combining
>
> the standard practice (return NULL), the uncommon alternative (return
>
> -1) and a few special cases present in the core functions.
>
>
>
> In short, any function you expose in an extension module will be
>
> returning a PyObject* and should return NULL if it is setting or
>
> cascading an exception.
>
>
>
> I'm not convinced that the docs need altering here: this is the first
>
> time I've come across anyone who was confused. But if you think some
>
> different wording might help, feel free to propose something.
>
>
>
> TJG
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C extension module doesn't throw exception after setting error indicator through PyErr_SetString() rahul <rahul03535@gmail.com> - 2012-08-02 01:57 -0700
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() Tim Golden <mail@timgolden.me.uk> - 2012-08-02 10:06 +0100
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() rahul <rahul03535@gmail.com> - 2012-08-02 02:21 -0700
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() rahul <rahul03535@gmail.com> - 2012-08-02 02:21 -0700
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() Tim Golden <mail@timgolden.me.uk> - 2012-08-02 10:37 +0100
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() rahul <rahul03535@gmail.com> - 2012-08-02 02:50 -0700
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() Tim Golden <mail@timgolden.me.uk> - 2012-08-02 11:45 +0100
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() Stefan Behnel <stefan_ml@behnel.de> - 2012-08-02 12:54 +0200
Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() rahul <rahul03535@gmail.com> - 2012-08-02 02:50 -0700
csiph-web