4

In the python 2.7 console, as well as iPython 4, I was able to paste this string into a variable like so:

In [2]: c = 'ÙjÌÉñõµÏ“JÖq´ž#»&•¼²nËòQZ<_'

Subsequently I could type:

In [3]: print(c) and it would return ÙjÌÉñõµÏ“JÖq´ž#»&•¼²nËòQZ<_

However, in iPython 5.0, I get the following error:

In [4]: c = 'ÙjÌÉñõµ^LÏ“JÖq´ž#»&•¼²nËòQZ<_'
  File "<ipython-input-4-9bf9f2fa5210>", line 1
    c = 'ÙjÌÉñõµ

^
SyntaxError: EOL while scanning string literal

Even %paste returns an error:

    ÙjÌÉñõµ
    ^
SyntaxError: invalid syntax

What changed in iPython from 4 to 5, and why is this occurring? Something to do with the string not having escaped quotes?

lebca
  • 185
  • 2
  • 5
  • Changing the `^L` to `\^L` makes it accept it, but that sequence is missing from `c`. It's as though the new `readline` code is interpreting the `^L` as a control character. It shouldn't. – hpaulj Jul 12 '16 at 05:55
  • What's the source of this string? How many characters? What's it supposed to represent? – hpaulj Jul 12 '16 at 12:37
  • 32 characters. It's the ciphertext from DES encryption on a given plaintext and key and iv. – lebca Jul 14 '16 at 17:38
  • If I `ctrl v` that string on a plain `python2.7` session and ask `len(c)` I get 46. And if I add `u` (unicode) to it, I get 27. – hpaulj Jul 14 '16 at 18:02

1 Answers1

1

http://blog.jupyter.org/2016/07/08/ipython-5-0-released/

Ipython5 replaced the default readline with a new prompt_toolkit.

It looks like your string has several characters that the old readline ignored, but the new one sees. The first occurs right after the µ. I don't see it in the SO windows, but I can 'feel it' when moving the cursor over the line. I can also see something when pasting the line into an editor. But I not familiar enough with raw text tools to see more.

When I paste your string into a plain Python shell I get a bell and the screen clears. So even the regular readline is having problems with this string.

I've added '|' were there are unprintable characters

c = 'ÙjÌÉñõµ|Ï“JÖq´ž#|»&•¼|²nËòQZ<_'
hpaulj
  • 221,503
  • 14
  • 230
  • 353