Skip to content

Conversation

@n-takumasa
Copy link
Contributor

Description

Fixes followings:

  • %paste breaks the input history (In) index
  • %paste -q occurs a database error
  • %paste is not stored but others are stored in the history
  • %cpaste does not store its content in the history

Closes #13835
Closes #13829

Changes

  • %paste -q, %cpaste, %cpaste -q does not store itself in the history

Notes

Actual Behavior

magic count store
magic
store
block
error
%paste +1 no yes no
%paste -q +1 yes yes yes
%cpaste 0 yes no no
%cpaste -q 0 yes no no

Expected Behavior

magic count store
magic
store
block
error
%paste 0 no yes no
%paste -q 0 no yes no
%cpaste 0 no yes no
%cpaste -q 0 no yes no

Reproductive

Before this PR

%paste

(.venv) PS ipython> Set-Clipboard """Clipborard"""
(.venv) PS ipython> ipython
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: %paste
"Clipborard"

## -- End pasted text --
Out[1]: 'Clipborard'

In [3]: %paste -q
Out[3]: 'Clipborard'

ERROR! Session/line number was not unique in database. History logging moved to new session 330
In [5]: from pprint import pprint; pprint(list(enumerate(In)))
[(0, ''),
 (1, '"Clipborard"'),
 (2, "get_ipython().run_line_magic('paste', '-q')"),
 (3, '"Clipborard"'),
 (4, 'from pprint import pprint; pprint(list(enumerate(In)))')]

%cpaste

(.venv) PS ipython> ipython
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:"Keyboard"
:--
Out[1]: 'Keyboard'

In [2]: %cpaste -q
"Keyboard2"
--
Out[2]: 'Keyboard2'

In [3]: from pprint import pprint; pprint(list(enumerate(In)))
[(0, ''),
 (1, "get_ipython().run_line_magic('cpaste', '')"),
 (2, "get_ipython().run_line_magic('cpaste', '-q')"),
 (3, 'from pprint import pprint; pprint(list(enumerate(In)))')]

After this PR

%paste

(.venv) PS ipython> Set-Clipboard """Clipborard"""
(.venv) PS ipython> ipython
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: %paste
"Clipborard"

## -- End pasted text --
Out[1]: 'Clipborard'    

In [2]: %paste -q
Out[2]: 'Clipborard'

In [3]: from pprint import pprint; pprint(list(enumerate(In)))
[(0, ''),
 (1, '"Clipborard"'),
 (2, '"Clipborard"'),
 (3, 'from pprint import pprint; pprint(list(enumerate(In)))')]

%cpaste

(.venv) PS ipython> ipython
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.8.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:"Keyboard"
:--
Out[1]: 'Keyboard'

In [2]: %cpaste -q
"Keyboard2"
--
Out[2]: 'Keyboard2'

In [3]: from pprint import pprint; pprint(list(enumerate(In)))
[(0, ''),
 (1, '"Keyboard"'),
 (2, '"Keyboard2"'),
 (3, 'from pprint import pprint; pprint(list(enumerate(In)))')]

@Carreau Carreau merged commit e202f56 into ipython:main Dec 21, 2022
@Carreau
Copy link
Member

Carreau commented Dec 21, 2022

Thanks !

@feliche93
Copy link

@n-takumasa I am still getting the error when I run an interactive window in vs-code

Version: 1.74.3 (Universal)
Commit: 97dec172d3256f8ca4bfb2143f3f76b503ca0534
Date: 2023-01-09T17:07:18.579Z (5 days ago)
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 22.2.0
Sandboxed: No

I downgraded to ipython 8.1.1 as well as the latest and still get the same error.

Could it be related at all?

@n-takumasa
Copy link
Contributor Author

@feliche93
On my environment (Windows 10 + vscode 1.74.3 + IPython 8.8.0), the error (ERROR! Session/line number was not unique in database.) does not reproduce.
I think it is an issue with your environment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"paste -q" cause "session number not unique" error, while "paste" does not %cpaste still stores itself in history (unlike %paste)

3 participants