File: python3.13-pipes.patch

package info (click to toggle)
grpc 1.51.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,328 kB
  • sloc: cpp: 361,873; python: 72,206; ansic: 37,787; objc: 12,434; ruby: 11,521; sh: 7,652; php: 7,615; makefile: 3,481; xml: 3,246; cs: 1,836; javascript: 1,614; java: 465; pascal: 227; awk: 132
file content (110 lines) | stat: -rw-r--r-- 3,936 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
From dfa9d853fff02212ff232da5b39b76adf3ecce83 Mon Sep 17 00:00:00 2001
From: Leonardo Pistone <lepistone@spotify.com>
Date: Thu, 7 Dec 2023 12:59:29 -0800
Subject: [PATCH] Fix Python DeprecationWarning: 'pipes' (#34941)

Starting from Python 3.11, the pipes module produces this warning:

DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13

Turns out that in this repo the pipes module is only used for the
"quote" function which is turn directly taken from the shlex module [1].

The shlex module is not deprecated as of today and is already used in
other places in this repo. The function shlex.quote has been around
since the ancient Python 3.3.

[1] https://github.com/python/cpython/blob/3.11/Lib/pipes.py#L64-L66

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #34941

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34941 from lepistone:deprecate-python-pipes 233c54c135542178703aa700a2dddadc895fedb0
PiperOrigin-RevId: 588883480
---
 tools/run_tests/run_performance_tests.py | 10 +++++-----
 tools/run_tests/run_tests.py             |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

Origin: upstream, https://github.com/grpc/grpc/pull/34941
Bug-Debian: https://bugs.debian.org/1084603
--- a/tools/run_tests/run_performance_tests.py
+++ b/tools/run_tests/run_performance_tests.py
@@ -22,8 +22,8 @@
 import json
 import multiprocessing
 import os
-import pipes
 import re
+import shlex
 import subprocess
 import sys
 import tempfile
@@ -124,7 +124,7 @@
     if bq_result_table:
         cmd += 'BQ_RESULT_TABLE="%s" ' % bq_result_table
     cmd += 'tools/run_tests/performance/run_qps_driver.sh '
-    cmd += '--scenarios_json=%s ' % pipes.quote(
+    cmd += '--scenarios_json=%s ' % shlex.quote(
         json.dumps({'scenarios': [scenario_json]}))
     cmd += '--scenario_result_file=scenario_result.json '
     if server_cpu_load != 0:
@@ -132,7 +132,7 @@
     if remote_host:
         user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
         cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
-            user_at_host, pipes.quote(cmd))
+            user_at_host, shlex.quote(cmd))
 
     return jobset.JobSpec(cmdline=[cmd],
                           shortname='%s' % scenario_json['name'],
@@ -149,7 +149,7 @@
     if remote_host:
         user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, remote_host)
         cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
-            user_at_host, pipes.quote(cmd))
+            user_at_host, shlex.quote(cmd))
 
     return jobset.JobSpec(cmdline=[cmd],
                           shortname='shutdown_workers',
@@ -180,7 +180,7 @@
     if client_host:
         user_at_host = '%s@%s' % (_REMOTE_HOST_USERNAME, client_host)
         cmd = 'ssh %s "cd ~/performance_workspace/grpc/ && "%s' % (
-            user_at_host, pipes.quote(cmd))
+            user_at_host, shlex.quote(cmd))
 
     return jobset.JobSpec(cmdline=[cmd],
                           shortname='netperf',
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -26,10 +26,10 @@
 import multiprocessing
 import os
 import os.path
-import pipes
 import platform
 import random
 import re
+import shlex
 import socket
 import subprocess
 import sys
@@ -415,7 +415,7 @@
                         cmdline = [binary] + target['args']
                         shortname = target.get(
                             'shortname',
-                            ' '.join(pipes.quote(arg) for arg in cmdline))
+                            ' '.join(shlex.quote(arg) for arg in cmdline))
                         shortname += shortname_ext
                         out.append(
                             self.config.job_spec(