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

ctrl + c on latest PDM exits python interactive session instead of clearing the current line #1547

Closed
1 task done
jayceslesar opened this issue Dec 6, 2022 · 5 comments · Fixed by j178/pdm#1
Closed
1 task done
Labels
🐛 bug Something isn't working

Comments

@jayceslesar
Copy link

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

Before, when I ran pdm run python I was able to use ctrl + c to clear the input in the current line of the terminal. Now it exits the terminal completely which is not what happened before.

Actual behavior

In a direct call of python3 ctrl + c does not quit the interactive session.

❯ python3                   
Python 3.10.6 (main, Oct  3 2022, 19:34:55) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
KeyboardInterrupt
>>> 

In an instance of pdm run python3 or pdm run, a ctrl + c exits the session.

❯ pdm run python3           
Python 3.10.6 (main, Oct  3 2022, 19:34:55) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
KeyboardInterrupt
>>> Traceback (most recent call last):
  File "/opt/homebrew/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.3.1/libexec/lib/python3.11/site-packages/pdm/core.py", line 258, in main
    return Core().main(args)
           ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.3.1/libexec/lib/python3.11/site-packages/pdm/core.py", line 185, in main
    f(project, options)
  File "/opt/homebrew/Cellar/pdm/2.3.1/libexec/lib/python3.11/site-packages/pdm/cli/commands/run.py", line 386, in handle
    exit_code = runner.run(options.command, options.args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.3.1/libexec/lib/python3.11/site-packages/pdm/cli/commands/run.py", line 321, in run
    return self._run_process(
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/pdm/2.3.1/libexec/lib/python3.11/site-packages/pdm/cli/commands/run.py", line 224, in _run_process
    process.wait()
  File "/opt/homebrew/Cellar/[email protected]/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1260, in wait
    return self._wait(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1995, in _wait
    (pid, sts) = self._try_wait(0)
                 ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.0/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1953, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt

Expected behavior

ctrl + c should not quit the interactive session

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
pdm info && pdm info --env
PDM version:
  2.3.1
Python Interpreter:
  /Users/jslesar/work/my-repo/.venv/bin/python (3.10)
Project Root:
  /Users/jslesar/work/my-repo
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.10.6",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "21.6.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000",
  "python_full_version": "3.10.6",
  "platform_python_implementation": "CPython",
  "python_version": "3.10",
  "sys_platform": "darwin"
}
@jayceslesar jayceslesar added the 🐛 bug Something isn't working label Dec 6, 2022
@jayceslesar
Copy link
Author

definitely something fishy going on here...this was not the case before the latest PDM. I am also using a pyenv shell of 3.10.6 so it is weird to me why the 3.11 is showing up

@pawamoy
Copy link
Contributor

pawamoy commented Dec 6, 2022

Confirmed on my end as well.

@frostming
Copy link
Collaborator

This is caused by a fix for a weird issue of uvicorn: #1474 (comment)
The exact commit is 0edac2e

@frostming
Copy link
Collaborator

definitely something fishy going on here...this was not the case before the latest PDM. I am also using a pyenv shell of 3.10.6 so it is weird to me why the 3.11 is showing up

Nothing wrong, it is because PDM is installed with Python 3.11, it is different from what you use for your current shell or project.

@DurandA
Copy link

DurandA commented Feb 20, 2024

I am still facing this issue on PDM version 2.12.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants