Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26396
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <mail@timgolden.me.uk> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'ignored': 0.05; 'except:': 0.07; 'exception.': 0.07; 'executed': 0.07; 'null,': 0.07; 'raised': 0.07; 'try:': 0.07; 'undefined': 0.07; 'python': 0.09; 'block.': 0.09; 'subject:()': 0.09; 'subject:module': 0.09; 'subject:setting': 0.09; 'throws': 0.09; 'subject:error': 0.11; 'extension': 0.13; 'behaviour.': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject: \n ': 0.16; 'subject:exception': 0.16; 'subject:through': 0.16; 'tjg': 0.16; 'wrote:': 0.17; '(or': 0.18; 'module': 0.19; "python's": 0.23; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'execution': 0.27; "doesn't": 0.28; 'noticed': 0.28; 'function': 0.30; 'code': 0.31; 'point': 0.31; 'goes': 0.33; 'null': 0.33; 'received:192.168.100': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; 'version': 0.34; 'false': 0.35; 'add': 0.36; 'except': 0.36; 'but': 0.36; 'anything': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; "you've": 0.61; 'leaving': 0.62; 'different': 0.63; 'behavior': 0.64; 'from:addr:mail': 0.71; 'sounds': 0.71; 'state.': 0.71; 'different.': 0.84; 'presumably': 0.84 |
| Date | Thu, 02 Aug 2012 11:45:47 +0100 |
| From | Tim Golden <mail@timgolden.me.uk> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| 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> |
| In-Reply-To | <d6e4ea1d-53cd-4a50-92ed-79a0b535dbd1@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2865.1343904351.4697.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343904351 news.xs4all.nl 6960 [2001:888:2000:d::a6]:53608 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26396 |
Show key headers only | View raw
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