@@ -98,15 +98,15 @@ private static final class LocalData {
98
98
@ Override
99
99
public void postInitialize (Python3Core core ) {
100
100
super .postInitialize (core );
101
- core .lookupBuiltinModule (T_READLINE ).setInternalAttributes (new LocalData ());
101
+ core .lookupBuiltinModule (T_READLINE ).setModuleState (new LocalData ());
102
102
}
103
103
104
104
@ Builtin (name = "get_completer" , minNumOfPositionalArgs = 1 , declaresExplicitSelf = true )
105
105
@ GenerateNodeFactory
106
106
abstract static class GetCompleterNode extends PythonUnaryBuiltinNode {
107
107
@ Specialization
108
108
static Object getCompleter (PythonModule self ) {
109
- LocalData data = self .getInternalAttributes ();
109
+ LocalData data = self .getModuleState ();
110
110
if (data .completer != null ) {
111
111
return data .completer ;
112
112
} else {
@@ -120,7 +120,7 @@ static Object getCompleter(PythonModule self) {
120
120
abstract static class SetCompleterNode extends PythonBinaryBuiltinNode {
121
121
@ Specialization
122
122
PNone setCompleter (PythonModule self , Object callable ) {
123
- LocalData data = self .getInternalAttributes ();
123
+ LocalData data = self .getModuleState ();
124
124
data .completer = callable ;
125
125
return PNone .NONE ;
126
126
}
@@ -134,7 +134,7 @@ abstract static class ParseAndBindNode extends PythonBinaryBuiltinNode {
134
134
PNone setCompleter (PythonModule self , TruffleString tspec ) {
135
135
String spec = tspec .toJavaStringUncached ();
136
136
if (spec .startsWith ("tab:" )) {
137
- LocalData data = self .getInternalAttributes ();
137
+ LocalData data = self .getModuleState ();
138
138
data .bindings .put ("tab" , spec .split (":" )[1 ].trim ());
139
139
return PNone .NONE ;
140
140
} else {
@@ -159,7 +159,7 @@ abstract static class GetHistoryLengthNode extends PythonUnaryBuiltinNode {
159
159
@ Specialization
160
160
@ TruffleBoundary
161
161
int setCompleter (PythonModule self ) {
162
- LocalData data = self .getInternalAttributes ();
162
+ LocalData data = self .getModuleState ();
163
163
return data .history .size ();
164
164
}
165
165
}
@@ -170,7 +170,7 @@ abstract static class SetHistoryLengthNode extends PythonBinaryBuiltinNode {
170
170
@ Specialization
171
171
@ TruffleBoundary
172
172
TruffleString setCompleter (PythonModule self , int index ) {
173
- LocalData data = self .getInternalAttributes ();
173
+ LocalData data = self .getModuleState ();
174
174
try {
175
175
return data .history .get (index );
176
176
} catch (IndexOutOfBoundsException e ) {
@@ -192,7 +192,7 @@ TruffleString setCompleter(PythonModule self, int index, PString string,
192
192
@ Specialization
193
193
@ TruffleBoundary
194
194
TruffleString setCompleter (PythonModule self , int index , TruffleString string ) {
195
- LocalData data = self .getInternalAttributes ();
195
+ LocalData data = self .getModuleState ();
196
196
try {
197
197
return data .history .set (index , string );
198
198
} catch (IndexOutOfBoundsException e ) {
@@ -207,7 +207,7 @@ abstract static class DeleteItemNode extends PythonBinaryBuiltinNode {
207
207
@ Specialization
208
208
@ TruffleBoundary
209
209
TruffleString setCompleter (PythonModule self , int index ) {
210
- LocalData data = self .getInternalAttributes ();
210
+ LocalData data = self .getModuleState ();
211
211
try {
212
212
return data .history .remove (index );
213
213
} catch (IndexOutOfBoundsException e ) {
@@ -229,7 +229,7 @@ static PNone addHistory(PythonModule self, PString item,
229
229
@ Specialization
230
230
@ TruffleBoundary
231
231
static PNone addHistory (PythonModule self , TruffleString item ) {
232
- LocalData data = self .getInternalAttributes ();
232
+ LocalData data = self .getModuleState ();
233
233
data .history .add (item );
234
234
return PNone .NONE ;
235
235
}
@@ -249,7 +249,7 @@ PNone setCompleter(PythonModule self, PString path,
249
249
@ TruffleBoundary
250
250
@ SuppressWarnings ("try" )
251
251
PNone setCompleter (PythonModule self , TruffleString path ) {
252
- LocalData data = self .getInternalAttributes ();
252
+ LocalData data = self .getModuleState ();
253
253
try (GilNode .UncachedRelease gil = GilNode .uncachedRelease ()) {
254
254
BufferedReader reader = getContext ().getEnv ().getPublicTruffleFile (path .toJavaStringUncached ()).newBufferedReader ();
255
255
String line ;
@@ -277,7 +277,7 @@ PNone setCompleter(PythonModule self, PString path,
277
277
@ Specialization
278
278
@ TruffleBoundary
279
279
PNone setCompleter (PythonModule self , TruffleString path ) {
280
- LocalData data = self .getInternalAttributes ();
280
+ LocalData data = self .getModuleState ();
281
281
try {
282
282
BufferedWriter writer = getContext ().getEnv ().getPublicTruffleFile (path .toJavaStringUncached ()).newBufferedWriter (StandardOpenOption .CREATE , StandardOpenOption .TRUNCATE_EXISTING );
283
283
for (TruffleString l : data .history ) {
@@ -298,7 +298,7 @@ abstract static class ClearNode extends PythonUnaryBuiltinNode {
298
298
@ Specialization
299
299
@ TruffleBoundary
300
300
static PNone setCompleter (PythonModule self ) {
301
- LocalData data = self .getInternalAttributes ();
301
+ LocalData data = self .getModuleState ();
302
302
data .history .clear ();
303
303
return PNone .NONE ;
304
304
}
@@ -327,7 +327,7 @@ static PNone setCompleter() {
327
327
abstract static class GetAutoHistoryNode extends PythonUnaryBuiltinNode {
328
328
@ Specialization
329
329
static boolean setCompleter (PythonModule self ) {
330
- LocalData data = self .getInternalAttributes ();
330
+ LocalData data = self .getModuleState ();
331
331
return data .autoHistory ;
332
332
}
333
333
}
@@ -337,7 +337,7 @@ static boolean setCompleter(PythonModule self) {
337
337
abstract static class SetAutoHistoryNode extends PythonBinaryBuiltinNode {
338
338
@ Specialization
339
339
static PNone setCompleter (PythonModule self , boolean enabled ) {
340
- LocalData data = self .getInternalAttributes ();
340
+ LocalData data = self .getModuleState ();
341
341
data .autoHistory = enabled ;
342
342
return PNone .NONE ;
343
343
}
@@ -348,7 +348,7 @@ static PNone setCompleter(PythonModule self, boolean enabled) {
348
348
abstract static class SetCompleterDelimsNode extends PythonBinaryBuiltinNode {
349
349
@ Specialization
350
350
static PNone setCompleterDelims (PythonModule self , TruffleString completerDelims ) {
351
- LocalData data = self .getInternalAttributes ();
351
+ LocalData data = self .getModuleState ();
352
352
data .completerDelims = completerDelims ;
353
353
return PNone .NONE ;
354
354
}
@@ -359,7 +359,7 @@ static PNone setCompleterDelims(PythonModule self, TruffleString completerDelims
359
359
abstract static class GetCompleterDelimsNode extends PythonBuiltinNode {
360
360
@ Specialization
361
361
static Object getCompleterDelims (PythonModule self ) {
362
- LocalData data = self .getInternalAttributes ();
362
+ LocalData data = self .getModuleState ();
363
363
return (data .completerDelims != null ) ? data .completerDelims : PNone .NONE ;
364
364
}
365
365
}
0 commit comments