|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the Apache 2.0 License. |
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | | -using System.Linq.Expressions; |
5 | | - |
6 | | -using System.Numerics; |
7 | 4 |
|
8 | 5 | using System; |
9 | 6 | using System.Collections; |
10 | 7 | using System.Collections.Generic; |
11 | 8 | using System.Diagnostics; |
12 | 9 | using System.Dynamic; |
13 | 10 | using System.IO; |
| 11 | +using System.Linq.Expressions; |
| 12 | +using System.Numerics; |
| 13 | +using System.Reflection; |
14 | 14 | using System.Runtime.CompilerServices; |
15 | 15 | using System.Runtime.InteropServices; |
16 | 16 | using System.Text; |
17 | 17 |
|
18 | | -using Microsoft.Scripting; |
19 | 18 | using Microsoft.Scripting.Runtime; |
20 | 19 | using Microsoft.Scripting.Utils; |
21 | 20 |
|
@@ -241,7 +240,7 @@ public virtual List readlines([DefaultParameterValue(null)]object hint) { |
241 | 240 | return res; |
242 | 241 | } |
243 | 242 |
|
244 | | - public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [DefaultParameterValue(0)]object whence) { |
| 243 | + public virtual BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { |
245 | 244 | throw UnsupportedOperation(context, "seek"); |
246 | 245 | } |
247 | 246 |
|
@@ -911,13 +910,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { |
911 | 910 | return res - _readBuf.Count + _readBufPos; |
912 | 911 | } |
913 | 912 |
|
914 | | - public BigInteger seek(double offset, [DefaultParameterValue(0)]object whence) { |
| 913 | + public BigInteger seek(double offset, [Optional]object whence) { |
915 | 914 | _checkClosed(); |
916 | 915 |
|
917 | 916 | throw PythonOps.TypeError("an integer is required"); |
918 | 917 | } |
919 | 918 |
|
920 | | - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [DefaultParameterValue(0)]object whence) { |
| 919 | + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { |
921 | 920 | int whenceInt = GetInt(whence); |
922 | 921 | if (whenceInt < 0 || whenceInt > 2) { |
923 | 922 | throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); |
@@ -1251,13 +1250,13 @@ public override BigInteger tell(CodeContext/*!*/ context) { |
1251 | 1250 | return res + _writeBuf.Count; |
1252 | 1251 | } |
1253 | 1252 |
|
1254 | | - public BigInteger seek(double offset, [DefaultParameterValue(0)]object whence) { |
| 1253 | + public BigInteger seek(double offset, [Optional]object whence) { |
1255 | 1254 | _checkClosed(); |
1256 | 1255 |
|
1257 | 1256 | throw PythonOps.TypeError("an integer is required"); |
1258 | 1257 | } |
1259 | 1258 |
|
1260 | | - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [DefaultParameterValue(0)]object whence) { |
| 1259 | + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { |
1261 | 1260 | int whenceInt = GetInt(whence); |
1262 | 1261 | if (whenceInt < 0 || whenceInt > 2) { |
1263 | 1262 | throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); |
@@ -1646,13 +1645,13 @@ public override BigInteger readinto(CodeContext/*!*/ context, object buf) { |
1646 | 1645 | return base.readinto(context, buf); |
1647 | 1646 | } |
1648 | 1647 |
|
1649 | | - public BigInteger seek(double offset, [DefaultParameterValue(0)]object whence) { |
| 1648 | + public BigInteger seek(double offset, [Optional]object whence) { |
1650 | 1649 | _checkClosed(); |
1651 | 1650 |
|
1652 | 1651 | throw PythonOps.TypeError("an integer is required"); |
1653 | 1652 | } |
1654 | 1653 |
|
1655 | | - public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [DefaultParameterValue(0)]object whence) { |
| 1654 | + public override BigInteger seek(CodeContext/*!*/ context, BigInteger pos, [Optional]object whence) { |
1656 | 1655 | int whenceInt = GetInt(whence); |
1657 | 1656 | if (whenceInt < 0 || whenceInt > 2) { |
1658 | 1657 | throw PythonOps.ValueError("invalid whence ({0}, should be 0, 1, or 2)", whenceInt); |
@@ -2289,13 +2288,13 @@ public override object detach(CodeContext/*!*/ context) { |
2289 | 2288 | return res; |
2290 | 2289 | } |
2291 | 2290 |
|
2292 | | - public BigInteger seek(double offset, [DefaultParameterValue(0)]object whence) { |
| 2291 | + public BigInteger seek(double offset, [Optional]object whence) { |
2293 | 2292 | _checkClosed(); |
2294 | 2293 |
|
2295 | 2294 | throw PythonOps.TypeError("an integer is required"); |
2296 | 2295 | } |
2297 | 2296 |
|
2298 | | - public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [DefaultParameterValue(0)]object whence) { |
| 2297 | + public override BigInteger seek(CodeContext/*!*/ context, BigInteger cookie, [Optional]object whence) { |
2299 | 2298 | int whenceInt = GetInt(whence); |
2300 | 2299 | if (closed) { |
2301 | 2300 | throw PythonOps.ValueError("tell on closed file"); |
@@ -3116,6 +3115,8 @@ private static int GetInt(object i, int defaultValue) { |
3116 | 3115 | } |
3117 | 3116 |
|
3118 | 3117 | private static int GetInt(object i, string msg, params object[] args) { |
| 3118 | + if (i == Missing.Value) return 0; |
| 3119 | + |
3119 | 3120 | int res; |
3120 | 3121 | if (TryGetInt(i, out res)) { |
3121 | 3122 | return res; |
|
0 commit comments