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

Typing a 'try' statement leads to "incomplete input" #13847

Open
DrLex0 opened this issue Nov 30, 2022 · 0 comments
Open

Typing a 'try' statement leads to "incomplete input" #13847

DrLex0 opened this issue Nov 30, 2022 · 0 comments

Comments

@DrLex0
Copy link

DrLex0 commented Nov 30, 2022

ipython (or rather ipython3) 7.31.1 as installed in Ubuntu 22.04 (Jammy).

When typing:

try:
    print("whatever")  # or just any other line, 

and then hitting enter, it will result in:

In [18]: try:
    ...:     print("whatever")
  File "<ipython-input-18-05e767bdfd94>", line 2
    print("whatever")
                     ^
SyntaxError: incomplete input

It is not a general problem with multi-line input like #11334, other multi-line statements like if can be typed. So far, I have only seen this with try.
It will also happen if there were lines before it:

In [28]: if 1 == 1:
    ...:     print("I can type this")
    ...:     try:
    ...:         # blah
  File "<ipython-input-28-b092d0cb766f>", line 4
    # blah
          ^
SyntaxError: incomplete input

The only unpractical and kludgy workarounds that I have found to work, are copy-pasting at least 2 lines after the try: line, or using ctrl-o to add extra lines. Other things like shift-enter or leaving an empty line do not help.

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

No branches or pull requests

1 participant