Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'elif': 0.04; 'subject:bug': 0.04; 'message-id:@earthlink.net': 0.09; 'subject:string': 0.09; '(len': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'str):': 0.16; 'subject:handling': 0.16; 'tmp': 0.16; "doesn't": 0.22; 'incorrect': 0.23; 'sep': 0.23; 'from:addr:earthlink.net': 0.29; 'print': 0.29; 'error': 0.29; 'header:User-Agent:1': 0.33; 'rather': 0.33; 'to:addr:python-list': 0.34; 'subject:work': 0.34; 'subject:with': 0.36; 'skip:" 10': 0.37; 'but': 0.37; 'subject: (': 0.40; 'to:addr:python.org': 0.40; 'range': 0.61; 'cause': 0.67; 'charles': 0.67; 'received:207.69': 0.84; 'received:207.69.195': 0.84; 'subject:Possible': 0.84 Date: Mon, 26 Dec 2011 14:23:03 -0800 From: Charles Hixson User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20111110 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Possible bug in string handling (with kludgy work-around) Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324938867 news.xs4all.nl 6969 [2001:888:2000:d::a6]:59429 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17986 This doesn't cause a crash, but rather incorrect results. self.wordList = ["The", "quick", "brown", "fox", "carefully", "jumps", "over", "the", "lazy", "dog", "as", "it", "stealthily", "wends", "its", "way", "homewards", '\b.'] for i in range (len (self.wordList) ): if not isinstance(self.wordList[i], str): self.wordList = "" elif self.wordList[i] != "" and self.wordList[i][0] == "\b": print ("0: wordList[", i, "] = \"", self.wordList[i], "\"", sep = "") print ("0a: wordList[", i, "][1] = \"", self.wordList[i][1], "\"", sep = "") tmp = self.wordList[i][1] ## !! Kludge -- remove tmp to see the error self.wordList[i] = tmp + self.wordList[i][1:-1] ## !! Kludge -- remove tmp + to see the error print ("1: wordList[", i, "] = \"", self.wordList[i], "\"", sep = "") print ("len(wordList[", i, "]) = ", len(self.wordList[i]) ) -- Charles Hixson