`pty` option not working as expected in Python 3.14

Open
#1,052 1 comment 20 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Reproduce the behavior using the tasks.py and main.py examples, comparing Python 3.13 with Python 3.14 on macOS. Start by tracing the pty=True execution path and the handling of keyboard input; done means interactive input and Ctrl-C work again under Python 3.14.

Written by the indexing model from the issue text.

Description

I have some tasks that use an interactive terminal however when running those tasks with Python 3.14 the keyboard inputs are not passed through.
I'm not sure my understanding of the issue is good enough to explain it but I have created an example below which should demonstrate the issue:


tasks.py

from invoke import task

@task
def run(c):
    c.run("python main.py", pty=True)

main.py

#!/usr/bin/env python3

def main():
    result = input("Please enter some text: ")

    print(f"This is what you input: {result}")

if __name__ == '__main__':
    main()

When I run this with Python 3.13 or older it accepts the input and prints the result:

invoke run
Please enter some text: Some text
This is what you input: Some text

When I run this with Python 3.14, the input is not accepted and actually no keyboard inputs seem to go through including ctrl C to kill the process:

invoke run
Please enter some text: Some text
^C^C
^C^C

I am using pyenv to manage the Python versions (which is 3.14.0 to be exact) and I'm on macOS Sequoia Version 15.7

Dominant language
Python
Stars
4.8k
Forks
412
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pyinvoke/invoke

All issues in pyinvoke/invoke

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.