File tree 1 file changed +13
-5
lines changed 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 7
7
# cpymods - a dictionary mapping module names to their contents
8
8
# libdir - the location of RustPython's Lib/ directory.
9
9
10
- import re
10
+ import inspect
11
+ import io
11
12
import os
13
+ import re
12
14
import sys
13
15
import warnings
14
- import inspect
16
+ from contextlib import redirect_stdout
15
17
from pydoc import ModuleScanner
16
18
17
19
@@ -138,7 +140,10 @@ def onerror(modname):
138
140
139
141
140
142
def dir_of_mod_or_error (module_name ):
141
- with warnings .catch_warnings ():
143
+ # Importing modules causes ('Constant String', 2, None, 4) and
144
+ # "Hello world!" to be printed to stdout.
145
+ f = io .StringIO ()
146
+ with warnings .catch_warnings (), redirect_stdout (f ):
142
147
# ignore warnings caused by importing deprecated modules
143
148
warnings .filterwarnings ("ignore" , category = DeprecationWarning )
144
149
try :
@@ -197,11 +202,14 @@ def gen_modules():
197
202
libdir = ""
198
203
# This function holds the source code that will be run under RustPython
199
204
def compare ():
200
- import re
205
+ import inspect
206
+ import io
201
207
import os
208
+ import re
202
209
import sys
203
210
import warnings
204
- import inspect
211
+ from contextlib import redirect_stdout
212
+
205
213
import platform
206
214
207
215
def method_incompatability_reason (typ , method_name , real_method_value ):
You can’t perform that action at this time.
0 commit comments