@@ -133,7 +133,7 @@ boolean doForeignObject(VirtualFrame frame, Object self,
133
133
return !lib .isNull (self );
134
134
}
135
135
} catch (UnsupportedMessageException e ) {
136
- throw raise (TypeError , "foreign.__bool__ should return a boolean value " );
136
+ throw raise (AttributeError , "' foreign' object has no attribute '__bool__' " );
137
137
}
138
138
}
139
139
}
@@ -172,7 +172,7 @@ public long len(Object self,
172
172
} catch (UnsupportedMessageException e ) {
173
173
// fall through
174
174
}
175
- throw raise (AttributeError , "'foreign' object has no attribute 'len '" );
175
+ throw raise (AttributeError , "'foreign' object has no attribute '__len__ '" );
176
176
}
177
177
}
178
178
@@ -563,13 +563,14 @@ protected Object doInteropCall(Object callee, Object[] arguments, @SuppressWarni
563
563
Object res = lib .instantiate (callee , convertedArgs );
564
564
return toPTypeNode .executeConvert (res );
565
565
} catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e ) {
566
- throw raise (PythonErrorType .TypeError , "invalid instantiation of foreign object %s()" , callee );
566
+ throw raise (PythonErrorType .TypeError , "invalid instantiation of foreign object" );
567
567
}
568
568
}
569
569
570
570
@ Fallback
571
- protected Object doGeneric (Object callee , @ SuppressWarnings ("unused" ) Object arguments , @ SuppressWarnings ("unused" ) Object keywords ) {
572
- throw raise (PythonErrorType .TypeError , "invalid instantiation of foreign object %s()" , callee );
571
+ @ SuppressWarnings ("unused" )
572
+ protected Object doGeneric (Object callee , Object arguments , Object keywords ) {
573
+ throw raise (PythonErrorType .TypeError , "invalid instantiation of foreign object" );
573
574
}
574
575
}
575
576
@@ -609,13 +610,14 @@ protected Object doInteropCall(VirtualFrame frame, Object callee, Object[] argum
609
610
}
610
611
}
611
612
} catch (ArityException | UnsupportedTypeException | UnsupportedMessageException e ) {
612
- throw raise (PythonErrorType .TypeError , "invalid invocation of foreign callable %s()" , callee );
613
+ throw raise (PythonErrorType .TypeError , "invalid invocation of foreign callable" );
613
614
}
614
615
}
615
616
616
617
@ Fallback
617
- protected Object doGeneric (Object callee , @ SuppressWarnings ("unused" ) Object arguments , @ SuppressWarnings ("unused" ) Object keywords ) {
618
- throw raise (PythonErrorType .TypeError , "invalid invocation of foreign callable %s()" , callee );
618
+ @ SuppressWarnings ("unused" )
619
+ protected Object doGeneric (Object callee , Object arguments , Object keywords ) {
620
+ throw raise (PythonErrorType .TypeError , "invalid invocation of foreign callable" );
619
621
}
620
622
621
623
public static CallNode create () {
@@ -640,16 +642,15 @@ abstract static class GetattrNode extends PythonBinaryBuiltinNode {
640
642
@ Child PForeignToPTypeNode toPythonNode = PForeignToPTypeNode .create ();
641
643
642
644
@ Specialization
643
- protected Object doIt (Object object , Object key ,
645
+ protected Object doIt (Object object , String member ,
644
646
@ CachedLibrary (limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)" ) InteropLibrary read ) {
645
647
try {
646
- String member = (String ) key ;
647
648
if (read .isMemberReadable (object , member )) {
648
649
return toPythonNode .executeConvert (read .readMember (object , member ));
649
650
}
650
651
} catch (UnknownIdentifierException | UnsupportedMessageException ignore ) {
651
652
}
652
- throw raise (PythonErrorType .AttributeError , "foreign object %s has no attribute %s " , object , key );
653
+ throw raise (PythonErrorType .AttributeError , "foreign object has no attribute '%s' " , member );
653
654
}
654
655
}
655
656
@@ -662,7 +663,7 @@ protected PNone doIt(Object object, String key, Object value,
662
663
try {
663
664
lib .writeMember (object , key , value );
664
665
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException e ) {
665
- throw raise (PythonErrorType .AttributeError , "foreign object %s has no attribute %s" , object , key );
666
+ throw raise (PythonErrorType .AttributeError , "foreign object has no attribute '%s'" , key );
666
667
}
667
668
return PNone .NONE ;
668
669
}
@@ -689,7 +690,7 @@ protected PNone doIt(Object object, String key,
689
690
try {
690
691
lib .removeMember (object , key );
691
692
} catch (UnknownIdentifierException | UnsupportedMessageException e ) {
692
- throw raise (PythonErrorType .AttributeError , "foreign object %s has no attribute %s" , object , key );
693
+ throw raise (PythonErrorType .AttributeError , "foreign object has no attribute '%s'" , key );
693
694
}
694
695
return PNone .NONE ;
695
696
}
@@ -717,7 +718,7 @@ protected Object doIt(Object object,
717
718
try {
718
719
return lib .getMembers (object );
719
720
} catch (UnsupportedMessageException e ) {
720
- throw raise ( TypeError , "The object '%s' claims to have members, but does not return them", object );
721
+ throw new IllegalStateException ( "foreign object claims to have members, but does not return them" );
721
722
}
722
723
} else {
723
724
return factory ().createList ();
@@ -735,7 +736,7 @@ protected Object doIt(Object object,
735
736
try {
736
737
return lib .asInt (object );
737
738
} catch (UnsupportedMessageException e ) {
738
- throw raise ( TypeError , "foreign value '%s' claims it fits into index-sized int, but doesn't" , object );
739
+ throw new IllegalStateException ( "foreign value claims it fits into index-sized int, but doesn't" );
739
740
}
740
741
}
741
742
throw raiseIndexError ();
@@ -761,7 +762,7 @@ protected Object doBool(VirtualFrame frame, Object object,
761
762
try {
762
763
return getCallStrNode ().executeObject (frame , lib .asBoolean (object ));
763
764
} catch (UnsupportedMessageException e ) {
764
- throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the appropriate unbox message" );
765
+ throw new IllegalStateException ("foreign object claims to be boxed, but does not support the appropriate unbox message" );
765
766
}
766
767
}
767
768
@@ -771,7 +772,7 @@ protected Object doStr(VirtualFrame frame, Object object,
771
772
try {
772
773
return getCallStrNode ().executeObject (frame , lib .asString (object ));
773
774
} catch (UnsupportedMessageException e ) {
774
- throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the appropriate unbox message" );
775
+ throw new IllegalStateException ("foreign object claims to be boxed, but does not support the appropriate unbox message" );
775
776
}
776
777
}
777
778
@@ -781,7 +782,7 @@ protected Object doLong(VirtualFrame frame, Object object,
781
782
try {
782
783
return getCallStrNode ().executeObject (frame , lib .asLong (object ));
783
784
} catch (UnsupportedMessageException e ) {
784
- throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the appropriate unbox message" );
785
+ throw new IllegalStateException ("foreign object claims to be boxed, but does not support the appropriate unbox message" );
785
786
}
786
787
}
787
788
@@ -791,7 +792,7 @@ protected Object doDouble(VirtualFrame frame, Object object,
791
792
try {
792
793
return getCallStrNode ().executeObject (frame , lib .asDouble (object ));
793
794
} catch (UnsupportedMessageException e ) {
794
- throw new IllegalStateException ("The object '%s' claims to be boxed, but does not support the appropriate unbox message" );
795
+ throw new IllegalStateException ("foreign object claims to be boxed, but does not support the appropriate unbox message" );
795
796
}
796
797
}
797
798
0 commit comments