Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 Newsgroups: comp.lang.python Subject: Re: Capturing the bad codes that raise UnicodeError exceptions during decoding Date: Thu, 04 Aug 2016 15:45:24 -0400 Lines: 12 Message-ID: References: <1470336426.893449.686225577.24458777@webmail.messagingengine.com> <1470338568.900965.686261921.548DDA14@webmail.messagingengine.com> <1470339924.3065250.686286553.51C83AD9@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de BbvlN3H86IxTsy7L9uF5xgvwVR0k/1yJieZ8o1hDtIPg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'handler': 0.04; 'finished.': 0.07; 'received:internal': 0.09; 'suggestions.': 0.09; 'subject: \n ': 0.15; 'thu,': 0.15; '*before*': 0.16; 'chris,': 0.16; 'decode': 0.16; 'malcolm': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'replaced.': 0.16; 'wrote:': 0.16; 'aug': 0.20; 'header:In-Reply- To:1': 0.24; 'error': 0.27; 'this.': 0.28; 'subject:that': 0.29; 'code': 0.30; 'url:python': 0.33; 'raising': 0.33; 'text': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'thanks': 0.37; 'received:66': 0.38; 'subject:the': 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'url:3': 0.60; 'your': 0.60; 'skip:u 10': 0.61; 'header:Message- Id:1': 0.61; 'information': 0.63; 'capture': 0.66 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=VwlkDL9E702yb5jSlTfkWfytalE=; b=ilkWL/ Ah1YygcAg6JkM1Js+yUdfzTtW1kPa2TG6ue51BxI+CRQ5FRkzmCk4A6R4Cdc0UoM wL6wrlKbwiA4XKMB2t9cF0D3YfrcuoTUaSgn6Jcg6wQVHZjrZszdwIFVfAySlniZ TnCVSzkqlNkRg0gXWEuavFYWRGNPX1cTYCAlo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=VwlkDL9E702yb5j SlTfkWfytalE=; b=QE2qTsbyQbOMkYHFNDawwqbDP0V1alF2lUt0ySYZFPNc54Q AVwXqsjTy+ueoxmBJAxg8XM8vpq1c4qoTCcR8+mmVr1a2+SpxAZnonXTuVIosvVm RNlv7u61GBrgp2ivOsjbJ2kinnEpM7GvTUNqlBs3UrG6BH4nyTs02RaQarCU= X-Sasl-Enc: F0rNSb7CLQedOHVnPQ1EEfe3KBWfypFimqZ76ryeGNmK 1470339924 X-Mailer: MessagingEngine.com Webmail Interface - ajax-b9085e99 In-Reply-To: <1470338568.900965.686261921.548DDA14@webmail.messagingengine.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1470339924.3065250.686286553.51C83AD9@webmail.messagingengine.com> X-Mailman-Original-References: <1470336426.893449.686225577.24458777@webmail.messagingengine.com> <1470338568.900965.686261921.548DDA14@webmail.messagingengine.com> Xref: csiph.com comp.lang.python:112349 On Thu, Aug 4, 2016, at 15:22, Malcolm Greene wrote: > Hi Chris, > > Thanks for your suggestions. I would like to capture the specific bad > codes *before* they get replaced. So if a line of text has 10 bad codes > (each one raising UnicodeError), I would like to track each exception's > bad code but still return a valid decode line when finished. Look into writing your own error handler - there's enough information provided to do this. https://docs.python.org/3/library/codecs.html