Skip to content

Commit edd799d

Browse files
remove staticmethod decorators, silence errors
1 parent c55fec1 commit edd799d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Lib/test/test_xpickle.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This test covers backwards compatibility with
22
# previous version of Python by bouncing pickled objects through Python 3.6
33
# and Python 3.9 by running xpickle_worker.py.
4+
import os
45
import pathlib
56
import pickle
67
import subprocess
@@ -67,12 +68,15 @@ def have_python_version(py_version):
6768
python_str = ".".join(map(str, py_version))
6869
targets = [('py', f'-{python_str}'), (f'python{python_str}',)]
6970
if py_version not in py_executable_map:
70-
for target in targets[0 if is_windows else 1:]:
71-
worker = subprocess.Popen([*target, '-c','import test.support'],
72-
shell=is_windows)
73-
worker.communicate()
74-
if worker.returncode == 0:
75-
py_executable_map[py_version] = target
71+
with open(os.devnull, 'w') as devnull:
72+
for target in targets[0 if is_windows else 1:]:
73+
worker = subprocess.Popen([*target, '-c','import test.support'],
74+
stdout=devnull,
75+
stderr=devnull,
76+
shell=is_windows)
77+
worker.communicate()
78+
if worker.returncode == 0:
79+
py_executable_map[py_version] = target
7680

7781
return py_executable_map.get(py_version, None)
7882

@@ -99,8 +103,7 @@ def tearDown(self):
99103
pickletester.protocols = range(pickle.HIGHEST_PROTOCOL + 1)
100104
pickle.HIGHEST_PROTOCOL = self._OLD_HIGHEST_PROTOCOL
101105

102-
@staticmethod
103-
def send_to_worker(python, obj, proto, **kwargs):
106+
def send_to_worker(self, python, obj, proto, **kwargs):
104107
"""Bounce a pickled object through another version of Python.
105108
This will pickle the object, send it to a child process where it will
106109
be unpickled, then repickled and sent back to the parent process.
@@ -145,8 +148,7 @@ def dumps(self, arg, proto=0, **kwargs):
145148
python = py_executable_map[self.py_version]
146149
return self.send_to_worker(python, arg, proto, **kwargs)
147150

148-
@staticmethod
149-
def loads(*args, **kwargs):
151+
def loads(self, *args, **kwargs):
150152
return super().loads(*args, **kwargs)
151153

152154
# A scaled-down version of test_bytes from pickletester, to reduce

0 commit comments

Comments
 (0)