Skip to content

Commit a93b020

Browse files
authored
Add command line argument to disable importlib bootstrapping (#1040)
1 parent f453387 commit a93b020

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

Src/IronPython/Hosting/PythonOptionsParser.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ protected override void ParseArgument(string/*!*/ arg) {
190190
ConsoleOptions.BasicConsole = true;
191191
break;
192192

193+
#if DEBUG
194+
case "-X:NoImportLib":
195+
LanguageSetup.Options["NoImportLib"] = ScriptingRuntimeHelpers.True;
196+
break;
197+
#endif
198+
193199
default:
194200
if(arg.StartsWith("-W")) {
195201
if (_warningFilters == null) {
@@ -261,6 +267,9 @@ public override void GetHelp(out string commandLine, out string[,] options, out
261267
{ "-X:EnableProfiler", "Enables profiling support in the compiler" },
262268
{ "-X:LightweightScopes", "Generate optimized scopes that can be garbage collected" },
263269
{ "-X:BasicConsole", "Use only the basic console features" },
270+
#if DEBUG
271+
{ "-X:NoImportLib", "Don't bootstrap importlib" },
272+
#endif
264273
};
265274

266275
// Ensure the combined options come out sorted

Src/IronPython/Runtime/PythonContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public PythonContext(ScriptDomainManager/*!*/ manager, IDictionary<string, objec
294294
_mainThreadFunctionStack = PythonOps.GetFunctionStack();
295295

296296
// bootstrap importlib
297+
if (PythonOptions.NoImportLib) return;
297298
try {
298299
var sourceUnit = CreateSourceUnit(new BootstrapStreamContentProvider(), null, DefaultEncoding, SourceCodeKind.File);
299300

Src/IronPython/Runtime/PythonOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public sealed class PythonOptions : LanguageOptions {
120120

121121
public bool Quiet { get; }
122122

123+
internal bool NoImportLib { get; } // TODO: get rid of me when we no longer bootstrap importlib
124+
123125
public PythonOptions()
124126
: this(null) {
125127
}
@@ -149,6 +151,9 @@ public PythonOptions(IDictionary<string, object> options)
149151
Tracing = GetOption(options, "Tracing", false);
150152
NoDebug = GetOption(options, "NoDebug", (Regex)null);
151153
Quiet = GetOption(options, "Quiet", false);
154+
#if DEBUG
155+
NoImportLib = GetOption(options, "NoImportLib", false);
156+
#endif
152157
}
153158

154159
private static IDictionary<string, object> EnsureSearchPaths(IDictionary<string, object> options) {

0 commit comments

Comments
 (0)