Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core/IronPython.Modules/binascii.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,19 @@ static void to_hex(char ch, StringBuilder s, int index) {

#region hqx

// TODO: removed in 3.11
public static object a2b_hqx(object? data) {
throw new NotImplementedException();
}
// TODO: removed in 3.11
public static object rledecode_hqx(object? data) {
throw new NotImplementedException();
}
// TODO: removed in 3.11
public static object rlecode_hqx(object? data) {
throw new NotImplementedException();
}
// TODO: removed in 3.11
public static object b2a_hqx(object? data) {
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/IronPython.Modules/cmath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static Complex acos([NotNone] object x) {
double real = Math.Acos(0.5 * (a - b));
double imag = Math.Log(c + Math.Sqrt(c + 1) * Math.Sqrt(c - 1));

return new Complex(real, num.Imaginary >= 0 ? imag : -imag);
return new Complex(real, DoubleOps.IsNegative(num.Imaginary) ? imag : -imag);
}

//asin(x) = -i*ln( i*x + (1-x*x)^1/2)
Expand Down
13 changes: 7 additions & 6 deletions src/core/IronPython.StdLib/lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ def test_processor(self):

def setUp(self):
self.save_version = sys.version
self.save_mercurial = sys._mercurial
self.save_git = sys._git
self.save_platform = sys.platform

def tearDown(self):
sys.version = self.save_version
sys._mercurial = self.save_mercurial
sys._git = self.save_git
sys.platform = self.save_platform

@unittest.skipIf(sys.implementation.name == "ironpython", "not compatible with IronPython platform changes")
def test_sys_version(self):
# Old test.
for input, output in (
Expand All @@ -78,7 +79,7 @@ def test_sys_version(self):
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
):
# branch and revision are not "parsed", but fetched
# from sys._mercurial. Ignore them
# from sys._git. Ignore them
(name, version, branch, revision, buildno, builddate, compiler) \
= platform._sys_version(input)
self.assertEqual(
Expand Down Expand Up @@ -125,10 +126,10 @@ def test_sys_version(self):
sys_versions.items():
sys.version = version_tag
if subversion is None:
if hasattr(sys, "_mercurial"):
del sys._mercurial
if hasattr(sys, "_git"):
del sys._git
else:
sys._mercurial = subversion
sys._git = subversion
if sys_platform is not None:
sys.platform = sys_platform
self.assertEqual(platform.python_implementation(), info[0])
Expand Down
14 changes: 3 additions & 11 deletions src/core/IronPython.StdLib/lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
import unittest
import venv

# pip currently requires ssl support, so we ensure we handle
# it being missing (http://bugs.python.org/issue19744)
try:
import ssl
except ImportError:
ssl = None

skipInVenv = unittest.skipIf(sys.prefix != sys.base_prefix,
'Test not appropriate in a venv')

Expand Down Expand Up @@ -307,18 +300,17 @@ def test_explicit_no_pip(self):
self.run_with_capture(venv.create, self.env_dir, with_pip=False)
self.assert_pip_not_installed()

@failsOnWindows
def test_devnull_exists_and_is_empty(self):
def test_devnull(self):
# Fix for issue #20053 uses os.devnull to force a config file to
# appear empty. However http://bugs.python.org/issue20541 means
# that doesn't currently work properly on Windows. Once that is
# fixed, the "win_location" part of test_with_pip should be restored
self.assertTrue(os.path.exists(os.devnull))
with open(os.devnull, "rb") as f:
self.assertEqual(f.read(), b"")

self.assertTrue(os.path.exists(os.devnull))

# Requesting pip fails without SSL (http://bugs.python.org/issue19744)
@unittest.skipIf(ssl is None, ensurepip._MISSING_SSL_MESSAGE)
def test_with_pip(self):
rmtree(self.env_dir)
with EnvironmentVarGuard() as envvars:
Expand Down
10 changes: 10 additions & 0 deletions src/core/IronPython/Runtime/Operations/FloatOps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -638,6 +639,15 @@ internal static bool IsNegativeZero(double value) {
return (value == 0.0) && double.IsNegativeInfinity(1.0 / value);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static bool IsNegative(double value) {
#if NET7_0_OR_GREATER
return double.IsNegative(value);
#else
return value < 0.0 || IsNegativeZero(value);
#endif
}

internal static int Sign(double value) {
if (value == 0.0) {
return double.IsPositiveInfinity(1.0 / value) ? 1 : -1;
Expand Down
4 changes: 2 additions & 2 deletions src/executables/IronPython.Console/ipy-mono.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
BASEDIR=$(dirname "$0")
BASEDIR=$(dirname $(readlink -f "$0"))
ABS_PATH=$(cd "$BASEDIR"; pwd)
mono "$ABS_PATH/ipy.exe" "$@"
mono "$ABS_PATH/ipy.exe" "$@"
39 changes: 19 additions & 20 deletions tests/IronPython.Tests/Cases/CPythonCasesManifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Ignore=true
RunCondition=$(IS_OSX)
Ignore=true

[CPython.test_aifc] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_aifc] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=ImportError: No module named audioop

Expand All @@ -115,7 +115,7 @@ IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/489
[CPython.test_ast]
Ignore=true

[CPython.test_asynchat] # Module will be removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_asynchat] # Module has been removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=NOT $(IS_OSX) # TODO: debug

[CPython.test_asyncio.test_base_events]
Expand Down Expand Up @@ -151,20 +151,20 @@ Ignore=true
[CPython.test_asyncio.test_windows_utils]
Ignore=true

[CPython.test_asyncore] # Module will be removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_asyncore] # Module has been removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true

[CPython.test_atexit]
Ignore=true

[CPython.test_audioop] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_audioop] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=ImportError: No module named audioop

[CPython.test_bigmem]
Ignore=true

[CPython.test_binhex]
[CPython.test_binhex] # Module has been removed in 3.11
Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/673

[CPython.test_builtin] # IronPython.test_builtin_stdlib
Expand All @@ -188,11 +188,11 @@ Timeout=600000 # 10 minute timeout
Ignore=true
Reason=ImportError: No module named _testcapi

[CPython.test_cgi] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_cgi] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=NOT $(IS_MONO)
Reason=SystemError: The stream does not support seeking

[CPython.test_cgitb] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_cgitb] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true

[CPython.test_class] # IronPython.test_class_stdlib
Expand Down Expand Up @@ -293,7 +293,7 @@ Ignore=true
Ignore=true
Reason=ImportError: No module named _lsprof

[CPython.test_crypt] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_crypt] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=ImportError: No module named _crypt

Expand Down Expand Up @@ -478,7 +478,7 @@ Reason=Blocking

[CPython.test_httpservers]
Ignore=true
Reason=Blocking
Reason=Blocking # works?

[CPython.test_idle]
Ignore=true
Expand Down Expand Up @@ -592,7 +592,7 @@ Ignore=true
[CPython.test_modulefinder]
Ignore=true

[CPython.test_msilib] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_msilib] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=ImportError: No module named _msi

