Skip to content

Conversation

mgorny
Copy link
Member

@mgorny mgorny commented May 25, 2024

Replace the use of pipes.quote() with shlex.quote() to fix compatibility with Python 3.13. The former was always an undocumented alias to the latter, and the pipes module was removed completely in Python 3.13.

Fixes #93375

Replace the use of `pipes.quote()` with `shlex.quote()` to fix
compatibility with Python 3.13.  The former was always an undocumented
alias to the latter, and the `pipes` module was removed completely
in Python 3.13.

Fixes llvm#93375
@mgorny mgorny requested review from MaskRay and thesamesam May 25, 2024 09:06
@mgorny mgorny requested a review from a team as a code owner May 25, 2024 09:06
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 25, 2024
@llvmbot
Copy link
Member

llvmbot commented May 25, 2024

@llvm/pr-subscribers-libcxx

Author: Michał Górny (mgorny)

Changes

Replace the use of pipes.quote() with shlex.quote() to fix compatibility with Python 3.13. The former was always an undocumented alias to the latter, and the pipes module was removed completely in Python 3.13.

Fixes #93375


Full diff: https://github.com/llvm/llvm-project/pull/93376.diff

2 Files Affected:

  • (modified) libcxx/test/libcxx/lit.local.cfg (+3-2)
  • (modified) libcxx/utils/libcxx/test/dsl.py (+2-2)
diff --git a/libcxx/test/libcxx/lit.local.cfg b/libcxx/test/libcxx/lit.local.cfg
index 147367323d4a6..4467d8070cc70 100644
--- a/libcxx/test/libcxx/lit.local.cfg
+++ b/libcxx/test/libcxx/lit.local.cfg
@@ -1,4 +1,5 @@
 # The tests in this directory need to run Python
-import pipes, sys
+import shlex
+import sys
 
-config.substitutions.append(("%{python}", pipes.quote(sys.executable)))
+config.substitutions.append(("%{python}", shlex.quote(sys.executable)))
diff --git a/libcxx/utils/libcxx/test/dsl.py b/libcxx/utils/libcxx/test/dsl.py
index 387862ae6f496..7ac66d449b1cf 100644
--- a/libcxx/utils/libcxx/test/dsl.py
+++ b/libcxx/utils/libcxx/test/dsl.py
@@ -8,8 +8,8 @@
 
 import os
 import pickle
-import pipes
 import platform
+import shlex
 import shutil
 import tempfile
 
@@ -290,7 +290,7 @@ def hasAnyLocale(config, locales):
       }
     #endif
   """
-    return programSucceeds(config, program, args=[pipes.quote(l) for l in locales])
+    return programSucceeds(config, program, args=[shlex.quote(l) for l in locales])
 
 
 @_memoizeExpensiveOperation(lambda c, flags="": (c.substitutions, c.environment, flags))

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.

@ldionne
Copy link
Member

ldionne commented May 27, 2024

CI failures are flukes, merging.

@ldionne ldionne merged commit d3ce107 into llvm:main May 27, 2024
@mgorny mgorny deleted the licxx-py313 branch May 27, 2024 17:30
@mgorny
Copy link
Member Author

mgorny commented May 27, 2024

Thanks!

@mgorny
Copy link
Member Author

mgorny commented Jun 1, 2024

@ldionne, do you think we could backport this to 18.x too? It's rather trivial change, and previous LLVM versions tend to linger for years.

@ldionne
Copy link
Member

ldionne commented Jun 5, 2024

@mgorny Yes, you can follow the cherry-pick request process and I'll approve it. Are we still doing point releases for LLVM 18 though?

@mgorny
Copy link
Member Author

mgorny commented Jun 5, 2024

Oh, we aren't indeed. I haven't noticed, thanks for letting me know.

Leo3418 pushed a commit to yxlvcs-rit/csci-352-2241 that referenced this pull request Oct 28, 2024
The 'pipes' Python module has been deprecated for a while and been
removed in Python 3.13 [1].  A drop-in replacement for 'pipes.quote()'
is 'shlex.quote()' [2][3].

[1]: https://www.python.org/downloads/release/python-3130/
[2]: tox-dev/tox#2418
[3]: llvm/llvm-project#93376
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libc++ test runner fails on Python 3.13: ModuleNotFoundError: No module named 'pipes'
3 participants