@@ -29,8 +29,8 @@ public class PythonTuple : IList, IList<object?>, ICodeFormattable, IExpressionS
2929
3030 internal static readonly PythonTuple EMPTY = new PythonTuple ( ) ;
3131
32- public PythonTuple ( [ AllowNull ] object o ) {
33- _data = MakeItems ( o ) ;
32+ public PythonTuple ( CodeContext context , [ AllowNull ] object o ) {
33+ _data = MakeItems ( context , o ) ;
3434 }
3535
3636 protected PythonTuple ( object ? [ ] items ) {
@@ -55,19 +55,19 @@ public static PythonTuple __new__(CodeContext context, [NotNone] PythonType cls)
5555 if ( cls == TypeCache . PythonTuple ) {
5656 return EMPTY ;
5757 } else {
58- if ( ! ( cls . CreateInstance ( context ) is PythonTuple tupObj ) ) throw PythonOps . TypeError ( "{0} is not a subclass of tuple" , cls ) ;
58+ if ( cls . CreateInstance ( context ) is not PythonTuple tupObj ) throw PythonOps . TypeError ( "{0} is not a subclass of tuple" , cls ) ;
5959 return tupObj ;
6060 }
6161 }
6262
6363 public static PythonTuple __new__ ( CodeContext context , [ NotNone ] PythonType cls , object ? sequence ) {
64- if ( sequence == null ) return new PythonTuple ( sequence ) ; // this will throw the proper exception
64+ if ( sequence == null ) return new PythonTuple ( context , sequence ) ; // this will throw the proper exception
6565
6666 if ( cls == TypeCache . PythonTuple ) {
6767 if ( sequence . GetType ( ) == typeof ( PythonTuple ) ) return ( PythonTuple ) sequence ;
68- return new PythonTuple ( sequence ) ;
68+ return new PythonTuple ( context , sequence ) ;
6969 } else {
70- if ( ! ( cls . CreateInstance ( context , sequence ) is PythonTuple tupObj ) ) throw PythonOps . TypeError ( "{0} is not a subclass of tuple" , cls ) ;
70+ if ( cls . CreateInstance ( context , sequence ) is not PythonTuple tupObj ) throw PythonOps . TypeError ( "{0} is not a subclass of tuple" , cls ) ;
7171 return tupObj ;
7272 }
7373 }
@@ -115,15 +115,15 @@ public int count(object? obj) {
115115
116116 internal static PythonTuple Make ( object o ) {
117117 if ( o is PythonTuple t ) return t ;
118- return new PythonTuple ( o ) ;
118+ return new PythonTuple ( DefaultContext . Default , o ) ;
119119 }
120120
121121 internal static PythonTuple MakeTuple ( params object ? [ ] items ) {
122122 if ( items . Length == 0 ) return EMPTY ;
123- return new PythonTuple ( items ) ;
123+ return new PythonTuple ( DefaultContext . Default , items ) ;
124124 }
125125
126- private static object ? [ ] MakeItems ( object ? o ) {
126+ private static object ? [ ] MakeItems ( CodeContext context , object ? o ) {
127127 var t = o ? . GetType ( ) ;
128128 // Only use fast paths if we have an exact tuple/list, otherwise use iter
129129 if ( t == typeof ( PythonTuple ) ) {
@@ -142,7 +142,7 @@ internal static PythonTuple MakeTuple(params object?[] items) {
142142 PerfTrack . NoteEvent ( PerfTrack . Categories . OverAllocate , "TupleOA: " + PythonOps . GetPythonTypeName ( o ) ) ;
143143
144144 var l = new List < object ? > ( ) ;
145- IEnumerator i = PythonOps . GetEnumerator ( o ) ;
145+ IEnumerator i = PythonOps . GetEnumerator ( context , o ) ;
146146 while ( i . MoveNext ( ) ) {
147147 l . Add ( i . Current ) ;
148148 }
@@ -315,8 +315,8 @@ public IEnumerator GetEnumerator() {
315315 }
316316
317317 public object __getnewargs__ ( ) {
318- // Call "new Tuple ()" to force result to be a Tuple (otherwise, it could possibly be a Tuple subclass)
319- return PythonTuple . MakeTuple ( new PythonTuple ( this ) ) ;
318+ // Call "MakeTuple ()" to force result to be specifically a Tuple (otherwise, it could possibly be a Tuple subclass)
319+ return PythonTuple . MakeTuple ( _data ) ;
320320 }
321321
322322 #region IEnumerable<object> Members
0 commit comments