Expand All @@ -616,12 +616,12 @@ Reason=ImportError: No module named _multiprocessing
Ignore=true
Reason=ImportError: No module named _multiprocessing

[CPython.test_nis] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_nis] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=$(IS_POSIX)
Ignore=true
Reason=unittest.case.SkipTest: No module named 'nis'

[CPython.test_nntplib] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_nntplib] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true # currently failing during CI
RunCondition=NOT $(IS_NETCOREAPP) # https://github.com/IronLanguages/ironpython3/issues/1058

Expand All @@ -641,7 +641,7 @@ Reason=unittest.case.SkipTest: os.openpty() not available.
Ignore=true
Reason=AttributeError: 'module' object has no attribute 'isatty'

[CPython.test_ossaudiodev] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_ossaudiodev] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=unittest.case.SkipTest: No module named 'ossaudiodev'

Expand Down Expand Up @@ -682,7 +682,7 @@ Reason=StackOverflowException
Ignore=true
Reason=StackOverflowException

[CPython.test_pipes] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_pipes] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=$(IS_POSIX)
Ignore=true
Reason=unittest.case.SkipTest: pipes module only works on posix
Expand All @@ -694,8 +694,7 @@ Ignore=true
Ignore=true

[CPython.test_platform]
Ignore=true
Reason=AttributeError: 'module' object has no attribute '_mercurial'
RunCondition=NOT $(IS_OSX)

