FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

shlex.quote: Add `force` keyword argument · Issue #119670 · python/cpython · GitHub

Repository navigation

shlex.quote: Add force keyword argument #119670

Closed

Description

Feature or enhancement

Proposal:

Add the ability to force shlex.quote to always return an escaped / quoted string, avoiding the expensive regex-ing of a straggly set of characters (currently r'[^\w@%+=:,./-]') .

Different shells have slightly different sets of special characters, eg sometimes including #, sometimes not. To quell one's pedantic paranoia of strings being incorrectly escaped due to an incomplete regex check, we extend the signature of shlex.quote in a perfectly backwards compatible way which skips the regex and goes straight to the escaping.

Changes shlex.quote's signature from

def quote(s):

to

def quote(s, always=False):

always is of bool type, and by default is False, which produces the existing behaviour of the function.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on May 28, 2024
  2. changed the title [-]shlex.quote: Add 'always' keyword argument[/-] [+]shlex.quote: Add `force` keyword argument[/+] on Apr 28, 2026
  3. added a commit that references this issue on Jun 3, 2026
  4. added a commit that references this issue on Jun 4, 2026
  5. vstinner commented on Jun 4, 2026

    Member

    At the end, it was decided to rename the parameter to "force" (force=True).

  6. added a commit that references this issue on Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL