Obscure Bug in %: last character dropped from generated string

Steve Kirsch (stk@infoseek.com)
10 Jul 1994 01:23:12 GMT

We are using 1.0.1 here, so this may be fixed in 1.0.2, but I haven't seen it
reported. I'm not sure under what conditions it happens,
but here is a simple repeatable case that demonstrates the bug:

def bug():
a='xxxxxxxxxxxxxxxxx '
b='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
bug1(a,b)
b=b+'x'
bug1(a,b)

def bug1(a,b):
str='#band(%s) #band(%s%s)' % (a,a,b)
print str
bug()

What you get is:

#band(xxxxxxxxxxxxxxxxx ) #band(xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#band(xxxxxxxxxxxxxxxxx ) #band(xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
>>>

Note: in the second call to bug1, you correctly get the ) at the end.
In the first case (with the b string shorter by 1 character), you don't!!!!!!
This bug is very sensitive to string lengths. If you get the right lengths,
the bug appears.

---
Steven T. Kirsch 
InfoSeek Corporation
2620 Augustine Dr #250
Santa Clara, CA 95054
 
stk@infoseek.com  (408) 982-4463  FAX: (408) 986-1889