@@ -87,20 +87,19 @@ public static object __import__(CodeContext/*!*/ context, [NotNull]string name,
8787
8888 [ Documentation ( "abs(number) -> number\n \n Return the absolute value of the argument." ) ]
8989 public static object abs ( CodeContext /*!*/ context , object ? o ) {
90- if ( o is int ) return Int32Ops . Abs ( ( int ) o ) ;
91- if ( o is long ) return Int64Ops . Abs ( ( long ) o ) ;
92- if ( o is double ) return DoubleOps . Abs ( ( double ) o ) ;
93- if ( o is bool ) return ( ( ( bool ) o ) ? 1 : 0 ) ;
90+ if ( o is int i32 ) return Int32Ops . Abs ( i32 ) ;
91+ if ( o is long i64 ) return Int64Ops . Abs ( i64 ) ;
92+ if ( o is double d ) return DoubleOps . Abs ( d ) ;
93+ if ( o is bool b ) return ( b ? 1 : 0 ) ;
9494
95- if ( o is BigInteger ) return BigIntegerOps . __abs__ ( ( BigInteger ) o ) ;
96- if ( o is Complex ) return ComplexOps . Abs ( ( Complex ) o ) ;
95+ if ( o is BigInteger bi ) return BigIntegerOps . Abs ( bi ) ;
96+ if ( o is Complex z ) return ComplexOps . Abs ( z ) ;
9797
98- object value ;
99- if ( PythonTypeOps . TryInvokeUnaryOperator ( context , o , "__abs__" , out value ) ) {
98+ if ( PythonTypeOps . TryInvokeUnaryOperator ( context , o , "__abs__" , out object ? value ) ) {
10099 return value ;
101100 }
102101
103- throw PythonOps . TypeError ( "bad operand type for abs(): '{0}'" , PythonOps . GetPythonTypeName ( o ) ) ;
102+ throw PythonOps . TypeErrorForBadInstance ( "bad operand type for abs(): '{0}'" , o ) ;
104103 }
105104
106105 public static bool all ( CodeContext context , object ? x ) {
0 commit comments