Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26396
| Date | 2012-08-02 11:45 +0100 |
|---|---|
| From | Tim Golden <mail@timgolden.me.uk> |
| Subject | Re: C extension module doesn't throw exception after setting error indicator through PyErr_SetString() |
| 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> <d6e4ea1d-53cd-4a50-92ed-79a0b535dbd1@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2865.1343904351.4697.python-list@python.org> (permalink) |
On 02/08/2012 10:50, rahul wrote: > 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() Sounds like you're entering into undefined behaviour. If you set an exception and don't return NULL, you're leaving Python's internals in an inconsistent state. I don't know the internal code paths, but presumably in one version it just ignored the exception state while in the other it noticed it but in a different point in the code at which point it raised the exception. Or something. Long-and-short: return NULL from an extension module function once you've raised (or are cascading) an exception condition. Anything else is undefined unless you know *exactly* what you're doing. 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