@@ -368,22 +368,29 @@ abstract static class ReprNode extends PythonUnaryBuiltinNode {
368
368
static String repr (VirtualFrame frame , PArray self ,
369
369
@ Cached ("create(__REPR__)" ) LookupAndCallUnaryNode reprNode ,
370
370
@ Cached ConditionProfile isEmptyProfile ,
371
+ @ Cached ConditionProfile isUnicodeProfile ,
371
372
@ Cached CastToJavaStringNode cast ,
373
+ @ Cached ToUnicodeNode toUnicodeNode ,
372
374
@ Cached ArrayNodes .GetValueNode getValueNode ) {
373
375
StringBuilder sb = PythonUtils .newStringBuilder ();
374
376
PythonUtils .append (sb , "array('" );
375
377
PythonUtils .append (sb , self .getFormatStr ());
376
378
PythonUtils .append (sb , '\'' );
377
379
if (isEmptyProfile .profile (self .getLength () != 0 )) {
378
- PythonUtils .append (sb , ", [" );
379
- for (int i = 0 ; i < self .getLength (); i ++) {
380
- if (i > 0 ) {
381
- PythonUtils .append (sb , ", " );
380
+ if (isUnicodeProfile .profile (self .getFormat () == BufferFormat .UNICODE )) {
381
+ PythonUtils .append (sb , ", " );
382
+ PythonUtils .append (sb , cast .execute (reprNode .executeObject (frame , toUnicodeNode .call (frame , self ))));
383
+ } else {
384
+ PythonUtils .append (sb , ", [" );
385
+ for (int i = 0 ; i < self .getLength (); i ++) {
386
+ if (i > 0 ) {
387
+ PythonUtils .append (sb , ", " );
388
+ }
389
+ Object value = getValueNode .execute (self , i );
390
+ PythonUtils .append (sb , cast .execute (reprNode .executeObject (frame , value )));
382
391
}
383
- Object value = getValueNode .execute (self , i );
384
- PythonUtils .append (sb , cast .execute (reprNode .executeObject (frame , value )));
392
+ PythonUtils .append (sb , ']' );
385
393
}
386
- PythonUtils .append (sb , ']' );
387
394
}
388
395
PythonUtils .append (sb , ')' );
389
396
return PythonUtils .sbToString (sb );
0 commit comments