EDIT: Simplified version (skips fuzzing the console for other issues):
pzrq@icebox:~$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for b in [89,90]: print chr(b)+chr(27)
...
Y
>> 1;2c
EDIT2: Reproduced in Ruby:
Last login: Mon Jun 29 00:43:22 on ttys000
pzrq@icebox:~$ irb
2.1.1 :001 > for b in [89,90]
2.1.1 :002?> putc b
2.1.1 :003?> putc 27
2.1.1 :004?> end
Y=> [89, 90]
2.1.1 :005 > 1;2c
Original:
Reproducible (most of the time) enigma I've never seen before:
# Setup
$ mkvirtualenv pycrypto_test
$ pip install pycrypto
$ python
# Script 1
>>> from Crypto import Random
>>> for _ in range(10**3): print(Random.get_random_bytes(130))
# On the next input line, get 1;2c printed 0-10 times
# Just OSX Python 2.7.6, does not affect Homebrew Python 3.4.2
# Happens with or without ipython
>>> 1;2c1;2c1;2c
Have also seen it change the ipython shell prompt twice from normal square brackets (but can't reproduce reliably) to:
In é1ê:
I'd guess the first script is printing ASCII control characters under Python2, but in Python3 it's just printing byte strings.
# Script 2: Reproduced under (OSX) `brew install python3` v3.4.2 with
>>> for _ in range(10**3):
... for b in Random.get_random_bytes(130):
... print(chr(b))
# Lots of output
>>> 1;2c1;2c
What ASCII or other control characters might cause this? Or is there another explanation?