26
26
package com .oracle .graal .python .runtime ;
27
27
28
28
import java .io .File ;
29
- import java .io .IOException ;
30
29
31
30
import com .oracle .graal .python .PythonLanguage ;
32
31
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
@@ -55,7 +54,6 @@ public interface PythonCore {
55
54
static final String NO_PREFIX_WARNING = "could not determine Graal.Python's sys prefix path - you may need to pass --python.SysPrefix." ;
56
55
static final String NO_CORE_WARNING = "could not determine Graal.Python's core path - you may need to pass --python.CoreHome." ;
57
56
static final String NO_STDLIB = "could not determine Graal.Python's standard library path. You need to pass --python.StdLibHome if you want to use the standard library." ;
58
- static final boolean LIBPOLYGLOT = Boolean .getBoolean ("graalvm.libpolyglot" );
59
57
60
58
/**
61
59
* Load the core library and prepare all builtin classes and modules.
@@ -117,25 +115,12 @@ public interface PythonCore {
117
115
118
116
public PInt getFalse ();
119
117
120
- static void writeWarning (TruffleLanguage .Env env , String warning ) {
121
- if (!LIBPOLYGLOT || env .getOptions ().get (PythonOptions .VerboseFlag )) {
122
- write (env , "WARNING: " + warning );
123
- }
118
+ static void writeWarning (String warning ) {
119
+ PythonLanguage .getLogger ().warning (warning );
124
120
}
125
121
126
- static void writeInfo (TruffleLanguage .Env env , String warning ) {
127
- if (env .getOptions ().get (PythonOptions .VerboseFlag )) {
128
- write (env , warning );
129
- }
130
- }
131
-
132
- static void write (TruffleLanguage .Env env , String warning ) {
133
- try {
134
- env .err ().write ("[python] " .getBytes ());
135
- env .err ().write (warning .getBytes ());
136
- env .err ().write ('\n' );
137
- } catch (IOException e ) {
138
- }
122
+ static void writeInfo (String warning ) {
123
+ PythonLanguage .getLogger ().info (warning );
139
124
}
140
125
141
126
@ TruffleBoundary
@@ -152,7 +137,7 @@ public static String getCoreHomeOrFail() {
152
137
public static String getSysPrefix (TruffleLanguage .Env env ) {
153
138
String sysPrefix = env .getOptions ().get (PythonOptions .SysPrefix );
154
139
if (sysPrefix .isEmpty ()) {
155
- writeWarning (env , NO_PREFIX_WARNING );
140
+ writeWarning (NO_PREFIX_WARNING );
156
141
env .getOptions ().set (PythonOptions .SysPrefix , PREFIX );
157
142
return LIB_GRAALPYTHON ;
158
143
}
@@ -163,7 +148,7 @@ public static String getSysPrefix(TruffleLanguage.Env env) {
163
148
public static String getCoreHome (TruffleLanguage .Env env ) {
164
149
String coreHome = env .getOptions ().get (PythonOptions .CoreHome );
165
150
if (coreHome .isEmpty ()) {
166
- writeWarning (env , NO_CORE_WARNING );
151
+ writeWarning (NO_CORE_WARNING );
167
152
env .getOptions ().set (PythonOptions .CoreHome , LIB_GRAALPYTHON );
168
153
return LIB_GRAALPYTHON ;
169
154
}
@@ -174,7 +159,7 @@ public static String getCoreHome(TruffleLanguage.Env env) {
174
159
public static String getStdlibHome (TruffleLanguage .Env env ) {
175
160
String stdLibHome = env .getOptions ().get (PythonOptions .StdLibHome );
176
161
if (stdLibHome .isEmpty ()) {
177
- writeWarning (env , NO_STDLIB );
162
+ writeWarning (NO_STDLIB );
178
163
env .getOptions ().set (PythonOptions .StdLibHome , LIB_PYTHON_3 );
179
164
return LIB_PYTHON_3 ;
180
165
}
0 commit comments