@@ -87,20 +87,19 @@ public static object __import__(CodeContext/*!*/ context, [NotNull]string name,
87
87
88
88
[ Documentation ( "abs(number) -> number\n \n Return the absolute value of the argument." ) ]
89
89
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 ) ;
94
94
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 ) ;
97
97
98
- object value ;
99
- if ( PythonTypeOps . TryInvokeUnaryOperator ( context , o , "__abs__" , out value ) ) {
98
+ if ( PythonTypeOps . TryInvokeUnaryOperator ( context , o , "__abs__" , out object ? value ) ) {
100
99
return value ;
101
100
}
102
101
103
- throw PythonOps . TypeError ( "bad operand type for abs(): '{0}'" , PythonOps . GetPythonTypeName ( o ) ) ;
102
+ throw PythonOps . TypeErrorForBadInstance ( "bad operand type for abs(): '{0}'" , o ) ;
104
103
}
105
104
106
105
public static bool all ( CodeContext context , object ? x ) {
0 commit comments