@@ -161,6 +161,7 @@ public String getTRegexOption() {
161
161
162
162
public static final class TRegexCache {
163
163
164
+ private final Object originalPattern ;
164
165
private final String pattern ;
165
166
private final String flags ;
166
167
private final boolean binary ;
@@ -193,6 +194,7 @@ public static final class TRegexCache {
193
194
194
195
@ TruffleBoundary
195
196
public TRegexCache (Object pattern , int flags ) {
197
+ this .originalPattern = pattern ;
196
198
String patternStr ;
197
199
boolean binary = true ;
198
200
try {
@@ -379,7 +381,7 @@ private String getTRegexOptions(String encoding, PythonMethod pythonMethod, bool
379
381
}
380
382
381
383
@ TruffleBoundary
382
- public Object compile (PythonContext context , Object patternObject , PythonMethod method , boolean mustAdvance , TruffleString locale ) {
384
+ public Object compile (PythonContext context , PythonMethod method , boolean mustAdvance , TruffleString locale ) {
383
385
String encoding = isBinary () ? ENCODING_LATIN_1 : ENCODING_UTF_32 ;
384
386
String options = getTRegexOptions (encoding , method , mustAdvance , locale );
385
387
InteropLibrary lib = InteropLibrary .getUncached ();
@@ -393,7 +395,7 @@ public Object compile(PythonContext context, Object patternObject, PythonMethod
393
395
regexp = compiledRegex ;
394
396
}
395
397
} catch (RuntimeException e ) {
396
- throw handleCompilationError (e , patternObject , lib , context );
398
+ throw handleCompilationError (e , lib , context );
397
399
}
398
400
if (isLocaleSensitive ()) {
399
401
setLocaleSensitiveRegexp (method , mustAdvance , locale , regexp );
@@ -403,7 +405,7 @@ public Object compile(PythonContext context, Object patternObject, PythonMethod
403
405
return regexp ;
404
406
}
405
407
406
- private static RuntimeException handleCompilationError (RuntimeException e , Object patternObject , InteropLibrary lib , PythonContext context ) {
408
+ private RuntimeException handleCompilationError (RuntimeException e , InteropLibrary lib , PythonContext context ) {
407
409
try {
408
410
if (lib .isException (e )) {
409
411
if (lib .getExceptionType (e ) == ExceptionType .PARSE_ERROR ) {
@@ -418,7 +420,7 @@ private static RuntimeException handleCompilationError(RuntimeException e, Objec
418
420
int position = sourceSection .getCharIndex ();
419
421
PythonModule module = context .lookupBuiltinModule (BuiltinNames .T__SRE );
420
422
Object errorConstructor = PyObjectLookupAttr .getUncached ().execute (null , module , T_ERROR );
421
- PBaseException exception = (PBaseException ) CallNode .getUncached ().execute (errorConstructor , reason , patternObject , position );
423
+ PBaseException exception = (PBaseException ) CallNode .getUncached ().execute (errorConstructor , reason , originalPattern , position );
422
424
return PRaiseNode .getUncached ().raiseExceptionObject (exception );
423
425
}
424
426
}
@@ -508,7 +510,7 @@ Object localeNonSensitive(Object pattern, PythonMethod method, boolean mustAdvan
508
510
if (tRegex != null ) {
509
511
return tRegex ;
510
512
} else {
511
- return tRegexCache .compile (getContext (), pattern , method , mustAdvance , null );
513
+ return tRegexCache .compile (getContext (), method , mustAdvance , null );
512
514
}
513
515
}
514
516
@@ -525,7 +527,7 @@ Object localeSensitive(Object pattern, PythonMethod method, boolean mustAdvance,
525
527
if (tRegex != null ) {
526
528
return tRegex ;
527
529
} else {
528
- return tRegexCache .compile (getContext (), pattern , method , mustAdvance , locale );
530
+ return tRegexCache .compile (getContext (), method , mustAdvance , locale );
529
531
}
530
532
}
531
533
0 commit comments