Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17986

Possible bug in string handling (with kludgy work-around)

Date 2011-12-26 14:23 -0800
From Charles Hixson <charleshixsn@earthlink.net>
Subject Possible bug in string handling (with kludgy work-around)
Newsgroups comp.lang.python
Message-ID <mailman.4112.1324938867.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Possible bug in string handling (with kludgy work-around) Charles Hixson <charleshixsn@earthlink.net> - 2011-12-26 14:23 -0800
  Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-26 14:48 -0800
    Re: Possible bug in string handling (with kludgy work-around) Chris Angelico <rosuav@gmail.com> - 2011-12-27 10:05 +1100
  Re: Possible bug in string handling (with kludgy work-around) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-27 01:10 +0000
    Re: Possible bug in string handling (with kludgy work-around) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-12-27 09:53 -0500
      Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 10:04 -0800
        Re: Possible bug in string handling (with kludgy work-around) Lie Ryan <lie.1296@gmail.com> - 2011-12-28 08:23 +1100
        Re: Possible bug in string handling (with kludgy work-around) Terry Reedy <tjreedy@udel.edu> - 2011-12-27 16:38 -0500
          Re: Possible bug in string handling (with kludgy work-around) Rick Johnson <rantingrickjohnson@gmail.com> - 2011-12-27 16:57 -0800
            Re: Possible bug in string handling (with kludgy work-around) Lie Ryan <lie.1296@gmail.com> - 2011-12-29 04:54 +1100
        Re: Possible bug in string handling (with kludgy work-around) Terry Reedy <tjreedy@udel.edu> - 2011-12-27 16:38 -0500

csiph-web