@@ -1849,13 +1849,13 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
1849
1849
int nlocals , int stacksize , int flags ,
1850
1850
String codestring , PTuple constants , PTuple names ,
1851
1851
PTuple varnames , PTuple freevars , PTuple cellvars ,
1852
- String filename , String name , int firstlineno ,
1852
+ Object filename , Object name , int firstlineno ,
1853
1853
String lnotab ) {
1854
1854
return factory ().createCode (cls , argcount , kwonlyargcount ,
1855
1855
nlocals , stacksize , flags ,
1856
1856
toBytes (codestring ), constants .getArray (), names .getArray (),
1857
1857
varnames .getArray (), freevars .getArray (), cellvars .getArray (),
1858
- filename , name , firstlineno ,
1858
+ getStringArg ( filename ), getStringArg ( name ) , firstlineno ,
1859
1859
toBytes (lnotab ));
1860
1860
}
1861
1861
@@ -1864,7 +1864,7 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
1864
1864
int nlocals , int stacksize , int flags ,
1865
1865
PBytes codestring , PTuple constants , PTuple names ,
1866
1866
PTuple varnames , PTuple freevars , PTuple cellvars ,
1867
- PString filename , PString name , int firstlineno ,
1867
+ Object filename , Object name , int firstlineno ,
1868
1868
PBytes lnotab ,
1869
1869
@ Cached ("create()" ) SequenceStorageNodes .ToByteArrayNode toByteArrayNode ) {
1870
1870
byte [] codeBytes = toByteArrayNode .execute (codestring .getSequenceStorage ());
@@ -1874,7 +1874,7 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
1874
1874
nlocals , stacksize , flags ,
1875
1875
codeBytes , constants .getArray (), names .getArray (),
1876
1876
varnames .getArray (), freevars .getArray (), cellvars .getArray (),
1877
- filename . getValue ( ), name . getValue ( ), firstlineno ,
1877
+ getStringArg ( filename ), getStringArg ( name ), firstlineno ,
1878
1878
lnotabBytes );
1879
1879
}
1880
1880
@@ -1889,6 +1889,16 @@ Object call(Object cls, Object argcount, Object kwonlyargcount,
1889
1889
throw raise (SystemError , "bad argument to internal function" );
1890
1890
}
1891
1891
1892
+ private String getStringArg (Object arg ) {
1893
+ if (arg instanceof String ) {
1894
+ return (String ) arg ;
1895
+ } else if (arg instanceof PString ) {
1896
+ return ((PString ) arg ).toString ();
1897
+ } else {
1898
+ throw raise (SystemError , "bad argument to internal function" );
1899
+ }
1900
+ }
1901
+
1892
1902
@ TruffleBoundary
1893
1903
private static byte [] toBytes (String data ) {
1894
1904
return data .getBytes ();
0 commit comments