Skip to content

Commit

Permalink
Merge pull request #1758 from BCSharp/3.6
Browse files Browse the repository at this point in the history
Merge branch 'master' into 3.6
  • Loading branch information
slozier committed Dec 12, 2023
2 parents 26960dd + b7aaefa commit 3b824f0
Show file tree
Hide file tree
Showing 56 changed files with 401 additions and 270 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer 'AsSpan' over '
dotnet_diagnostic.CA1847.severity = none # CA1847: Use char literal for a single character lookup
dotnet_diagnostic.CA1852.severity = suggestion # CA1852: Seal internal types
dotnet_diagnostic.CA1859.severity = suggestion # CA1859: Use concrete types when possible for improved performance
dotnet_diagnostic.CA1861.severity = suggestion # CA1861: Avoid constant arrays as arguments
dotnet_diagnostic.CA2101.severity = suggestion # CA2101: Specify marshaling for P/Invoke string arguments
dotnet_diagnostic.CA2201.severity = none # CA2201: Do not raise reserved exception types
dotnet_diagnostic.CA2208.severity = suggestion # CA2208: Instantiate argument exceptions correctly
Expand Down
21 changes: 16 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Prerequisites

The issue tracker is used to report bugs and request new features, NOT to ask questions.
The issue tracker is used to report bugs and request new features, **NOT** to ask questions.

Questions should be posted in [Discussions](https://github.com/IronLanguages/ironpython3/discussions/categories/q-a) or to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.
Expand All @@ -19,10 +19,21 @@ https://ironpython.groups.io/g/users.
2. [Second Step]
3. [and so on...]

**Expected behavior:** [What you expected to happen]
**Expected behavior:**

**Actual behavior:** [What actually happened]
[What you expected to happen]

### Versions
**Actual behavior:**

You can get this information from executing `ipy -VV`.
[What actually happened]

### Version Information

If you are using the `ipy` console program, provide output of executing `ipy -VV`. If it is a local build, provide also the git hash of the commit used to build IronPython. In either case, provide the type of the operating system used.

If you are using the IronPython engine embedded in a .NET application, provide the version number of the NuGet package used (or if it is a local build, the git hash of the commit used to build IronPython), and the following info:

* .NET platform used (choice from: .NET, .NET Core, .NET Framework, Mono, Unity, Xamarin),
* Version of the .NET platform used,
* Operating system used,
* Value of `sys.version`, from imported module `sys`.
11 changes: 2 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-20.04, macos-latest]
os: [windows-latest, ubuntu-latest, macos-latest]

steps:
- name: Install tools
if: matrix.os == 'ubuntu-20.04'
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get -yq install mono-vbnc dos2unix
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.1.x'
- name: Setup .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
Expand All @@ -48,9 +44,6 @@ jobs:
- name: Test (net462)
run: ./make.ps1 -frameworks net462 test-all
shell: pwsh
- name: Test (netcoreapp2.1)
run: ./make.ps1 -frameworks netcoreapp2.1 test-all
shell: pwsh
- name: Test (netcoreapp3.1)
run: ./make.ps1 -frameworks netcoreapp3.1 test-all
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
displayName: Linux (Ubuntu)
timeoutInMinutes: 180
pool:
vmImage: ubuntu-20.04
vmImage: ubuntu-latest
steps:
- template: Build/steps.yml
parameters:
Expand Down
9 changes: 2 additions & 7 deletions Build/After.targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
</Choose>

<PropertyGroup>
<_TargetFramework>$(TargetFramework)</_TargetFramework>
<_TargetFramework Condition=" $(TargetFramework.EndsWith('-windows')) ">$(TargetFramework.Substring(0, $(TargetFramework.IndexOf('-windows'))))</_TargetFramework>
<_TargetFramework>$(TargetFramework.Replace('-windows', ''))</_TargetFramework>
<MainStageDir>$(StageDir)\$(_TargetFramework)</MainStageDir>
<MainStageDir Condition=" '$(StoreInDLLs)' == 'true' ">$(StageDir)\$(_TargetFramework)\DLLs</MainStageDir>
<UnsignedItems>@(StageItem)</UnsignedItems>
Expand All @@ -44,9 +43,5 @@
<Copy SourceFiles="$(UnsignedItems)" DestinationFolder="$(MainStageDir)" />
</Target>

<Target Name="_StoreInDLLs" Condition=" '$(StoreInDLLs)' == 'true' ">
<Move SourceFiles="@(StageItem)" DestinationFolder="$(TargetDir)%(StageItem.RecursiveDir)DLLs" />
</Target>

