@@ -23,6 +23,7 @@ namespace IronPython.Modules {
2323 public static class PythonOperator {
2424 public const string __doc__ = "Provides programmatic access to various operators (addition, accessing members, etc...)" ;
2525
26+ [ PythonType ]
2627 public sealed class attrgetter : ICodeFormattable {
2728 private readonly object [ ] _names ;
2829
@@ -40,31 +41,32 @@ public attrgetter([NotNone] params object[] attrs) {
4041 public PythonTuple __reduce__ ( ) => PythonTuple . MakeTuple ( DynamicHelpers . GetPythonType ( this ) , PythonTuple . MakeTuple ( _names ) ) ;
4142
4243 [ SpecialName ]
43- public object Call ( CodeContext context , object param ) {
44+ public object ? Call ( CodeContext context , object ? param ) {
4445 if ( _names . Length == 1 ) {
4546 return GetOneAttr ( context , param , _names [ 0 ] ) ;
4647 }
4748
48- object [ ] res = new object [ _names . Length ] ;
49+ object ? [ ] res = new object [ _names . Length ] ;
4950 for ( int i = 0 ; i < _names . Length ; i ++ ) {
5051 res [ i ] = GetOneAttr ( context , param , _names [ i ] ) ;
5152 }
5253 return PythonTuple . MakeTuple ( res ) ;
5354 }
5455
55- private static object GetOneAttr ( CodeContext context , object param , object val ) {
56+ private static object ? GetOneAttr ( CodeContext context , object ? param , object val ) {
5657 if ( val is not string s ) {
5758 throw PythonOps . TypeError ( "attribute name must be string" ) ;
5859 }
5960 int dotPos = s . IndexOf ( '.' ) ;
6061 if ( dotPos >= 0 ) {
61- object nextParam = GetOneAttr ( context , param , s . Substring ( 0 , dotPos ) ) ;
62+ object ? nextParam = GetOneAttr ( context , param , s . Substring ( 0 , dotPos ) ) ;
6263 return GetOneAttr ( context , nextParam , s . Substring ( dotPos + 1 ) ) ;
6364 }
6465 return PythonOps . GetBoundAttr ( context , param , s ) ;
6566 }
6667 }
6768
69+ [ PythonType ]
6870 public sealed class itemgetter : ICodeFormattable {
6971 private readonly object ? [ ] _items ;
7072
@@ -82,7 +84,7 @@ public itemgetter([NotNone] params object?[] items) {
8284 public PythonTuple __reduce__ ( ) => PythonTuple . MakeTuple ( DynamicHelpers . GetPythonType ( this ) , PythonTuple . MakeTuple ( _items ) ) ;
8385
8486 [ SpecialName ]
85- public object Call ( CodeContext /*!*/ context , object param ) {
87+ public object ? Call ( CodeContext /*!*/ context , object ? param ) {
8688 if ( _items . Length == 1 ) {
8789 return PythonOps . GetIndex ( context , param , _items [ 0 ] ) ;
8890 }
0 commit comments