@@ -1803,14 +1803,28 @@ public Object asciiGeneric(VirtualFrame frame, Object obj,
1803
1803
public abstract static class RoundNode extends PythonBuiltinNode {
1804
1804
@ Specialization (limit = "1" )
1805
1805
Object round (VirtualFrame frame , Object x , @ SuppressWarnings ("unused" ) PNone n ,
1806
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("x" ) PythonObjectLibrary lib ) {
1807
- return lib .lookupAndCallSpecialMethod (x , frame , __ROUND__ );
1806
+ @ CachedLibrary ("x" ) PythonObjectLibrary lib ,
1807
+ @ CachedLibrary (limit = "1" ) PythonObjectLibrary methodLib ,
1808
+ @ Cached BranchProfile noRound ) {
1809
+ Object method = lib .lookupAttributeOnType (x , __ROUND__ );
1810
+ if (method == PNone .NO_VALUE ) {
1811
+ noRound .enter ();
1812
+ throw raise (TypeError , ErrorMessages .TYPE_DOESNT_DEFINE_METHOD , x , __ROUND__ );
1813
+ }
1814
+ return methodLib .callUnboundMethod (method , frame , x );
1808
1815
}
1809
1816
1810
1817
@ Specialization (guards = "!isNoValue(n)" , limit = "1" )
1811
1818
Object round (VirtualFrame frame , Object x , Object n ,
1812
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("x" ) PythonObjectLibrary lib ) {
1813
- return lib .lookupAndCallSpecialMethod (x , frame , __ROUND__ , n );
1819
+ @ CachedLibrary ("x" ) PythonObjectLibrary lib ,
1820
+ @ CachedLibrary (limit = "1" ) PythonObjectLibrary methodLib ,
1821
+ @ Cached BranchProfile noRound ) {
1822
+ Object method = lib .lookupAttributeOnType (x , __ROUND__ );
1823
+ if (method == PNone .NO_VALUE ) {
1824
+ noRound .enter ();
1825
+ throw raise (TypeError , ErrorMessages .TYPE_DOESNT_DEFINE_METHOD , x , __ROUND__ );
1826
+ }
1827
+ return methodLib .callUnboundMethod (method , frame , x , n );
1814
1828
}
1815
1829
}
1816
1830
0 commit comments