<Target Name="Stage" DependsOnTargets="_LateStage;_MainStage;_StoreInDLLs" />
<Target Name="Stage" DependsOnTargets="_LateStage;_MainStage" />
</Project>
6 changes: 0 additions & 6 deletions Build/steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ steps:
Write-Host ("##vso[task.setvariable variable=PackageVersion;isSecret=false;isOutput=true;]$PackageVersion")
displayName: Grab Package Version
- task: UseDotNet@2
displayName: Install .NET Core 2.1 runtime for testing
inputs:
packageType: 'runtime'
version: '2.1.x'

- task: UseDotNet@2
displayName: Install .NET Core 3.1 runtime for testing
inputs:
Expand Down
2 changes: 0 additions & 2 deletions IronPython.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB
Build\net462.props = Build\net462.props
Build\net6.0-windows.props = Build\net6.0-windows.props
Build\net6.0.props = Build\net6.0.props
Build\netcoreapp2.1.props = Build\netcoreapp2.1.props
Build\netcoreapp3.1.props = Build\netcoreapp3.1.props
Build\netstandard2.0.props = Build\netstandard2.0.props
Build\steps.yml = Build\steps.yml
Build\Tasks.Targets = Build\Tasks.Targets
Expand Down
13 changes: 4 additions & 9 deletions Package/nuget/IronPython.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ This package contains the IronPython interpreter engine.</description>
<group targetFramework="netstandard2.0">
<dependency id="DynamicLanguageRuntime" version="1.3.4" />
<dependency id="System.Memory" version="4.5.5" />
<dependency id="System.Text.Encoding.CodePages" version="4.6.0" />
<dependency id="Microsoft.Win32.Registry" version="4.5.0" />
<dependency id="Mono.Unix" version="7.1.0-final.1.21458.1" />
</group>
<group targetFramework="netcoreapp3.1">
<dependency id="DynamicLanguageRuntime" version="1.3.4" />
<dependency id="System.Text.Encoding.CodePages" version="4.7.0" />
<dependency id="Microsoft.Win32.Registry" version="4.7.0" />
<dependency id="Mono.Unix" version="7.1.0-final.1.21458.1" />
</group>
Expand All @@ -41,9 +36,9 @@ This package contains the IronPython interpreter engine.</description>
</dependencies>
</metadata>
<files>
<file src="**\IronPython*.dll" target="lib" exclude="**\IronPythonTest.dll;**\DLLs\*.dll;netcoreapp2.1\**\*;net7.0*\**\*" />
<file src="**\IronPython*.pdb" target="lib" exclude="**\IronPythonTest.pdb;**\DLLs\*.pdb;netcoreapp2.1\**\*;net7.0*\**\*" />
<file src="**\IronPython*.xml" target="lib" exclude="**\IronPythonTest.xml;**\DLLs\*.xml;netcoreapp2.1\**\*;net7.0*\**\*" />
<file src="**\IronPython*.dll" target="lib" exclude="**\IronPythonTest.dll;**\DLLs\*.dll;netcoreapp3.1\**\*;net7.0*\**\*;net8.0*\**\*" />
<file src="**\IronPython*.pdb" target="lib" exclude="**\IronPythonTest.pdb;**\DLLs\*.pdb;netcoreapp3.1\**\*;net7.0*\**\*;net8.0*\**\*" />
<file src="**\IronPython*.xml" target="lib" exclude="**\IronPythonTest.xml;**\DLLs\*.xml;netcoreapp3.1\**\*;net7.0*\**\*;net8.0*\**\*" />
<file src="LICENSE" />
<file src="..\..\..\nuget\README.md" target="" />
<file src="..\..\..\..\Documentation\logo.png" target="" />
Expand Down
2 changes: 1 addition & 1 deletion Package/zip/Zip.Packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<MakeDir Directories="$(PackageDir)" Condition="!Exists('$(PackageDir)')"/>

