Skip to content

gh-79451: Cmd.complete: use completedefault also with cmd=None - #10588

Closed
blueyed wants to merge 3 commits into
python:mainfrom
blueyed:cmd-complete-None
Closed

blueyed wants to merge 3 commits into
python:mainfrom
blueyed:cmd-complete-None

Conversation

@blueyed

@blueyed blueyed commented Nov 17, 2018 •

Copy link
Copy Markdown
Contributor

Otherwise it will trigger a TypeError ("must be str, not NoneType") below with:

compfunc = getattr(self, 'complete_' + cmd)

The doc for parseline state:

'command' and 'args' may be None if the line couldn't be parsed.

Might need a test of course etc, but maybe one fails already..

https://bugs.python.org/issue35270

TODO:

  • test

@remilapeyre remilapeyre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @blueyed, can you add a test and a Misc/NEWS.d entry? You can either use blurb or https://blurb-it.herokuapp.com/

Comment thread Lib/cmd.py Resolved
@blueyed

blueyed commented Feb 8, 2019

Copy link
Copy Markdown
Contributor Author

Added a test.

@blueyed

blueyed commented Mar 9, 2019

Copy link
Copy Markdown
Contributor Author

@remilapeyre
Gentle ping.

Otherwise it will trigger a TypeError ("must be str, not NoneType") below with:

    compfunc = getattr(self, 'complete_' + cmd)

The doc for `parseline` states:

> 'command' and 'args' may be None if the line couldn't be parsed.
@blueyed
blueyed force-pushed the cmd-complete-None branch from 4bb8624 to 704a33d Compare March 9, 2019 15:13
@blueyed

blueyed commented Mar 9, 2019

Copy link
Copy Markdown
Contributor Author

Hopefully fixed the test for Windows (skipping with missing readline), and rebased.

@remilapeyre remilapeyre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@ghost

ghost commented Jan 3, 2024

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@encukou

encukou commented Jan 3, 2024

Copy link
Copy Markdown
Member

Hello, and sorry for the delay.
Are you still interested in this PR? You would need to (re)-sign the CLA (click the CI failure).
Also, we can now test readline-related functionality in a PTY, so rather than using mock you could do something like this in CmdTestReadline:

    def test_with_None_from_parseline(self):
        script = textwrap.dedent("""
            import cmd
            class CustomCmd(cmd.Cmd):
                def parseline(self, line):
                    if line.startswith('exit'):
                        return 'exit', '', line
                    return None, None, line

                def completedefault(self, *args):
                    return ['via_completedefault']

                def do_exit(self, args):
                    return True

            CustomCmd().cmdloop()
        """)

        input = b"foo bar\t\nexit\n"

        output = run_pty(script, input)

        self.assertIn(b'via_completedefault', output)

@python-cla-bot

python-cla-bot Bot commented Apr 6, 2025

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA signed

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jun 15, 2025
@serhiy-storchaka serhiy-storchaka changed the title bpo-35270: Cmd.complete: use completedefault also with cmd=None gh-79451: Cmd.complete: use completedefault also with cmd=None Aug 12, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 13, 2026
@ambv

ambv commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

This PR has been blocked on an unsigned CLA for more than 12 months and cannot be merged until all commit authors sign. Closing to cull the number of open pull requests. Do not reopen this pull request without signing the CLA first and getting a go-ahead from a triager or core developer on gh-79451.

@ambv ambv closed this Oct 21, 2026
@blueyed blueyed mannequin mentioned this pull request Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants