@@ -1849,13 +1849,13 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
18491849 int nlocals , int stacksize , int flags ,
18501850 String codestring , PTuple constants , PTuple names ,
18511851 PTuple varnames , PTuple freevars , PTuple cellvars ,
1852- String filename , String name , int firstlineno ,
1852+ Object filename , Object name , int firstlineno ,
18531853 String lnotab ) {
18541854 return factory ().createCode (cls , argcount , kwonlyargcount ,
18551855 nlocals , stacksize , flags ,
18561856 toBytes (codestring ), constants .getArray (), names .getArray (),
18571857 varnames .getArray (), freevars .getArray (), cellvars .getArray (),
1858- filename , name , firstlineno ,
1858+ getStringArg ( filename ), getStringArg ( name ) , firstlineno ,
18591859 toBytes (lnotab ));
18601860 }
18611861
@@ -1864,7 +1864,7 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
18641864 int nlocals , int stacksize , int flags ,
18651865 PBytes codestring , PTuple constants , PTuple names ,
18661866 PTuple varnames , PTuple freevars , PTuple cellvars ,
1867- PString filename , PString name , int firstlineno ,
1867+ Object filename , Object name , int firstlineno ,
18681868 PBytes lnotab ,
18691869 @ Cached ("create()" ) SequenceStorageNodes .ToByteArrayNode toByteArrayNode ) {
18701870 byte [] codeBytes = toByteArrayNode .execute (codestring .getSequenceStorage ());
@@ -1874,7 +1874,7 @@ Object call(PythonClass cls, int argcount, int kwonlyargcount,
18741874 nlocals , stacksize , flags ,
18751875 codeBytes , constants .getArray (), names .getArray (),
18761876 varnames .getArray (), freevars .getArray (), cellvars .getArray (),
1877- filename . getValue ( ), name . getValue ( ), firstlineno ,
1877+ getStringArg ( filename ), getStringArg ( name ), firstlineno ,
18781878 lnotabBytes );
18791879 }
18801880
@@ -1889,6 +1889,16 @@ Object call(Object cls, Object argcount, Object kwonlyargcount,
18891889 throw raise (SystemError , "bad argument to internal function" );
18901890 }
18911891
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+
18921902 @ TruffleBoundary
18931903 private static byte [] toBytes (String data ) {
18941904 return data .getBytes ();
0 commit comments