An (apparent) longstring-literals bug

Kenneth Manheimer (klm@nist.gov)
Tue, 14 Jun 1994 16:16:07 GMT

I'm running python 1.0.2 on a Sun (sunm) running SunOS 4.1.3.

I'm finally getting around to experimenting with python, and i'm
happened to hit unexpected exceptions when trying the new '"""'
longstring literals. The problem seems to be keyed on having a line
within the literal end with one of the quote chars that was tripled to
delimit the literal.

Eg (the arrow at the left margin points to the interpreter's
evaluation response):

12:08:13 coil.klm 43: python
Python 1.0.2 (May 11 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> """
... This works fine.
... """
> '\012This works fine.\012'
>>> """
... "This doesn't."
... """
File "<stdin>", line 3
"""
"This doesn't."
"""
^
> SyntaxError: invalid token
>>> '''
... Nor this:'
... '''
File "<stdin>", line 3
'''
Nor this:'
'''
^
> SyntaxError: invalid token
>>> """ and this is even worse.
... ""
... """
> SystemError: bad argument to internal function
>>>

Note the last case, with the SystemError! (It seems to depend on
having two of the quotes at the end of the line.)

I don't know whether this happens for scripts from files.

I wonder whether this has something to with confusion in the parser
with the new string-literal-juxtaposition feature? Or is it just me -
does this occur for other installations?

Ken
ken.manheimer@nist.gov, 301 975-3539