Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Modernize import hook #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 163 commits into
base: upstream
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
663df73
reworked PythonException to simplify memory management, and enable .N…
lostmsu May 5, 2020
d45c39a
allows codecs to encode and decode thrown exceptions
lostmsu Feb 25, 2020
0d941c5
turned on CLR exception marshaling
lostmsu May 5, 2020
02cd234
revert to C# 7.3
lostmsu May 5, 2020
defb200
fixed Restore when not all exception fields are set
lostmsu May 5, 2020
945dc85
cleaned PythonException code up a bit
lostmsu May 5, 2020
3d95e60
remove unused overloads of FromPyErr
lostmsu May 5, 2020
d667998
capture exception on Exceptions.SetError, restore in ThrowLastAsClrEx…
lostmsu May 5, 2020
bec8b7d
fixed failure in ExceptionEncoded test case caused by ExceptionDispat…
lostmsu May 5, 2020
0961c94
added tests for __cause__/InnerException #893 #1098
lostmsu May 6, 2020
2cd8627
introduced StolenReference type
lostmsu May 14, 2020
e4c1b9b
prevent undebuggable StackOverflowException during exception interop
lostmsu May 29, 2020
81cd197
Merge branch 'master' into PR/ExceptionsImprovement
lostmsu Jun 22, 2020
3c0b737
README: added summary of new exception handling features
lostmsu Jun 22, 2020
0f33f71
disable implicit conversion from PyFloat to .NET integer types (fixes…
lostmsu Dec 31, 2020
5fd77b1
Add PythonEngine.Interrupt (#1337)
gpetrou Jan 21, 2021
7e7cbca
Disable implicit conversion from PyFloat to uint64 (#1362)
tminka Jan 21, 2021
32fdc9c
Disable implicit conversion from PyFloat to array index (#1363)
tminka Jan 21, 2021
92932fd
Better error messages for method argument mismatch and others (#1361)
tminka Jan 27, 2021
063a674
Added the ability to implement delegates with `ref` and `out` paramet…
tminka Jan 28, 2021
909ed1f
dropped net40 target from modern projects
lostmsu Nov 30, 2020
47e926e
use .NET Standard 2.0 platform detection features
lostmsu Dec 2, 2020
21683b3
drop NativeCodePage alltogether
lostmsu Dec 2, 2020
972c41d
WIP: use C# 9 function pointers for PInvoke
lostmsu Dec 4, 2020
51e5184
allow setting PythonDLL
lostmsu Dec 10, 2020
2498d47
always explicitly specify the way strings are marshaled
lostmsu Jan 22, 2021
70fc803
CI: figure out DLL name from environment
lostmsu Jan 22, 2021
28a5dab
use Roslyn preview in CI
lostmsu Jan 22, 2021
c75229a
fixed Linux and Mac DLL loaders breaking dll path
lostmsu Jan 22, 2021
a0a1dc1
correctly detect DLL on *nix when running from Python
lostmsu Jan 22, 2021
1b88783
Windows library loader: add support for hModule == 0
lostmsu Jan 22, 2021
2c1aaef
fix dll loading in tests
lostmsu Jan 22, 2021
39e41d0
mentiond PythonDLL in changelog
lostmsu Jan 22, 2021
17040fe
set PYDLL in AppVeyor
lostmsu Jan 22, 2021
b7410b6
revert automatically added 'm' suffix for *nix default dll name
lostmsu Jan 22, 2021
275cae9
specify full DLL name instead of PYVER in GH Actions
lostmsu Jan 22, 2021
b4cb37e
use Microsoft.Net.Compilers.Toolset instead of Microsoft.Net.Compilers
lostmsu Jan 23, 2021
f68e581
in CI MacOS python DLL has 'm' suffix
lostmsu Jan 23, 2021
cda604a
only set PYTHONNET_PYDLL for test runs from .NET
lostmsu Jan 23, 2021
3982892
workaround for pytest/clr module not preloading python C API library
lostmsu Jan 23, 2021
a6cbe20
addressed a few code comments
lostmsu Jan 26, 2021
9e5887c
Merge pull request #1365 from losttech/features/VersionIndependent
lostmsu Jan 28, 2021
1afae4c
Fix exception string (#1360)
filmor Jan 29, 2021
d86bf3c
ParameterInfo.Name needs to be checked for null before usage (#1375)
filmor Feb 4, 2021
6b2347a
monthly NuGet release previews (#1381)
lostmsu Feb 12, 2021
4da1954
Sign Runtime DLL with a strong name (#1382)
gpetrou Feb 13, 2021
b92d929
Replace clr module by loading through clr_loader
filmor Feb 13, 2021
fdb7144
Add Changelog entry
filmor Feb 14, 2021
f01a78c
Fix domain reload tests and activate them on macOS
filmor Feb 13, 2021
0d7e43a
Run tests on .NET Core
filmor Feb 13, 2021
67032ea
Vendor System.Drawing.Point for testing on .NET Core
filmor Feb 14, 2021
8bc458b
Use approximate comparison for single max/min value comparison
filmor Feb 14, 2021
d46fa1e
Adjust the import tests to use only commonly available deps
filmor Feb 14, 2021
f0011a5
Fix PythonTestRunner to work with new pytest setup
filmor Feb 14, 2021
c1a01b7
Drop references to the obsolete call
filmor Feb 14, 2021
6510ff7
Merge pull request #1373 from filmor/clr-loader
filmor Feb 14, 2021
fb083bb
Adjust setup.py for wheel building
filmor Feb 14, 2021
4c05417
enable manual preview release
lostmsu Feb 17, 2021
132b666
rename nuget preview release workflow
lostmsu Feb 17, 2021
0f5e781
NuGet Preview pipeline changes missed in https://github.com/pythonnet…
lostmsu Feb 17, 2021
1ab9cb1
simplify PyScope by delegating ownership to PyObject instance
lostmsu Jan 23, 2021
707ef36
Lossless encoders for IList<T>, IEnumerable<T> and ICollection<T> (#1…
koubaa Feb 18, 2021
d0d7616
ensure interned strings can not be referenced after InternString.Shut…
lostmsu Feb 21, 2021
83328d2
made InterruptTest more robust
lostmsu Feb 21, 2021
6db4373
added NuGet shields to README
lostmsu Feb 21, 2021
6f1219f
mentioned PythonDLL in README
lostmsu Feb 21, 2021
c4f2ad7
Adjust static libpython detection (#1396)
filmor Feb 22, 2021
c3fc7f0
allow comparing BorrowedReference to null
lostmsu Feb 19, 2021
60bb68c
removed unused Utf8Marshaler
lostmsu Feb 19, 2021
50834ba
introduced PyModule (inherits PyScope)
lostmsu Feb 19, 2021
ac68aab
minor fixes
lostmsu Feb 19, 2021
6f10641
PyImport test validate no initialization failures
lostmsu Feb 25, 2021
676fbb4
PyObject.Length raises an exception when object does not have a conce…
lostmsu Feb 25, 2021
5bcd708
Merge pull request #1391 from losttech/cleanup/21-02-19
filmor Feb 26, 2021
b2c15a4
ImportHook: verify __import__ was not updated before overwriting it w…
lostmsu Feb 25, 2021
fefa322
drop _PyObject_GetDictPtr and use PyObject_GenericGetDict instead
lostmsu Feb 25, 2021
908316f
ImportHook: drop dead code around clr_prefix
lostmsu Feb 26, 2021
f2dc8f1
Merge pull request #1400 from losttech/cleanup/21-02-25
lostmsu Feb 27, 2021
db765ca
suggest to set Runtime.PythonDLL when embedding in .NET
lostmsu Mar 8, 2021
4afa4bd
more info on Runtime.PythonDLL
lostmsu Mar 9, 2021
1e5338f
allow GIL state debugging; require GILState to be properly disposed
lostmsu Feb 24, 2021
483f192
try libdl.so.2 on Linux before libdl.so
lostmsu Mar 25, 2021
a2304dc
Merge pull request #1425 from losttech/bugs/libdl.so.2
filmor Mar 25, 2021
6e1eea6
TypeFlags is an enum
lostmsu Feb 22, 2021
486ad0a
use C# 9 everywhere by default
lostmsu Feb 22, 2021
95d5e35
added new class PyType to wrap Python type objects and enable new typ…
lostmsu Feb 22, 2021
6379221
reworked Enum marshaling
lostmsu Feb 20, 2021
a157fb4
added regression test for https://github.com/pythonnet/pythonnet/issu…
lostmsu Mar 30, 2021
957a3cb
disabled ability to register encoders for `System.Type`
lostmsu Mar 30, 2021
23527d1
disabled PythonRegisteredDecoder_NoStackOverflowOnSystemType test due…
lostmsu Mar 31, 2021
257a765
merge latest master
lostmsu Apr 9, 2021
c0fe430
reworked `PythonException`:
lostmsu Apr 9, 2021
e58411d
rum embedding tests before Python tests
lostmsu Apr 9, 2021
00653dc
PythonException.StackTrace is GIL-safe
lostmsu Apr 9, 2021
3433201
separate .Steal() and .StealNullable()
lostmsu Apr 11, 2021
95cc52f
can't test exception type when runtime is down
lostmsu Apr 11, 2021
63ad42c
PythonException: dispose intermediate values used in stack trace gene…
lostmsu Apr 11, 2021
faec7fc
Point users to Message property of PythonException
lostmsu Apr 11, 2021
dfc70f6
minor change in PythonEngine.With
lostmsu Apr 11, 2021
d976acf
simplified code of PythonException and added a lot more checks
lostmsu Apr 11, 2021
146ebf3
fixed type of reference in PyException_SetCause
lostmsu Apr 11, 2021
272687b
minor fixes to Converter.ToArray:
lostmsu Apr 11, 2021
2cd3f61
added a few debug checks to Exceptions.SetError
lostmsu Apr 11, 2021
e79f041
method binding failure now supports non-Python exception causes
lostmsu Apr 11, 2021
d068f36
XDecref now checks, that refcount is positive in debug builds
lostmsu Apr 11, 2021
4877fe7
fixed __cause__ on overload bind failure and array conversion
lostmsu Apr 11, 2021
ed594c1
cache PythonException message
lostmsu Apr 11, 2021
e5bce06
minor code cleanup
lostmsu Apr 11, 2021
6819e7b
improved handling of dict offset in object instances
lostmsu Apr 11, 2021
6679d1c
added a few debug checks
lostmsu Apr 11, 2021
dff75d2
do not call find_libpython as Python.Runtime can find it on its own
lostmsu Apr 11, 2021
0775458
Merge pull request #1440 from losttech/PR/No_find_libpyton_for_import…
filmor Apr 12, 2021
16f04e9
fixed __cause__ on overload bind failure and array conversion
lostmsu Apr 11, 2021
daccc43
Replaced magic offsets with per-type calculation
lostmsu Apr 12, 2021
db746aa
detect Py_TRACE_REFS at runtime and calculate object offsets accordingly
lostmsu Mar 26, 2021
33d771c
Re-enable the domain reload tests (#1404)
BadSingleton May 3, 2021
5ded48d
dispose all temporary objects in PyCheck_Iter_PyObject_IsIterable_Thr…
lostmsu May 14, 2021
21169db
use PyType instances instead of raw pointers in TypeManager type cach…
lostmsu Apr 2, 2021
67bd1c2
merge latest master
lostmsu May 15, 2021
2c62028
+ class diagram for ManagedType and subclasses
lostmsu May 23, 2021
91e98a2
added OverloadMapper to ManagedTypes class diagram
lostmsu May 23, 2021
88b19cf
refactored tp_dealloc in ExtensionType and descendants
lostmsu May 23, 2021
786b450
refactored tp_clear in ExtensionType and descendants into a virtual C…
lostmsu May 23, 2021
993707e
all Dealloc overrides simply duplicate Clear, so just call both from …
lostmsu May 23, 2021
7eac886
handle ProcessExit event to avoid Python crash when CLR (in particula…
lostmsu May 21, 2021
2e57b04
+ class diagram for ManagedType and subclasses
lostmsu May 23, 2021
539ce81
added OverloadMapper to ManagedTypes class diagram
lostmsu May 23, 2021
25e3864
refactored tp_dealloc in ExtensionType and descendants
lostmsu May 23, 2021
5bca333
refactored tp_clear in ExtensionType and descendants into a virtual C…
lostmsu May 23, 2021
7271d88
all Dealloc overrides simply duplicate Clear, so just call both from …
lostmsu May 23, 2021
4f3f648
fixup! merge latest master
SDEII May 29, 2021
c500a39
fixup! reworked `PythonException`:
lostmsu May 29, 2021
7d8f754
Merge pull request #1134 from losttech/PR/ExceptionsImprovement
lostmsu Jun 1, 2021
a321daa
(WIP) modernize the import hook
BadSingleton Jan 15, 2021
279b535
Add the loaded namespaces tracking
BadSingleton Jan 15, 2021
f92e95b
cleanup and changelog entry
BadSingleton Jan 15, 2021
afffc18
Fix a bug where clr wasn't in sys.modules after reload
BadSingleton Jan 18, 2021
d821c0f
Further refinements to setattr logic on ModuleObjects
BadSingleton Jan 19, 2021
e469a8a
fixups, add docs
BadSingleton Jan 20, 2021
685b972
merge fixup
BadSingleton Mar 4, 2021
be81364
(WIP) import hook in the pytohn module
BadSingleton Mar 10, 2021
73958ed
Revert "(WIP) import hook in the pytohn module"
BadSingleton Apr 12, 2021
e71a0ef
Import hook as a module, take 2
BadSingleton Apr 12, 2021
2af066d
fixup! Merge remote-tracking branch 'origin/master' into modernize-im…
BadSingleton Apr 12, 2021
bb490bf
fixup! fixup! Merge remote-tracking branch 'origin/master' into moder…
BadSingleton Apr 12, 2021
31ea876
Create a clr.loader module
BadSingleton Jun 1, 2021
c02d5c6
Test to test if the test passes
BadSingleton Jun 2, 2021
970a189
fix new exception usage
BadSingleton Jun 2, 2021
059605b
kick the build because I can't repro
BadSingleton Jun 2, 2021
ff170e9
Add Namespaces to the import hook only through AddReference
BadSingleton Jun 2, 2021
da051a9
Add a failing test for Unicode conversion
pkese Jun 8, 2021
1b6c6c0
Fix Python -> .Net unicode string conversion
pkese Jun 8, 2021
4674b5c
Add separate test for the initial problem (passing); disable failing …
pkese Jun 8, 2021
63de923
Review changes, update API usage
BadSingleton Jun 8, 2021
1629116
Use exclusively PyUnicode_DecodeUTF16 for .NET->Python string convers…
filmor Jun 9, 2021
df5ebc2
Activate UnicodeSurrogate test
filmor Jun 9, 2021
d084b2e
Apply suggested changes
pkese Jun 9, 2021
f061d28
Revert stuff that I don't understand
pkese Jun 9, 2021
49ccc1e
Apply code review suggestions
filmor Jun 11, 2021
12027ad
Merge pull request #1467 from pkese/master
lostmsu Jun 11, 2021
624f7e3
Merge remote-tracking branch 'upstream/master' into modernize-import-…
BadSingleton Jun 14, 2021
bd7e745
make PyModule_AddObject in line with CPython
BadSingleton Jun 14, 2021
46a85fe
take care of stragglers
BadSingleton Jun 15, 2021
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
29 changes: 22 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jobs:
build-test:
name: Build and Test
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 5
timeout-minutes: 7

strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
python: [3.6, 3.7, 3.8, 3.9]
python: ["3.6", "3.7", "3.8", "3.9"]
platform: [x64]
shutdown_mode: [Normal, Soft]

Expand Down Expand Up @@ -44,19 +44,34 @@ jobs:

- name: Build and Install
run: |
python setup.py configure
pip install -v .

- name: Python Tests
run: pytest
- name: Set Python DLL path (non Windows)
if: ${{ matrix.os != 'windows' }}
run: |
python -m pythonnet.find_libpython --export >> $GITHUB_ENV

- name: Set Python DLL path (Windows)
if: ${{ matrix.os == 'windows' }}
run: |
python -m pythonnet.find_libpython --export | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Embedding tests
run: dotnet test --runtime any-${{ matrix.platform }} src/embed_tests/
if: ${{ matrix.os != 'macos' }} # Not working right now, doesn't find libpython

- name: Python Tests (Mono)
if: ${{ matrix.os != 'windows' }}
run: pytest --runtime mono

- name: Python Tests (.NET Core)
run: pytest --runtime netcore

- name: Python Tests (.NET Framework)
if: ${{ matrix.os == 'windows' }}
run: pytest --runtime netfx

- name: Python tests run from .NET
run: dotnet test --runtime any-${{ matrix.platform }} src/python_tests_runner/
if: ${{ matrix.os == 'windows' }} # Not working for others right now

# TODO: Run perf tests
# TODO: Run mono tests on Windows?
60 changes: 60 additions & 0 deletions .github/workflows/nuget-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: NuGet Preview Release

on:
schedule:
- cron: "5 4 3 */1 *" # once a month, at 4:05 on 3rd
workflow_dispatch:

jobs:
release:
name: Release Preview
runs-on: ubuntu-latest
environment: NuGet
timeout-minutes: 10

env:
PYTHONNET_SHUTDOWN_MODE: Normal

steps:
- name: Get Date
run: |
echo "DATE_VER=$(date "+%Y-%m-%d")" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
architecture: x64

- name: Install dependencies
run: |
pip install --upgrade -r requirements.txt

- name: Build and Install
run: |
pip install -v .

- name: Python Tests
run: pytest
env:
PYTHONNET_PYDLL: libpython3.8.so

- name: Embedding tests
run: dotnet test --runtime any-ubuntu src/embed_tests/
env:
PYTHONNET_PYDLL: libpython3.8.so

- name: Pack
run: dotnet pack --configuration Release --version-suffix preview${{env.DATE_VER}} --output "Release-Preview"

- name: Publish NuGet
run: dotnet nuget push --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_MONTHLY }} Release-Preview/*.nupkg

# TODO: Run perf tests
# TODO: Run mono tests on Windows?
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/src/runtime/interopNative.cs

# Configuration data
configured.props

# General binaries and Build results
*.dll
*.exe
Expand Down
6 changes: 4 additions & 2 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- Meinrad Recheis ([@henon](https://github.com/henon))
- Mohamed Koubaa ([@koubaa](https://github.com/koubaa))
- Patrick Stewart ([@patstew](https://github.com/patstew))
- Peter Kese ([@pkese](https://github.com/pkese))
- Raphael Nestler ([@rnestler](https://github.com/rnestler))
- Rickard Holmberg ([@rickardraysearch](https://github.com/rickardraysearch))
- Sam Winstanley ([@swinstanley](https://github.com/swinstanley))
Expand All @@ -66,10 +67,10 @@
- Ville M. Vainio ([@vivainio](https://github.com/vivainio))
- Virgil Dupras ([@hsoft](https://github.com/hsoft))
- Wenguang Yang ([@yagweb](https://github.com/yagweb))
- William Sardar ([@williamsardar])(https://github.com/williamsardar)
- William Sardar ([@williamsardar](https://github.com/williamsardar))
- Xavier Dupré ([@sdpython](https://github.com/sdpython))
- Zane Purvis ([@zanedp](https://github.com/zanedp))
- ([@amos402]https://github.com/amos402)
- ([@amos402](https://github.com/amos402))
- ([@bltribble](https://github.com/bltribble))
- ([@civilx64](https://github.com/civilx64))
- ([@GSPP](https://github.com/GSPP))
Expand All @@ -82,3 +83,4 @@
- ([@testrunner123](https://github.com/testrunner123))
- ([@DanBarzilian](https://github.com/DanBarzilian))
- ([@alxnull](https://github.com/alxnull))
- ([@gpetrou](https://github.com/gpetrou))
59 changes: 45 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].

- Ability to instantiate new .NET arrays using `Array[T](dim1, dim2, ...)` syntax
- Python operator method will call C# operator method for supported binary and unary operators ([#1324][p1324]).
- Add GetPythonThreadID and Interrupt methods in PythonEngine
- Ability to implement delegates with `ref` and `out` parameters in Python, by returning the modified parameter values in a tuple. ([#1355][i1355])
- `PyType` - a wrapper for Python type objects, that also permits creating new heap types from `TypeSpec`
- Improved exception handling:
- exceptions can now be converted with codecs
- `InnerException` and `__cause__` are propagated properly

### Changed
- Drop support for Python 2, 3.4, and 3.5
Expand All @@ -28,28 +34,52 @@ details about the cause of the failure
to the regular method return value (unless they are passed with `ref` or `out` keyword).
- BREAKING: Drop support for the long-deprecated CLR.* prefix.
- `PyObject` now implements `IEnumerable<PyObject>` in addition to `IEnumerable`
- floating point values passed from Python are no longer silently truncated
when .NET expects an integer [#1342][i1342]
- More specific error messages for method argument mismatch
- BREAKING: Methods with `ref` or `out` parameters and void return type return a tuple of only the `ref` and `out` parameters.
- BREAKING: to call Python from .NET `Runtime.PythonDLL` property must be set to Python DLL name
or the DLL must be loaded in advance. This must be done before calling any other Python.NET functions.
- BREAKING: `PyObject.Length()` now raises a `PythonException` when object does not support a concept of length.
- BREAKING: disabled implicit conversion from C# enums to Python `int` and back.
One must now either use enum members (e.g. `MyEnum.Option`), or use enum constructor
(e.g. `MyEnum(42)` or `MyEnum(42, True)` when `MyEnum` does not have a member with value 42).
- Sign Runtime DLL with a strong name
- Implement loading through `clr_loader` instead of the included `ClrModule`, enables
support for .NET Core
- .NET and Python exceptions are preserved when crossing Python/.NET boundary
- BREAKING: custom encoders are no longer called for instances of `System.Type`
- `PythonException.Restore` no longer clears `PythonException` instance.
- Replaced the old `__import__` hook hack with a PEP302-style Meta Path Loader

### Fixed

- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
- Fix incorrect dereference in params array handling
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
- Fix `object[]` parameters taking precedence when should not in overload resolution
- Fixed a bug where all .NET class instances were considered Iterable
- Fix incorrect choice of method to invoke when using keyword arguments.
- Fix non-delegate types incorrectly appearing as callable.
- Indexers can now be used with interface objects
- Fixed a bug where indexers could not be used if they were inherited
- Made it possible to use `__len__` also on `ICollection<>` interface objects
- Fixed issue when calling PythonException.Format where another exception would be raise for unnormalized exceptions
- Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects
- Fixed objects returned by enumerating `PyObject` being disposed too soon
- Incorrectly using a non-generic type with type parameters now produces a helpful Python error instead of throwing NullReferenceException
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
- Fix incorrect dereference in params array handling
- Fixes issue with function resolution when calling overloaded function with keyword arguments from python ([#1097][i1097])
- Fix `object[]` parameters taking precedence when should not in overload resolution
- Fixed a bug where all .NET class instances were considered Iterable
- Fix incorrect choice of method to invoke when using keyword arguments.
- Fix non-delegate types incorrectly appearing as callable.
- Indexers can now be used with interface objects
- Fixed a bug where indexers could not be used if they were inherited
- Made it possible to use `__len__` also on `ICollection<>` interface objects
- Fixed issue when calling PythonException.Format where another exception would be raise for unnormalized exceptions
- Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects
- Fixed objects returned by enumerating `PyObject` being disposed too soon
- Incorrectly using a non-generic type with type parameters now produces a helpful Python error instead of throwing NullReferenceException
- `import` may now raise errors with more detail than "No module named X"
- Exception stacktraces on `PythonException.StackTrace` are now properly formatted
- Providing an invalid type parameter to a generic type or method produces a helpful Python error
- Empty parameter names (as can be generated from F#) do not cause crashes
- Unicode strings with surrogates were truncated when converting from Python

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the extra whitespace

### Removed

- implicit assembly loading (you have to explicitly `clr.AddReference` before doing import)
- messages in `PythonException` no longer start with exception type
- support for .NET Framework 4.0-4.6; Mono before 5.4. Python.NET now requires .NET Standard 2.0
(see [the matrix](https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support))

## [2.5.0][] - 2020-06-14

Expand Down Expand Up @@ -809,3 +839,4 @@ This version improves performance on benchmarks significantly compared to 2.3.
[i755]: https://github.com/pythonnet/pythonnet/pull/755
[p534]: https://github.com/pythonnet/pythonnet/pull/534
[i449]: https://github.com/pythonnet/pythonnet/issues/449
[i1342]: https://github.com/pythonnet/pythonnet/issues/1342
10 changes: 7 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
<AssemblyCopyright>Copyright (c) 2006-2020 The Contributors of the Python.NET Project</AssemblyCopyright>
<AssemblyCompany>pythonnet</AssemblyCompany>
<AssemblyProduct>Python.NET</AssemblyProduct>
<LangVersion>7.3</LangVersion>
<LangVersion>9.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NonCopyableAnalyzer" Version="0.6.0">
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.9.0-3.final">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Lost.NonCopyableAnalyzer" Version="0.7.0-m04">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)configured.props" Condition="Exists('$(MSBuildThisFileDirectory)configured.props')" />
</Project>
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2006-2020 the contributors of the Python.NET project
Copyright (c) 2006-2021 the contributors of the Python.NET project

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
Expand Down
14 changes: 13 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ pythonnet - Python.NET

|gh shield| |appveyor shield|

|license shield| |pypi package version| |conda-forge version| |python supported shield|
|license shield|

|pypi package version| |conda-forge version| |python supported shield|

|nuget preview shield| |nuget release shield|

Python.NET is a package that gives Python programmers nearly
seamless integration with the .NET Common Language Runtime (CLR) and
Expand Down Expand Up @@ -41,6 +45,10 @@ module:
Embedding Python in .NET
------------------------

- You must set `Runtime.PythonDLL` property or `PYTHONNET_PYDLL` environment variable
starting with version 3.0, otherwise you will receive `TypeInitializationException`.
Typical values are `python38.dll` (Windows), `libpython3.8.dylib` (Mac),
`libpython3.8.so` (most other *nix).
- All calls to python should be inside a
``using (Py.GIL()) {/* Your code here */}`` block.
- Import python modules using ``dynamic mod = Py.Import("mod")``, then
Expand Down Expand Up @@ -130,5 +138,9 @@ This project is supported by the `.NET Foundation <https://dotnetfoundation.org>
:target: http://stackoverflow.com/questions/tagged/python.net
.. |conda-forge version| image:: https://img.shields.io/conda/vn/conda-forge/pythonnet.svg
:target: https://anaconda.org/conda-forge/pythonnet
.. |nuget preview shield| image:: https://img.shields.io/nuget/vpre/pythonnet
:target: https://www.nuget.org/packages/pythonnet/
.. |nuget release shield| image:: https://img.shields.io/nuget/v/pythonnet
:target: https://www.nuget.org/packages/pythonnet/
.. |gh shield| image:: https://github.com/pythonnet/pythonnet/workflows/GitHub%20Actions/badge.svg
:target: https://github.com/pythonnet/pythonnet/actions?query=branch%3Amaster
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ init:
- set PY_VER=%PYTHON_VERSION:.=%
- set PYTHON=C:\PYTHON%PY_VER%
- if %PLATFORM%==x64 (set PYTHON=%PYTHON%-x64)
- set PYTHONNET_PYDLL=%PYTHON%\python%PY_VER%.dll

# Put desired Python version first in PATH
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
Expand All @@ -41,7 +42,6 @@ install:
- pip install --upgrade -r requirements.txt --quiet

build_script:
- python setup.py configure
# Create clean `sdist`. Only used for releases
- python setup.py --quiet sdist
- python setup.py bdist_wheel
Expand Down
39 changes: 2 additions & 37 deletions clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,5 @@
Legacy Python.NET loader for backwards compatibility
"""

def _get_netfx_path():
import os, sys

if sys.maxsize > 2 ** 32:
arch = "amd64"
else:
arch = "x86"

return os.path.join(os.path.dirname(__file__), "pythonnet", "netfx", arch, "clr.pyd")


def _get_mono_path():
import os, glob

paths = glob.glob(os.path.join(os.path.dirname(__file__), "pythonnet", "mono", "clr.*so"))
return paths[0]


def _load_clr():
import sys
from importlib import util

if sys.platform == "win32":
path = _get_netfx_path()
else:
path = _get_mono_path()

del sys.modules[__name__]

spec = util.spec_from_file_location("clr", path)
clr = util.module_from_spec(spec)
spec.loader.exec_module(clr)

sys.modules[__name__] = clr


_load_clr()
from pythonnet import load
load()
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[build-system]
requires = ["setuptools>=42", "wheel", "pycparser"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
xfail_strict = true
testpaths = [
"tests"
]
Loading