[CPython.test_poll]
RunCondition=$(IS_POSIX)
Expand Down Expand Up @@ -802,7 +801,7 @@ Ignore=true
[CPython.test_site]
Ignore=true

[CPython.test_smtpd] # Module will be removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_smtpd] # Module has been removed in 3.12 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true

[CPython.test_smtplib]
Expand All @@ -817,7 +816,7 @@ Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/122
[CPython.test_source_encoding]
IsolationLevel=ENGINE # source file in a non-UTF-8 encoding

[CPython.test_spwd] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_spwd] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=$(IS_POSIX)

[CPython.test_sqlite]
Expand Down Expand Up @@ -858,7 +857,7 @@ IsolationLevel=PROCESS
Redirect=true
Ignore=true

[CPython.test_sunau] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_sunau] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
Ignore=true
Reason=ImportError: No module named audioop

Expand Down Expand Up @@ -908,7 +907,7 @@ Ignore=true
Ignore=true
Reason=ImportError: No module named '_tkinter'

[CPython.test_telnetlib] # Module will be removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
[CPython.test_telnetlib] # Module has been removed in 3.13 - https://github.com/IronLanguages/ironpython3/issues/1352
RunCondition=NOT $(IS_LINUX) # TODO: debug

[CPython.test_tempfile]
Expand Down
14 changes: 10 additions & 4 deletions tests/IronPython.Tests/Cases/CaseExecuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.ExceptionServices;
using System.Text.RegularExpressions;
using System.Threading;

Expand Down Expand Up @@ -290,7 +291,9 @@ private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource sourc
engine.GetSysModule().SetVariable("argv", PythonList.FromArrayNoCopy(new object[] { source.Path }));
var compiledCode = source.Compile(new IronPython.Compiler.PythonCompilerOptions() { ModuleName = "__main__" });

int res = 0;
ExceptionDispatchInfo exceptionInfo = null;

int res = -1;
int maxStackSize = 2 * 1024 * 1024; // 2 MiB
var thread = new Thread(() => {
try {
Expand All @@ -301,12 +304,12 @@ private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource sourc
#pragma warning disable SYSLIB0006 // 'Thread.ResetAbort is not supported and throws PlatformNotSupportedException.'
Thread.ResetAbort();
#pragma warning restore SYSLIB0006
} catch (Exception ex) when (ex.GetPythonException() is object pex) {
if (DynamicHelpers.GetPythonType(pex).Name == "SkipTest") {
} catch (Exception ex) {
if (ex.GetPythonException() is object pex && DynamicHelpers.GetPythonType(pex).Name == "SkipTest") {
NUnit.Framework.TestContext.Progress.WriteLine($"Test {testcase.Name} skipped: {pex}");
res = 0;
} else {
throw;
exceptionInfo = ExceptionDispatchInfo.Capture(ex);
}
}
}, maxStackSize) {
Expand All @@ -324,6 +327,9 @@ private int GetResult(TestInfo testcase, ScriptEngine engine, ScriptSource sourc
NUnit.Framework.TestContext.Error.WriteLine($"{testcase.Name} timed out after {testcase.Options.Timeout / 1000.0} seconds.");
return -1;
}

exceptionInfo?.Throw();

return res;
} finally {
Environment.CurrentDirectory = cwd;
Expand Down