diff --git a/Lib/cmd.py b/Lib/cmd.py index c333e099bd8c9a..438b88aa1049cc 100644 --- a/Lib/cmd.py +++ b/Lib/cmd.py @@ -42,12 +42,15 @@ functions respectively. """ -import inspect, string, sys +import sys __all__ = ["Cmd"] PROMPT = '(Cmd) ' -IDENTCHARS = string.ascii_letters + string.digits + '_' +IDENTCHARS = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' + 'abcdefghijklmnopqrstuvwxyz' + '0123456789' + '_') class Cmd: """A simple framework for writing line-oriented command interpreters. @@ -303,9 +306,11 @@ def do_help(self, arg): try: func = getattr(self, 'help_' + arg) except AttributeError: + from inspect import cleandoc + try: doc=getattr(self, 'do_' + arg).__doc__ - doc = inspect.cleandoc(doc) + doc = cleandoc(doc) if doc: self.stdout.write("%s\n"%str(doc)) return diff --git a/Misc/NEWS.d/next/Library/2025-02-13-02-03-38.gh-issue-118761.le_qEg.rst b/Misc/NEWS.d/next/Library/2025-02-13-02-03-38.gh-issue-118761.le_qEg.rst new file mode 100644 index 00000000000000..4a5b7f6b5de6cd --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-02-13-02-03-38.gh-issue-118761.le_qEg.rst @@ -0,0 +1,2 @@ +Improve import time of :mod:`cmd` by lazy importing :mod:`inspect` and +removing :mod:`string`. Patch by Semyon Moroz.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: