EOF while scanning triple-quoted string literal

Ian Kelly ian.g.kelly at gmail.com
Tue Oct 12 00:23:52 CEST 2010


On Mon, Oct 11, 2010 at 3:59 PM, Rhodri James
<rhodri at wildebst.demon.co.uk>wrote:

> On Mon, 11 Oct 2010 10:37:09 +0100, bussiere bussiere <bussiere at gmail.com>
> wrote:
>
>
>  i've looked on the web and here but i didn't find an answer : here is my
>> code
>>
>> zlib.decompress("""
>> xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà
>> Z@ÑÁÔQÇlxÇÆïPP
>> ~ýVãì゙M6ÛÐ|ê֭ᄁᄂヤ=)}éÓUe﬿ö3ᄎᄌú"}ʿïÿ÷1þ8ñ́U÷ᄏñíLÒVi:`ᄈᄎL!Ê҆p6-%Fë^ヘ÷à,Q.K!ユô`ÄA!ÑêweÌ
>> ÊÚAロYøøÂjôóᅠÂcñ䊧fᆴùテúN
>>
>> :nüzAÝ7%ᄌcdUタᄌ3ôPۂタlンyHᆲᄑ$/yzᄒíàヌ'ÕÓ&`|S!<'ᄂ÷Zļᄐ2ホモ;ニ(ÅÛfb!úü$ナテᄒ,9ßhàPᄎᄄێフÑbØὛホQᄍ-Ü}(n;ᄄホLヤ\^ï9ᆭᄍラDdВéÞ|åPOGᄂÐÙ%â&AÔë)ÎTÐC
>> ᄐïc枢í%Èï!フᄋëiq*ᄌVKÐNᄡ[ᄁfOq{OᆭÆÊ,0GᄂリmtツᄈOᄌΥ$#îヘqbYᄆメUニᄉÞáP`
>> ヨ×ᆵÃPwaレǩâ×)ハFcêÚ=!Åöᄊ
>> )AFñᄈ/cMᄃ!NóNΈór?pàÜòXw
>>
>> Bvæ0ïçIÉoマ>5pᆭ-ØWÚNᄆùFᄆØPçÃþdᅠ;ル1[Oᄈホ~6ツᄈᆬŕìᄄޠ=øð@ネV﾿ᄅ)÷%ユÜib{HᄆKŅVlDCテîfÑWì÷ìáár.ワîv﾿<dᄎn~ú*ÁÕ7ýá}EsYᆵWᄂÈ:R×ãQңメ?Ø1vヘäツ~èR1ᄉÜ*ᄡónAᆬjmNoツユᄈÌښᆬf[8ᆭÛ>゙OWラ|ÌbDᄁÖ녡M=Ð÷èâミム'ÂÝÐ
>> ;ë mᄎQÂäԤۢ:モᄆdᄎᄑLȂ1ᄈ_÷YZᆲNòÛ
>> â\ロxÐlݵᆵムᆱøm5Ëá=ïoÍlMᆪ[×#Ypᅠトx[ÉÊyæツoモナz)ᆭᄀÝÏìò
>>
>> """)
>>
>> so it was a string that i got by zlib.compress an other string. How can i
>> decompress this string ?
>>
>
> It helps to say what your problem is more explicitly than just hinting at
> it in the title.  Assuming that you are running on Windows and the Python
> traceback really does single this line out, my guess is that one of those
> random binary characters is a Ctrl-Z.  Windows regards that as the end of a
> text file.  How you get out of that one, I'm not sure, but frankly putting
> arbitrary binary into a literal string is rather asking for something like
> this to come and bite you.
>

Option 1: Replace the binary bytes with the proper escape codes
(incidentally, I see some backslashes already in there that most likely also
need to be escaped).

Option 2: Move that ugly mess out of the source and into an auxiliary data
file.

Option 3: Encode it in base64 and add a decoding step before the
decompression step.

Cheers,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101011/2d655a10/attachment.html>


More information about the Python-list mailing list