<ItemGroup>
<ZipFiles Include="$(StageDir)\**\*.*" Exclude="$(StageDir)\README.md;$(StageDir)\**\*.pdb;$(StageDir)\netstandard2.0\**\*;$(StageDir)\netcoreapp2.1\**\*;$(StageDir)\net7.0*\**\*" />
<ZipFiles Include="$(StageDir)\**\*.*" Exclude="$(StageDir)\README.md;$(StageDir)\**\*.pdb;$(StageDir)\netstandard2.0\**\*;$(StageDir)\netcoreapp3.1\**\*;$(StageDir)\net7.0*\**\*;$(StageDir)\net8.0*\**\*" />
<ZipFiles Include="README.md" Link="$(MSBuildThisFileDirectory)README.md" />
<ZipFiles Include="scripts/Enter-IronPythonEnvironment.ps1" Link="$(RootDir)Src\Scripts\Enter-IronPythonEnvironment.ps1" />
<ZipFiles Include="scripts/Install-IronPython.ps1" Link="$(RootDir)Src\Scripts\Install-IronPython.ps1" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ Binaries of IronPython 3 can be downloaded from the [release page](https://githu
See the [building document](Documentation/building.md). Since the main development is on Windows, bugs on other platforms may inadvertently be introduced - please report them!

## Supported Platforms
IronPython 3 targets .NET Framework 4.6.2, .NET Standard 2.0, .NET Core 3.1 and .NET 6.0. The support for .NET and .NET Core follow the lifecycle defined on [.NET and .NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
IronPython 3 targets .NET Framework 4.6.2, .NET Standard 2.0 and .NET 6.0. The support for .NET and .NET Core follow the lifecycle defined on [.NET and .NET Core Support Policy](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
6 changes: 1 addition & 5 deletions Src/IronPython.Modules/IronPython.Modules.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;netcoreapp3.1;netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
<BaseAddress>885063680</BaseAddress>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -33,10 +33,6 @@
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
</ItemGroup>

Expand Down
26 changes: 13 additions & 13 deletions Src/IronPython.Modules/IterTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,11 @@ public class zip_longest : IEnumerator {

[PythonType]
public class product : IterBase {
public product(params object[] iterables) {
InnerEnumerator = Yielder(ArrayUtils.ConvertAll(iterables, x => new PythonList(PythonOps.GetEnumerator(x))));
public product(CodeContext context, params object[] iterables) {
InnerEnumerator = Yielder(ArrayUtils.ConvertAll(iterables, x => new PythonList(context, PythonOps.GetEnumerator(x))));
}

public product([ParamDictionary]IDictionary<object, object> paramDict, params object[] iterables) {
public product(CodeContext context, [ParamDictionary]IDictionary<object, object> paramDict, params object[] iterables) {
object repeat;
int iRepeat = 1;
if (paramDict.TryGetValue("repeat", out repeat)) {
Expand All @@ -785,7 +785,7 @@ public class product : IterBase {
PythonList[] finalIterables = new PythonList[iterables.Length * iRepeat];
for (int i = 0; i < iRepeat; i++) {
for (int j = 0; j < iterables.Length; j++) {
finalIterables[i * iterables.Length + j] = new PythonList(iterables[j]);
finalIterables[i * iterables.Length + j] = new PythonList(context, iterables[j]);
}
}
InnerEnumerator = Yielder(finalIterables);
Expand Down Expand Up @@ -840,8 +840,8 @@ public class product : IterBase {
public class combinations : IterBase {
private readonly PythonList _data;

public combinations(object iterable, object r) {
_data = new PythonList(iterable);
public combinations(CodeContext context, object iterable, object r) {
_data = new PythonList(context, iterable);

InnerEnumerator = Yielder(GetR(r, _data));
}
Expand Down Expand Up @@ -910,8 +910,8 @@ public class combinations : IterBase {
public class combinations_with_replacement : IterBase {
private readonly PythonList _data;

public combinations_with_replacement(object iterable, object r) {
_data = new PythonList(iterable);
public combinations_with_replacement(CodeContext context, object iterable, object r) {
_data = new PythonList(context, iterable);

InnerEnumerator = Yielder(GetR(r, _data));
}
Expand Down Expand Up @@ -979,14 +979,14 @@ public class combinations_with_replacement : IterBase {
public class permutations : IterBase {
private readonly PythonList _data;

public permutations(object iterable) {
_data = new PythonList(iterable);
public permutations(CodeContext context, object iterable) {
_data = new PythonList(context, iterable);

InnerEnumerator = Yielder(_data.Count);
}

public permutations(object iterable, object r) {
_data = new PythonList(iterable);
public permutations(CodeContext context, object iterable, object r) {
_data = new PythonList(context, iterable);

InnerEnumerator = Yielder(GetR(r, _data));
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ public class starmap : IterBase {
objargs[i] = args[i];
}
} else {
PythonList argsList = new PythonList(PythonOps.GetEnumerator(iter.Current));
PythonList argsList = new PythonList(context, PythonOps.GetEnumerator(iter.Current));
objargs = ArrayUtils.ToArray(argsList);
}

Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_datetime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ public datetime(DateTime dt, tzinfo? tzinfo)

public double timestamp() {
if (tzinfo is null) {
return PythonTime.TicksToTimestamp(_dateTime.Ticks);
return PythonTime.TicksToTimestamp(_dateTime.ToUniversalTime().Ticks);
}
else {
return (this - new datetime(new DateTime(1970, 1, 1), timezone.utc)).total_seconds();
Expand Down
8 changes: 4 additions & 4 deletions Src/IronPython.Modules/_signal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public static partial class PythonSignal {
//Negative Scenarios
if (signalnum < 1 || signalnum > 22) {
throw PythonOps.ValueError("signal number out of range");
} else if (!GetPythonSignalState(context).PySignalToPyHandler.ContainsKey(signalnum)) {
} else if (GetPythonSignalState(context).PySignalToPyHandler.TryGetValue(signalnum, out object value)) {
//Default
return value;
} else {
//Handles the special case of SIG_IGN. This is not really a signal,
//but CPython returns null for it any ways
return null;
} else {
//Default
return GetPythonSignalState(context).PySignalToPyHandler[signalnum];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/_ssl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public class _SSLContext {

public PythonList get_ca_certs(CodeContext context, bool binary_form = false) {
if (binary_form) throw new NotImplementedException(nameof(binary_form));
return new PythonList(_cert_store.Cast<X509Certificate2>().Select(c => CertificateToPython(context, c)));
return PythonList.FromEnumerable(_cert_store.Cast<X509Certificate2>().Select(c => CertificateToPython(context, c)));
}

public void load_verify_locations(CodeContext context, object cafile = null, string capath = null, object cadata = null) {
Expand Down
2 changes: 1 addition & 1 deletion Src/IronPython.Modules/grp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class struct_group : PythonTuple {

private static struct_group Make(IntPtr pwd) {
group g = (group)Marshal.PtrToStructure(pwd, typeof(group));
return new struct_group(g.gr_name, g.gr_passwd, g.gr_gid, new PythonList(MarshalStringArray(g.gr_mem)));
return new struct_group(g.gr_name, g.gr_passwd, g.gr_gid, PythonList.FromEnumerable(MarshalStringArray(g.gr_mem)));
}

private static IEnumerable<string> MarshalStringArray(IntPtr arrayPtr) {
Expand Down
5 changes: 2 additions & 3 deletions Src/IronPython.Modules/nt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1829,13 +1829,12 @@ public static void utime(CodeContext context, object? path, [ParamDictionary, No

public static int write(CodeContext/*!*/ context, int fd, [NotNone] IBufferProtocol data) {
try {
using var buffer = data.GetBuffer();
PythonContext pythonContext = context.LanguageContext;
var streams = pythonContext.FileManager.GetStreams(fd);
using var buffer = data.GetBuffer();
var bytes = buffer.AsReadOnlySpan();
if (!streams.WriteStream.CanWrite) throw PythonOps.OSError(9, "Bad file descriptor");

return streams.Write(bytes);
return streams.Write(buffer);
} catch (Exception e) {
throw ToPythonException(e);
}
Expand Down
24 changes: 19 additions & 5 deletions Src/IronPython.Modules/time.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Threading;

using IronPython.Runtime;
using IronPython.Runtime.Exceptions;
using IronPython.Runtime.Operations;
using IronPython.Runtime.Types;

Expand Down Expand Up @@ -106,18 +107,31 @@ public static string asctime(CodeContext/*!*/ context, [NotNone] PythonTuple tim

public static double perf_counter() => clock();

public static double process_time() => Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds;

public static string ctime(CodeContext/*!*/ context)
=> asctime(context, localtime());

public static string ctime(CodeContext/*!*/ context, object? seconds)
=> asctime(context, localtime(seconds));

public static object get_clock_info([NotNone] string name) {
public static object get_clock_info(CodeContext/*!*/ context, [NotNone] string name) {
// TODO: Fill with correct values
if (name == "monotonic")
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", false }, { "implementation", "Stopwatch.GetTimestamp" }, { "monotonic", true }, { "resolution", 0.015625 } });

throw new NotImplementedException();
switch (name) {
case "monotonic":
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", false }, { "implementation", "Stopwatch.GetTimestamp" }, { "monotonic", true }, { "resolution", 0.015625 } });
case "perf_counter":
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", false }, { "implementation", "Stopwatch.ElapsedTicks" }, { "monotonic", true }, { "resolution", 1e-7 } });
case "process_time":
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", false }, { "implementation", "Process.TotalProcessorTime" }, { "monotonic", true }, { "resolution", 1e-7 } });
case "clock":
PythonOps.Warn(context, PythonExceptions.DeprecationWarning, "time.clock has been deprecated in Python 3.3 and will be removed from Python 3.8: use time.perf_counter or time.process_time instead");
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", false }, { "implementation", "Stopwatch.ElapsedTicks" }, { "monotonic", true }, { "resolution", 1e-7 } });
case "time":
return new SimpleNamespace(new Dictionary<string, object?> { { "adjustable", true }, { "implementation", "DateTime.Now" }, { "monotonic", false }, { "resolution", 0.015625 } });
default:
throw PythonOps.ValueError("unknown clock");
}
}

public static void sleep(double tm) {
Expand Down
4 changes: 2 additions & 2 deletions Src/IronPython.Modules/xxsubtype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public spamlist()
: base() {
}

public spamlist(object sequence)
: base(sequence) {
public spamlist(CodeContext context, object sequence)
: base(context, sequence) {
}

private int _state;
Expand Down
Loading

0 comments on commit 3b824f0

Please sign in to comment.