@@ -225,12 +225,13 @@ public static string Ascii(CodeContext/*!*/ context, object? o) {
225225 return StringOps . AsciiEncode ( Repr ( context , o ) ) ;
226226 }
227227
228- public static string Repr ( CodeContext /*!*/ context , object ? o ) {
228+ internal static object GetReprObject ( CodeContext /*!*/ context , object ? o ) {
229229 if ( o == null ) return "None" ;
230230
231+ // Fast tracks
231232 if ( o is string s ) return StringOps . __repr__ ( s ) ;
232- if ( o is int ) return Int32Ops . __repr__ ( ( int ) o ) ;
233- if ( o is long ) return ( ( long ) o ) . ToString ( ) ;
233+ if ( o is int i32 ) return Int32Ops . __repr__ ( i32 ) ;
234+ if ( o is BigInteger bi ) return BigIntegerOps . __repr__ ( bi ) ;
234235
235236 // could be a container object, we need to detect recursion, but only
236237 // for our own built-in types that we're aware of. The user can setup
@@ -267,6 +268,9 @@ public static string Repr(CodeContext/*!*/ context, object? o) {
267268 throw PythonOps . TypeError ( "__repr__ returned non-string (got '{0}' from type '{1}')" , PythonOps . GetPythonTypeName ( repr ) , PythonOps . GetPythonTypeName ( o ) ) ;
268269 }
269270
271+ public static string Repr ( CodeContext /*!*/ context , object ? o )
272+ => GetReprObject ( context , o ) . ToString ( ) ?? "<unknown>" ;
273+
270274 public static string Format ( CodeContext /*!*/ context , object ? argValue , string formatSpec ) {
271275 object ? res ;
272276 // call __format__ with the format spec (__format__ is defined on object, so this always succeeds)
0 commit comments