Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting into iPython does not work as expected #570

Closed
Maximus5 opened this issue Jul 31, 2015 · 7 comments
Closed

Pasting into iPython does not work as expected #570

Maximus5 opened this issue Jul 31, 2015 · 7 comments

Comments

@Maximus5
Copy link
Owner

Originally reported on Google Code with ID 570

Required information!
OS version: Win7 x64
ConEmu version: 120604 32bit (32-bit because I'm using 32-bit Python)
Far version: N/A

*Bug description*
Pasting long (> ~250 chars) blocks of text into iPython doesn't work as expected

*Steps to reproduction*
1. Start new iPython console or attach to running iPython console
2. Copy example text from web browser, text editor etc. (DOS/ANSI, UNIX/UTF8... makes
no difference how the text is encoded)
3. Paste into iPython window using '%cpaste' magic command

Observed behavior: Several lines of text will paste with appropriate CR and indentation.
However, at some random point, the block will either stop, or will jump ahead a random
number of lines (characters, maybe?). It is so flaky that I have actually seen it work
properly >_< (once)

Expected behavior: Pasting "properly" formatted python code (where "proper" is defined
as: line ending markers of some kind separate lines, and indentation using tabs or
spaces is as expected for python code. The ipython "magic" command '%cpaste' will strip
out extra characters from line beginnings (e.g. if pasting from an email, removes '>>')
and "do the right thing" with line ending markers.

Reported by ben.alkov on 2012-06-08 16:09:02

@Maximus5
Copy link
Owner Author

Several questions...

What version of iPython you are using?
I try to install 0.12.1 and get setup error:
*** run_installscript: internal error 0xFFFFFFFF ***

Trying to start (file however appears) get an error:
C:\Python24\Scripts>ipython.exe                             
Traceback (most recent call last):                          
  File "C:\Python24\Scripts\ipython-script.py", line 5, in ?
    from pkg_resources import load_entry_point              
ImportError: No module named pkg_resources                  

Where to get sample script for pasting? :)

Reported by ConEmu.Maximus5 on 2012-06-08 18:44:16

@Maximus5
Copy link
Owner Author

Sorry, I should have thought of that. Python 2.6.6 32-bit, iPython 0.12.1
I always install using pip. 2.6 is the oldest I've used: maybe there's some incompatibility
with 2.4.
Here's a standalone piece of code you can try (I'd suggest trying it several times;
it actually worked for me just now after failing :) ). Input %cpaste', then paste the
code, then input '--' and ENTER. If it pastes without error, you should be able to
do "subStringMatchExact('atgacatgcacaagtatgcat', 'atg')" and get "(0, 5, 15)" as a
result.
-----------------------------------------------------------------
def subStringMatchExact(target_string, key_string):
    """Return a tuple of indices of the key string in the target
    string.

    """

    i = 0
    index_list = []

    if key_string:
        while i < len(target_string):
            i = target_string.find(key_string, i)
            if i == -1:
                return tuple(index_list)
            else:
                index_list.append(i)
            i += len(key_string)
    return tuple(index_list)

Reported by ben.alkov on 2012-06-08 19:27:46

@Maximus5
Copy link
Owner Author

Ok, successfully installed on ActivePython 2.7.2.5

Reported by ConEmu.Maximus5 on 2012-06-08 19:31:17

@Maximus5
Copy link
Owner Author

Check 120608

Reported by ConEmu.Maximus5 on 2012-06-08 21:48:46

@Maximus5
Copy link
Owner Author

Excellent! I haven't done a *lot* of testing, but the two examples I tried (40 lines
and 37 lines) both worked perfectly the first time. Pasting was a /little/ slow, but
hey, it works :)

Reported by ben.alkov on 2012-06-09 14:57:04

@Maximus5
Copy link
Owner Author

The pasting was rewritten and the code has become too fast :)
Small lags have been added in order to avoid input queue overflow.
In future may be...

Reported by ConEmu.Maximus5 on 2012-06-09 19:10:54

  • Status changed: Fixed

@Maximus5
Copy link
Owner Author

Lags problem fixed, wait for the next version

Reported by ConEmu.Maximus5 on 2012-06-17 20:00:59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant