Repository navigation
Differences between versions
Note
For differences between IronPython 2 and 3 see Upgrading from IronPython2. This page describes breaking changes between releases of IronPython 3.
IronPython 3.4 incorporates the Python Standard Library released with CPython 3.4 and generally the language features of Python 3.4, however some language features from later Python versions may be implemented as well, especially if they are backward-compatible, that is, they do not introduce incompatibilities with Python scripts expecting Python 3.4. However, sometimes this is not desirable or possible to maintain, usually due to a bug that needed to be fixed, increased compatibility with existing 3rd party Python packages, or a general need of the maintenance of the IronPython code base. To facilitate upgrades between IronPython 3 versions, this document keeps track of such breaking changes, starting with 3.4.3. Changes in earlier releases aren't covered.
IronPython targets .NET Framework 4.6.2, .NET 8, .NET 10 and .NET Standard 2.0. The .NET 6 target was removed. Applications on .NET 6 or 7 that reference the NuGet package get the .NET Standard 2.0 assemblies.
In a number of cases, public methods or constructors have an additional parameter of type CodeContext added (as the first parameter). To have the same behaviour as in an earlier version that did not have this parameter, use IronPython.Runtime.DefaultContext.Default as the first argument, or provide appropriate code context if preferred.
For instance, the signature of the constructor of PythonTuple (which is the class implementing the Python tuple type) after 3.4.2 has changed from:
public PythonTuple([AllowNull]object o)to
public PythonTuple(CodeContext context, [AllowNull]object o)The C# code that was using this constructor now must provide a context as the first argument. This context may be used to iterate the object provided as the second argument to initialize the tuple. To have the same behaviour as in the version 3.4.2 and before, use IronPython.Runtime.DefaultContext.Default as argument, although this may not always be the optimal context to use.
The PythonOps.Call* APIs are obsolete and will be removed in a future release. Please use the PythonCalls.Call* APIs directly instead.
The PythonOps.IOError and PythonOps.WindowsError methods are obsolete. Use PythonOps.OSError instead.
Those static methods in ArrayOps power operators + and * on System.Array (as the first argument). They retain their existing functionality as concatenation and repetition, but will change their meaning to element-wise addition and multiplication in the future. Hence they are marked as obsolete; migrate to own implementation of concatenation and repetition.
-
MemoryBufferProtocolWrapperis now generic. To expose aMemory<byte>to Python, usenew MemoryBufferProtocolWrapper<byte>(memory). - The public APIs have nullable annotations, so C# code with nullable reference types enabled may get new warnings.
Other public types that implement Python modules and builtins have also been changed, renamed or removed. They aren't meant to be used directly by hosting code.
A host that provides its own PlatformAdaptationLayer gets its modules through PalImporter, a sys.path_hooks entry placed after the hook for FileFinder. Directories that exist on disk are handled by FileFinder, so PalImporter only handles directories that exist only in the PAL. Unlike before:
- A PAL directory that doesn't exist when it's first looked up isn't found later, until its
sys.path_importer_cacheentry is cleared. - Modules are found in
sys.pathorder. Previously, a module on disk always won over one in the PAL.
This section only covers changes that are specific to IronPython. Each release also has bug fixes that bring IronPython's behaviour closer to CPython's. These can affect code that depended on the old behaviour, but they aren't listed here. See the release notes for the full list of changes.
The import statement and __import__ go through importlib._bootstrap, as in CPython. Imports now behave like CPython's, and in particular a module file added to a directory after an import from that directory may not be found until importlib.invalidate_caches() is called. Other changes:
- When a .NET namespace and a namespace package (PEP 420, a directory without
__init__.py) have the same name, the .NET namespace is imported. - Source files of other DLR languages (e.g. Ruby) can no longer be imported.
- If a .NET value in the runtime's globals (
ScriptRuntime.Globals) changes after it was imported, the nextimportreturns the new value only after another assembly is loaded orimportlib.invalidate_caches()is called.
The __name__ and repr of a .NET namespace use its full name, e.g. System.Collections instead of Collections.
In this version, any use of those operators on System.Array as the first argument generates FutureWarning. The behavoiur of the operators stays the same (concatenation and repetition, like for lists), but will change in a future IronPython release to element-wise addition and multiplication, to better match the semantics of N-dimensional arrays like in NumPy.
Not released yet.
Still looking for more? Browse the Discussions tab, where you can ask questions to the IronPython community.
π IronPython