Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26037
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!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 | <bahamutzero8825@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.036 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; 'cpython': 0.05; 'exception.': 0.07; 'raised': 0.07; 'try:': 0.07; 'file,': 0.15; 'received:209.85.161.174': 0.16; 'wrote:': 0.17; 'char': 0.17; 'else,': 0.17; 'windows': 0.19; 'work.': 0.23; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; "doesn't": 0.28; 'file': 0.32; 'traceback': 0.33; 'handle': 0.33; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'open': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'really': 0.36; 'except': 0.36; 'message-id:@gmail.com': 0.36; 'should': 0.36; 'bad': 0.37; 'detail': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'skip:u 10': 0.60; 'matter': 0.61; 'helps': 0.63; 'skip:6 10': 0.63; 'email addr:gmail.com': 0.63; 'more': 0.63; '"it': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=TNspAFxvjf2S9yx4EvXrzfzSdMtphoLAaFwZpVKII9Y=; b=cPfBhVu3n8QQVIfMStAcuyx9F49phRKVAmkidmPFpbYxelDjTISgfVpZxaOxwjeKXB tPOqNXlR0ruBOFIB75w5hy78G06KaTrl3c9JnpfZD+Weu5nIwBEoPvM3EnbaWtOPbxCI 0zhWMPh/QX22+wIW3Jauss8UPxaODf5gvI673us0Pp9u81ICW2npinBREcSurmA9Jidf 31bbKETTZ653wSz/so14hzhv6zeQm2ML9LeCy7Za0JSPqcaY5W+yZsAyjoP2R6JUgqGi nrdxoEQFyzZXfsGVTfj9BjwD9gl+dU2AX66iEMJx7UMm6esLncsVhczJc0rfUxaKGwMP /SZQ== |
| Date | Wed, 25 Jul 2012 06:34:53 -0500 |
| From | Andrew Berg <bahamutzero8825@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | "comp.lang.python" <python-list@python.org> |
| Subject | Re: catch UnicodeDecodeError |
| References | <04f7ff8d-9881-4a04-ab2e-b5573b5f3cd1@googlegroups.com> |
| In-Reply-To | <04f7ff8d-9881-4a04-ab2e-b5573b5f3cd1@googlegroups.com> |
| X-Enigmail-Version | 1.4.3 |
| Content-Type | text/plain; charset=UTF-8 |
| 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.2569.1343216109.4697.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343216109 news.xs4all.nl 6951 [2001:888:2000:d::a6]:36122 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26037 |
Show key headers only | View raw
On 7/25/2012 6:05 AM, jaroslav.dobrek@gmail.com wrote:
> What I really want to do is use something like
>
> try:
> # open file, read line, or do something else, I don't care
> except UnicodeDecodeError:
> sys.exit("Found a bad char in file " + file + " line " + str(line_number)
>
> Yet, no matter where I put this try-except, it doesn't work.
>
> How should I use try-except with UnicodeDecodeError?
The same way you handle any other exception. The traceback will tell you
the exact line that raised the exception. It helps us help you if you
include the full traceback and give more detail than "it doesn't work".
--
CPython 3.3.0b1 | Windows NT 6.1.7601.17803
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
catch UnicodeDecodeError jaroslav.dobrek@gmail.com - 2012-07-25 04:05 -0700
Re: catch UnicodeDecodeError Andrew Berg <bahamutzero8825@gmail.com> - 2012-07-25 06:34 -0500
Re: catch UnicodeDecodeError Philipp Hagemeister <phihag@phihag.de> - 2012-07-25 13:35 +0200
Re: catch UnicodeDecodeError jaroslav.dobrek@gmail.com - 2012-07-25 05:09 -0700
Re: catch UnicodeDecodeError jaroslav.dobrek@gmail.com - 2012-07-25 05:09 -0700
Re: catch UnicodeDecodeError Dave Angel <d@davea.name> - 2012-07-25 14:50 -0400
Re: catch UnicodeDecodeError Jaroslav Dobrek <jaroslav.dobrek@gmail.com> - 2012-07-26 00:46 -0700
Re: catch UnicodeDecodeError Stefan Behnel <stefan_ml@behnel.de> - 2012-07-26 10:28 +0200
Re: catch UnicodeDecodeError Jaroslav Dobrek <jaroslav.dobrek@gmail.com> - 2012-07-26 03:51 -0700
Re: catch UnicodeDecodeError Stefan Behnel <stefan_ml@behnel.de> - 2012-07-26 13:15 +0200
Re: catch UnicodeDecodeError jaroslav.dobrek@gmail.com - 2012-07-26 04:58 -0700
Re: catch UnicodeDecodeError jaroslav.dobrek@gmail.com - 2012-07-26 04:58 -0700
Re: catch UnicodeDecodeError Philipp Hagemeister <phihag@phihag.de> - 2012-07-26 14:17 +0200
Re: catch UnicodeDecodeError Stefan Behnel <stefan_ml@behnel.de> - 2012-07-26 14:24 +0200
Re: catch UnicodeDecodeError Chris Angelico <rosuav@gmail.com> - 2012-07-26 19:46 +1000
Re: catch UnicodeDecodeError wxjmfauth@gmail.com - 2012-07-26 03:19 -0700
Re: catch UnicodeDecodeError Philipp Hagemeister <phihag@phihag.de> - 2012-07-26 14:43 +0200
csiph-web