Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #24404
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!204.52.135.9.MISMATCH!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'exception': 0.05; 'finally:': 0.07; 'none:': 0.07; '(self,': 0.09; 'except:': 0.09; 'method,': 0.09; 'shows.': 0.09; 'try:': 0.09; 'python': 0.10; 'cc:addr:python-list': 0.10; 'def': 0.11; 'called.': 0.16; 'chunks': 0.16; 'code?': 0.16; 'errors,': 0.16; 'expecting': 0.16; 'guess.': 0.16; 'guessing': 0.16; 'line)': 0.16; 'python3': 0.16; 'str)': 0.16; 'subject:exception': 0.16; 'wrote:': 0.17; 'value.': 0.18; 'sorry,': 0.22; 'subject:problem': 0.22; 'trying': 0.22; 'header:In-Reply-To:1': 0.23; "i'd": 0.24; 'variable': 0.24; 'defined': 0.24; 'print': 0.25; 'header:User-Agent:1': 0.26; 'cc:2**0': 0.27; 'forgot': 0.27; 'error': 0.28; 'cc:no real name:2**0': 0.28; 'cc:addr:python.org': 0.29; 'assert': 0.29; 'exceptions': 0.29; 'produces': 0.29; 'code:': 0.29; 'skip:( 20': 0.30; 'probably': 0.30; 'class': 0.30; "i'm": 0.30; 'code': 0.31; 'except': 0.35; 'whatever': 0.37; 'subject:: ': 0.37; 'pm,': 0.38; 'end': 0.38; 'enough': 0.39; 'first': 0.62; 'remove': 0.63; 'line,': 0.66; 'finally': 0.67; 'header:Reply-To:1': 0.67; 'reply- to:no real name:2**0': 0.71; 'receive': 0.71; 'received:74.208': 0.72; '3...': 0.84; 'bane': 0.84; 'bare': 0.84; 'received:74.208.4.194': 0.84; 'fragment': 0.91 |
| Date | Sun, 24 Jun 2012 18:45:45 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
| MIME-Version | 1.0 |
| To | Charles Hixson <charleshixsn@earthlink.net> |
| Subject | Re: exception problem |
| References | <4FE79433.8020704@earthlink.net> <4FE794F1.6000202@earthlink.net> |
| In-Reply-To | <4FE794F1.6000202@earthlink.net> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:IZ2UeHPyCHJx9sKOY5PpYlD4veBdAsdLImvSPN+tgYJ nwXW2DU5t4LA8mYn/N1HsfX6VatBr4oDbdEkYxYmUZJ6CjnKK0 pgmaibbAsynbKJAc7n3R29Ip1B8muJRKNrZxdS8y0ARFOsF1v+ vr+7n5jGinZw3JjST6YfzPeBc5NhmX2J3Ovti5WfDkdPKrrbUU H0siCmwnjwa7NIN5AtbklmA5N+ssrK5hADCr4ule+mNNt0MAv8 dwlGwYh1537z7pxJ0y2GaMreD7aPa4jtp/NaH63jByOQbgu9gw Nm85AYv8HYIMw3Gb5Z6ICBosa0w0jN8G24TBDhGuPA2Saf6Ug= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| 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.1464.1340577976.4697.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1340577976 news.xs4all.nl 6950 [2001:888:2000:d::a6]:40979 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:24404 |
Show key headers only | View raw
On 06/24/2012 06:30 PM, Charles Hixson wrote:
> Sorry, I left out:
> er$ python3 --version
> Python 3.2.3rc1
>
> On 06/24/2012 03:26 PM, Charles Hixson wrote:
>> The code:
>> print ("pre-chunkLine")
>> chunks = []
>> try:
>> chunks = self.chunkLine (l)
>> except:
>> print ("caught exception")
>> print (sys.exc_info()[:2])
>> finally:
>> print ("at finally")
>> print ("chunks =")
>> print (repr(chunks), ".", end = ":")
>> produces this result:
>> . . ., by
>> pre-chunkLine
>> caught exception
>> at finally
>> path 3...
>>
>> Any suggestions as to what's wrong with the code?
>> FWIW, chunkLine begins:
>> def chunkLine (self, line):
>> print ("chunkLine: ")
>> print ("line = ", line)
>> if line == None:
>> return []
>> assert (isinstance (line, str) )
>>
>
>
On your except line, you forgot both the type of exception you're
expecting and the variable to receive its value. So you're masking all
errors, including a name error finding chunkline().
You don't include enough code to make the fragment executable, so I'd
have to just guess. I'm guessing that chunkline() is not defined in the
same class as that first method, whatever it was called.
If this were my problem, probably first thing I'd try is to remove the
try and catch, and see what it shows. Bare exceptions are the bane of
programming; Using it is like trying to learn to drive while blindfolded.
--
DaveA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: exception problem Dave Angel <d@davea.name> - 2012-06-24 18:45 -0400 Re: exception problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-06-25 07:40 +0000
csiph-web