Skip to content

Commit a579491

Browse files
committed
Eliminate contextless PythonTuple constructor
1 parent 9d6fa23 commit a579491

File tree

15 files changed

+30
-30
lines changed

15 files changed

+30
-30
lines changed

src/core/IronPython.Modules/IterTools.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public class product : IterBase {
763763
private PythonTuple[] tuples;
764764

765765
public product(CodeContext context, [NotNone] params object[] iterables) {
766-
tuples = ArrayUtils.ConvertAll(iterables, x => new PythonTuple(PythonOps.GetEnumerator(x)));
766+
tuples = ArrayUtils.ConvertAll(iterables, x => new PythonTuple(context, PythonOps.GetEnumerator(x)));
767767
InnerEnumerator = Yielder(tuples);
768768
}
769769

@@ -788,7 +788,7 @@ public product(CodeContext context, [ParamDictionary] IDictionary<object, object
788788
tuples = new PythonTuple[iterables.Length * iRepeat];
789789
for (int i = 0; i < iRepeat; i++) {
790790
for (int j = 0; j < iterables.Length; j++) {
791-
tuples[i * iterables.Length + j] = new PythonTuple(iterables[j]);
791+
tuples[i * iterables.Length + j] = new PythonTuple(context, iterables[j]);
792792
}
793793
}
794794
InnerEnumerator = Yielder(tuples);

src/core/IronPython.Modules/_collections.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) {
961961
int res;
962962
CompareUtil.Push(this);
963963
try {
964-
res = ((IStructuralEquatable)new PythonTuple(this)).GetHashCode(comparer);
964+
res = ((IStructuralEquatable)new PythonTuple(DefaultContext.Default, this)).GetHashCode(comparer);
965965
} finally {
966966
CompareUtil.Pop(this);
967967
}

src/core/IronPython.Modules/nt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ public PythonTuple __reduce__() {
13891389

13901390
return MakeTuple(
13911391
DynamicHelpers.GetPythonTypeFromType(typeof(stat_result)),
1392-
MakeTuple(new PythonTuple(this), timeDict)
1392+
MakeTuple(new PythonTuple(DefaultContext.Default, this), timeDict)
13931393
);
13941394
}
13951395
}

src/core/IronPython.Modules/resource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private struct_rusage(object?[] sequence) : base(sequence) {
245245
throw PythonOps.TypeError("resource.struct_rusage() takes a {0}-sequence ({1}-sequence given)", n_sequence_fields, __len__());
246246
}
247247

248-
private struct_rusage(object o) : base(o) {
248+
private struct_rusage(object o) : base(DefaultContext.Default, o) {
249249
if (__len__() != n_sequence_fields)
250250
throw PythonOps.TypeError("resource.struct_rusage() takes a {0}-sequence ({1}-sequence given)", n_sequence_fields, __len__());
251251
}

src/core/IronPython.Modules/time.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ internal struct_time(int year, int month, int day, int hour, int minute, int sec
512512
}
513513

514514
internal struct_time(PythonTuple sequence)
515-
: base(sequence) {
515+
: base(DefaultContext.Default, sequence) {
516516
}
517517

518518
public static struct_time __new__(CodeContext context, [NotNone] PythonType cls, int year, int month, int day, int hour, int minute, int second, int dayOfWeek, int dayOfYear, int isDst) {

src/core/IronPython/Runtime/ClrModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ private static void SortModules(List<string> modules) {
11301130
/// All times are expressed in the same unit of measure as DateTime.Ticks
11311131
/// </summary>
11321132
public static PythonTuple GetProfilerData(CodeContext/*!*/ context, bool includeUnused = false) {
1133-
return new PythonTuple(Profiler.GetProfiler(context.LanguageContext).GetProfile(includeUnused));
1133+
return new PythonTuple(DefaultContext.Default, Profiler.GetProfiler(context.LanguageContext).GetProfile(includeUnused));
11341134
}
11351135

11361136
/// <summary>

src/core/IronPython/Runtime/Exceptions/PythonExceptions.BaseException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static object __new__([NotNone] PythonType/*!*/ cls, [NotNone] params obj
9090
} else {
9191
res = (BaseException)Activator.CreateInstance(cls.UnderlyingSystemType, cls)!;
9292
}
93-
res._args = new PythonTuple(args);
93+
res._args = new PythonTuple(DefaultContext.Default, args);
9494
return res;
9595
}
9696

src/core/IronPython/Runtime/Operations/PythonOps.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ internal static bool TryInvokeLengthHint(CodeContext context, object? sequence,
10001000
List<object?> largs;
10011001

10021002
if (argsTuple != null && args.Length == names.Length) {
1003-
if (!(argsTuple is PythonTuple tuple)) tuple = new PythonTuple(argsTuple);
1003+
if (!(argsTuple is PythonTuple tuple)) tuple = new PythonTuple(DefaultContext.Default, argsTuple);
10041004

10051005
largs = new List<object?>(tuple);
10061006
largs.AddRange(args);
@@ -1813,7 +1813,7 @@ public static void DictUpdate(CodeContext context, PythonDictionary dict, object
18131813
/// LIST_TO_TUPLE
18141814
/// </summary>
18151815
[EditorBrowsable(EditorBrowsableState.Never)]
1816-
public static PythonTuple ListToTuple(PythonList list) => new PythonTuple(list);
1816+
public static PythonTuple ListToTuple(PythonList list) => new PythonTuple(DefaultContext.Default, list);
18171817

18181818
/// <summary>
18191819
/// SET_ADD

src/core/IronPython/Runtime/PythonFunction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public PythonTuple __defaults__ {
139139
get {
140140
if (_defaults.Length == 0) return null;
141141

142-
return new PythonTuple(_defaults);
142+
return new PythonTuple(DefaultContext.Default, _defaults);
143143
}
144144
set {
145145
_defaults = value == null ? [] : value.ToArray();

src/core/IronPython/Runtime/PythonList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) {
13021302
int res;
13031303
CompareUtil.Push(this);
13041304
try {
1305-
res = ((IStructuralEquatable)new PythonTuple(this)).GetHashCode(comparer);
1305+
res = ((IStructuralEquatable)new PythonTuple(DefaultContext.Default, this)).GetHashCode(comparer);
13061306
} finally {
13071307
CompareUtil.Pop(this);
13081308
}

0 commit comments

Comments
 (0)