Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use new references#1603

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lostmsu merged 120 commits intopythonnet:masterfromlosttech:precise-API-references
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
120 commits
Select commitHold shift + click to select a range
5d6e5d5
use reference types instead of IntPtr where possible in runtime.cs
lostmsuOct 17, 2021
2d33902
switched converter.cs to the new style references
lostmsuOct 17, 2021
f8b761a
switched most of classbase.cs to the new style references (except cro…
lostmsuOct 17, 2021
09d8e41
switched pyobject.cs to the new style references
lostmsuOct 17, 2021
1b58cf4
mostly switched moduleobject.cs to the new style references
lostmsuOct 17, 2021
c05c6ec
switched methodbinder.cs to the new style references
lostmsuOct 17, 2021
d626f7e
partially switched classderived.cs to the new reference style
lostmsuOct 17, 2021
ff60ec4
switched arrayobject.cs to the new style references
lostmsuOct 17, 2021
0010fa0
switched delegatemanager.cs to the new style references
lostmsuOct 17, 2021
178a359
partially switched metatype.cs to the new style references
lostmsuOct 18, 2021
9764b25
switched typemanager.cs to the new style references
lostmsuOct 18, 2021
11edcc3
switched pytype.cs to the new style references
lostmsuOct 18, 2021
2e71874
mass enable nullable types
lostmsuOct 18, 2021
3076040
fixed nullablity in arrayobject.cs
lostmsuOct 18, 2021
56f3bd5
fixed nullability in assemblymanager.cs
lostmsuOct 18, 2021
58cb0e6
switched classmanager.cs to the new style references
lostmsuOct 18, 2021
2095b46
switched classobject.cs to the new style references
lostmsuOct 18, 2021
f6b84da
partially switched managedtype.cs to the new style references
lostmsuOct 18, 2021
ee65632
partially switched classmanager.cs to the new style references
lostmsuOct 18, 2021
5266dc4
PyIdentifier public members to return borrowed references
lostmsuOct 6, 2021
0bc3670
added nullability annotations to methodbinder.cs
lostmsuOct 18, 2021
de9a8cb
switched methodbinding.cs and methodobject.cs to the new style refere…
lostmsuOct 18, 2021
9195c30
switched overload.cs to the new style references
lostmsuOct 18, 2021
590de7a
switched propertyobject.cs to the new style references
lostmsuOct 18, 2021
7fa537a
switched delegateobject.cs to the new style references
lostmsuOct 18, 2021
49124fc
switched module.cs to the new style references
lostmsuOct 18, 2021
9db9b0b
nullability annotations for PyObject
lostmsuOct 18, 2021
00fd17a
switched modulefunctionobject.cs to the new style references
lostmsuOct 18, 2021
5798b41
minor refactorings
lostmsuOct 18, 2021
ebdf7c5
partially switched moduleobject.cs and importhook.cs to the new style…
lostmsuOct 18, 2021
5ad09e4
switched exceptions.cs to the new style references
lostmsuOct 18, 2021
d1abd9a
switched interfaceobject.cs to the new style references
lostmsuOct 18, 2021
43a862a
switched pythonexception.cs to the new style references
lostmsuOct 18, 2021
1d80162
switched pytuple.cs to the new style references
lostmsuOct 18, 2021
0241b38
switched eventobject.cs and eventbiding.cs to the new style references
lostmsuOct 18, 2021
2ac952a
switched all PyObject derived classes to the new style references
lostmsuOct 18, 2021
7adf98a
implemented non-confusing PyModule_AddObject
lostmsuOct 18, 2021
2dd3f8f
switched pythonengine.cs to the new style references
lostmsuOct 18, 2021
3b79019
switched fieldobject.cs and constructorbinding.cs to the new style re…
lostmsuOct 18, 2021
9b990c1
switched finalizer.cs to the new style references
lostmsuOct 19, 2021
027e529
switched debughelper.cs to the new style references
lostmsuOct 19, 2021
4793818
switched converter extensions and sample codecs to the new style refe…
lostmsuOct 19, 2021
0d60500
switched collection wrappers (from sample codec) to the new style ref…
lostmsuOct 19, 2021
cf606a2
switched iterator.cs and indexer.cs to the new style references
lostmsuOct 19, 2021
bb84c48
getting rid of a few minor warnings and compile errors
lostmsuOct 19, 2021
e295679
switched to new references in some tests
lostmsuOct 19, 2021
7a9e411
switched state serialization to new reference types (untested)
lostmsuOct 19, 2021
9a9ed3b
minor error fixes
lostmsuOct 19, 2021
581f695
assume remaning manual refcounting is not needed, because we use smar…
lostmsuOct 19, 2021
07f1657
fixed new reference uses, that are not allowed in C#
lostmsuOct 19, 2021
7deebd4
renamed parameter in tp_dealloc functions for clarity
lostmsuOct 19, 2021
8619e77
allowed untested calls to PyObject_GC_Del and XDecref (3 in total)
lostmsuOct 19, 2021
672aef6
fixed compile errors in TypeMethod (untested)
lostmsuOct 19, 2021
c4909d4
workaround for analyzer not permitting copying a reference as the las…
lostmsuOct 19, 2021
6fa2004
switched tests to match the new reference changes
lostmsuOct 19, 2021
14949fb
fixed thunk loading for slots, that use new reference types
lostmsuOct 19, 2021
0728e21
fixed PyObject_DelAttr load from DLL failing
lostmsuOct 19, 2021
fe4c481
fixed uses of Marshal.Read/Marshal.Write overloads with first argumen…
lostmsuOct 19, 2021
4346d41
fixed OnSerialized and OnDeserialized in PyObject not being typed cor…
lostmsuOct 19, 2021
62e193a
fixed bad equality comparisons
lostmsuOct 20, 2021
2fa8b9c
improved reliability of Clean and Dealloc implementations
lostmsuOct 20, 2021
d6607b0
bad if condition
lostmsuOct 20, 2021
6335d97
improved GetThunk reliability
lostmsuOct 20, 2021
d649d6c
fixed circular dependency in Runtime PyMembers and InternString initi…
lostmsuOct 20, 2021
d1bc193
tiny refactor
lostmsuOct 20, 2021
32c4bb6
switched generictype.cs to the new style references
lostmsuOct 20, 2021
a1427ac
increfs in OnSave are no longer necessary with the new references
lostmsuOct 20, 2021
cd97a46
fixed MethodBinding failing for reference types
lostmsuOct 20, 2021
05ecbcf
nullability annotation fix in MaybeMethodBase
lostmsuOct 20, 2021
a3591b6
minor improvements
lostmsuOct 20, 2021
7ed0c7a
WIP
lostmsuOct 24, 2021
d6a853f
avoid generating and handling useless SerializationException when May…
lostmsuOct 28, 2021
b0c25c1
finalizer does not attempt to finalize objects when runtime is shut down
lostmsuOct 28, 2021
5ca474a
PyType Dict and MRO properties to assist debugging
lostmsuOct 28, 2021
48078b3
WIP 2
lostmsuOct 28, 2021
a624dd8
fixed PyObject disposal crashing when runtime is still finalizing
lostmsuOct 29, 2021
e7ab071
arrays: use 64 bit indexing, and avoid first chance .NET exceptions o…
lostmsuOct 29, 2021
cbe1dd2
refactored conditional ClassBase slot initialization
lostmsuOct 29, 2021
d5f1c48
removed DisposePythonWrappersForClrTypes
lostmsuOct 29, 2021
74d87c5
simplified outdated condition in ClassBase.tp_clear
lostmsuOct 29, 2021
82d6c33
sprinkled a few DebuggerHidden to make debugging easier
lostmsuOct 29, 2021
eeebcd7
fixed derived classes not inheriting slots correctly
lostmsuOct 29, 2021
8ee8d3d
remove unused TypeManager._slotImpls
lostmsuOct 29, 2021
1a4ada7
fixed TestRuntime not building in Release mode
lostmsuOct 30, 2021
a610aa3
can't really clear managed references to Python objects from ManagedT…
lostmsuOct 30, 2021
03f32cb
PythonException is serializable
lostmsuOct 30, 2021
b1c9f5b
EventObject no longer used for static events. EventBinding is constru…
lostmsuOct 30, 2021
cb4bb9a
use a special class to stub .NET types that no longer exist after a d…
lostmsuNov 2, 2021
652f946
make EventHandlerCollection serializable
lostmsuNov 2, 2021
84db670
fixed MaybeMemberInfo always failing for properties
lostmsuNov 2, 2021
56fafe3
fixed construct_removed_class domain reload test case
lostmsuNov 2, 2021
d33dcdd
domain reload test runner can run test by index
lostmsuNov 2, 2021
b737e10
minor docs change
lostmsuNov 2, 2021
d3e4fba
assert check in GetUnmanagedBaseType for null base
lostmsuNov 2, 2021
e003e12
PythonEngine .Exec and .Eval no longer work with raw pointers
lostmsuNov 9, 2021
d0a6f44
a few annotation to ease debugging
lostmsuNov 9, 2021
e31f7ba
ensure Python types continue to exist when registered decoders for th…
lostmsuNov 9, 2021
48c0dfc
GC-related WIP
lostmsuNov 9, 2021
44d65d9
merge latest master
lostmsuNov 23, 2021
cb58147
merge latest changes from upstream
lostmsuNov 23, 2021
2fdbf0e
added TraceAlloc solution configuration
lostmsuNov 24, 2021
a8ef06c
fixed sending PyObject across domain boundary
lostmsuNov 24, 2021
7167229
fixed accidental premature disposal of Runtime.PyNone
lostmsuNov 24, 2021
ab11fa2
made freeing GCHandles more robust
lostmsuNov 24, 2021
7a4daeb
removed bad assert in generated constructor for derived classes
lostmsuNov 24, 2021
e422367
fixed __pyobj__ access
lostmsuNov 24, 2021
a74ea86
minor
lostmsuNov 24, 2021
0325a8c
fixed Python derived types trying to double-free GCHandle when collec…
lostmsuNov 24, 2021
85fab3b
reinstate collection assert on shutdown from Python
lostmsuNov 24, 2021
932fce2
fixed crash when Python derived class instances survive past early sh…
lostmsuNov 24, 2021
c2e207a
delay nulling GC handles of reflected instances until the last moment…
lostmsuNov 24, 2021
c8f0f09
fixed assert in XDecref in case _Py_IsFinalizing is not present
lostmsuNov 24, 2021
e269cf0
when initialized from Python, reset slots implemented in CLR: CLR mig…
lostmsuNov 25, 2021
d7d5cb7
fixed minor warnings
lostmsuNov 25, 2021
d6edace
fixed line endings in intern_.cs
lostmsuNov 25, 2021
a86994f
use NonCopyableAnalyzer 0.7.0-m05
lostmsuNov 25, 2021
2e040ea
Merge pull request #2 from losttech/ManagedType-DontKeepBorrowedRefs
lostmsuDec 9, 2021
b614dba
merge latest master
lostmsuDec 9, 2021
f09a48b
fixed MacOS bad assembly test by using PythonDLL (which is never a .N…
lostmsuDec 9, 2021
3794fea
Merge branch 'master' into precise-API-references
lostmsuDec 14, 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
2 changes: 2 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,6 +65,7 @@ One must now either use enum members (e.g. `MyEnum.Option`), or use enum constru
- BREAKING: Names of .NET types (e.g. `str(__class__)`) changed to better support generic types
- BREAKING: overload resolution will no longer prefer basic types. Instead, first matching overload will
be chosen.
- BREAKING: `Exec` and `Eval` from `PythonEngine` no longer accept raw pointers.
- BREAKING: .NET collections and arrays are no longer automatically converted to
Python collections. Instead, they implement standard Python
collection interfaces from `collections.abc`.
Expand All@@ -74,6 +75,7 @@ be of type `PyInt` instead of `System.Int32` due to possible loss of information
Python `float` will continue to be converted to `System.Double`.
- BREAKING: Python.NET will no longer implicitly convert types like `numpy.float64`, that implement `__float__` to
`System.Single` and `System.Double`. An explicit conversion is required on Python or .NET side.
- BREAKING: `PyObject.GetHashCode` can fail.
- BREAKING: Python.NET will no longer implicitly convert any Python object to `System.Boolean`.
- BREAKING: `PyObject.GetAttr(name, default)` now only ignores `AttributeError` (previously ignored all exceptions).
- BREAKING: `PyObject` no longer implements `IEnumerable<PyObject>`.
Expand Down
45 changes: 45 additions & 0 deletionspythonnet.sln
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,6 +54,9 @@ Global
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
TraceAlloc|Any CPU = TraceAlloc|Any CPU
TraceAlloc|x64 = TraceAlloc|x64
TraceAlloc|x86 = TraceAlloc|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand All@@ -68,6 +71,12 @@ Global
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.Release|x64.Build.0 = Release|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.Release|x86.ActiveCfg = Release|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.Release|x86.Build.0 = Release|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|Any CPU.ActiveCfg = TraceAlloc|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|Any CPU.Build.0 = TraceAlloc|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x64.ActiveCfg = Debug|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x64.Build.0 = Debug|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU
{4E8C8FE2-0FB8-4517-B2D9-5FB2D5FC849B}.TraceAlloc|x86.Build.0 = Debug|Any CPU
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|Any CPU.ActiveCfg = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|Any CPU.Build.0 = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Debug|x64.ActiveCfg = Debug|x64
Expand All@@ -80,6 +89,12 @@ Global
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x64.Build.0 = Release|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x86.ActiveCfg = Release|x86
{E6B01706-00BA-4144-9029-186AC42FBE9A}.Release|x86.Build.0 = Release|x86
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|Any CPU.ActiveCfg = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|Any CPU.Build.0 = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x64.ActiveCfg = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x64.Build.0 = Debug|x64
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x86.ActiveCfg = Debug|x86
{E6B01706-00BA-4144-9029-186AC42FBE9A}.TraceAlloc|x86.Build.0 = Debug|x86
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All@@ -92,6 +107,12 @@ Global
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Release|x64.Build.0 = Release|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Release|x86.ActiveCfg = Release|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.Release|x86.Build.0 = Release|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|Any CPU.ActiveCfg = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|Any CPU.Build.0 = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|x64.ActiveCfg = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|x64.Build.0 = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU
{819E089B-4770-400E-93C6-4F7A35F0EA12}.TraceAlloc|x86.Build.0 = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All@@ -104,6 +125,12 @@ Global
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Release|x64.Build.0 = Release|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Release|x86.ActiveCfg = Release|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.Release|x86.Build.0 = Release|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|Any CPU.ActiveCfg = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|Any CPU.Build.0 = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|x64.ActiveCfg = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|x64.Build.0 = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU
{14EF9518-5BB7-4F83-8686-015BD2CC788E}.TraceAlloc|x86.Build.0 = Debug|Any CPU
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Debug|Any CPU.ActiveCfg = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Debug|Any CPU.Build.0 = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Debug|x64.ActiveCfg = Debug|x64
Expand All@@ -116,6 +143,12 @@ Global
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x64.Build.0 = Release|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x86.ActiveCfg = Release|x86
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.Release|x86.Build.0 = Release|x86
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|Any CPU.ActiveCfg = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|Any CPU.Build.0 = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|x64.ActiveCfg = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|x64.Build.0 = Debug|x64
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|x86.ActiveCfg = Debug|x86
{4F2EA4A1-7ECA-48B5-8077-7A3C366F9931}.TraceAlloc|x86.Build.0 = Debug|x86
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All@@ -128,6 +161,12 @@ Global
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x64.Build.0 = Release|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.ActiveCfg = Release|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.Release|x86.Build.0 = Release|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|Any CPU.ActiveCfg = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|Any CPU.Build.0 = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|x64.ActiveCfg = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|x64.Build.0 = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU
{F2FB6DA3-318E-4F30-9A1F-932C667E38C5}.TraceAlloc|x86.Build.0 = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand All@@ -140,6 +179,12 @@ Global
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x64.Build.0 = Release|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x86.ActiveCfg = Release|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.Release|x86.Build.0 = Release|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|Any CPU.ActiveCfg = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|Any CPU.Build.0 = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x64.ActiveCfg = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x64.Build.0 = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x86.ActiveCfg = Debug|Any CPU
{35CBBDEB-FC07-4D04-9D3E-F88FC180110B}.TraceAlloc|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletionsrc/embed_tests/CallableObject.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@ public void SetUp()
{
PythonEngine.Initialize();
using var locals = new PyDict();
PythonEngine.Exec(CallViaInheritance.BaseClassSource, locals: locals.Handle);
PythonEngine.Exec(CallViaInheritance.BaseClassSource, locals: locals);
CustomBaseTypeProvider.BaseClass = new PyType(locals[CallViaInheritance.BaseClassName]);
PythonEngine.InteropConfiguration.PythonBaseTypeProviders.Add(new CustomBaseTypeProvider());
}
Expand Down
4 changes: 2 additions & 2 deletionssrc/embed_tests/CodecGroups.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,12 +49,12 @@ public void Encodes()
};

var uri = group.TryEncode(new Uri("data:"));
var clrObject = (CLRObject)ManagedType.GetManagedObject(uri.Handle);
var clrObject = (CLRObject)ManagedType.GetManagedObject(uri);
Assert.AreSame(encoder1, clrObject.inst);
Assert.AreNotSame(encoder2, clrObject.inst);

var tuple = group.TryEncode(Tuple.Create(1));
clrObject = (CLRObject)ManagedType.GetManagedObject(tuple.Handle);
clrObject = (CLRObject)ManagedType.GetManagedObject(tuple);
Assert.AreSame(encoder0, clrObject.inst);
}

Expand Down
6 changes: 3 additions & 3 deletionssrc/embed_tests/Inheritance.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,8 +13,8 @@ public class Inheritance
public void SetUp()
{
PythonEngine.Initialize();
var locals = new PyDict();
PythonEngine.Exec(InheritanceTestBaseClassWrapper.ClassSourceCode, locals: locals.Handle);
usingvar locals = new PyDict();
PythonEngine.Exec(InheritanceTestBaseClassWrapper.ClassSourceCode, locals: locals);
ExtraBaseTypeProvider.ExtraBase = new PyType(locals[InheritanceTestBaseClassWrapper.ClassName]);
var baseTypeProviders = PythonEngine.InteropConfiguration.PythonBaseTypeProviders;
baseTypeProviders.Add(new ExtraBaseTypeProvider());
Expand DownExpand Up@@ -172,7 +172,7 @@ public int XProp
{
return scope.Eval<int>($"super(this.__class__, this).{nameof(XProp)}");
}
catch (PythonException ex) when (ex.Type.Handle ==Exceptions.AttributeError)
catch (PythonException ex) when (PythonReferenceComparer.Instance.Equals(ex.Type,Exceptions.AttributeError))
{
if (this.extras.TryGetValue(nameof(this.XProp), out object value))
return (int)value;
Expand Down
12 changes: 3 additions & 9 deletionssrc/embed_tests/References.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,15 +39,9 @@ public void MoveToPyObject_SetsNull()
public void CanBorrowFromNewReference()
{
var dict = new PyDict();
NewReference reference = Runtime.PyDict_Items(dict.Reference);
try
{
PythonException.ThrowIfIsNotZero(Runtime.PyList_Reverse(reference));
}
finally
{
reference.Dispose();
}
using NewReference reference = Runtime.PyDict_Items(dict.Reference);
BorrowedReference borrowed = reference.BorrowOrThrow();
PythonException.ThrowIfIsNotZero(Runtime.PyList_Reverse(borrowed));
}
}
}
15 changes: 7 additions & 8 deletionssrc/embed_tests/TestConverter.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ public void TestConvertSingleToManaged(
var pyFloat = new PyFloat(testValue);

object convertedValue;
var converted = Converter.ToManaged(pyFloat.Handle, typeof(float), out convertedValue, false);
var converted = Converter.ToManaged(pyFloat, typeof(float), out convertedValue, false);

Assert.IsTrue(converted);
Assert.IsTrue(((float) convertedValue).Equals(testValue));
Expand All@@ -56,7 +56,7 @@ public void TestConvertDoubleToManaged(
var pyFloat = new PyFloat(testValue);

object convertedValue;
var converted = Converter.ToManaged(pyFloat.Handle, typeof(double), out convertedValue, false);
var converted = Converter.ToManaged(pyFloat, typeof(double), out convertedValue, false);

Assert.IsTrue(converted);
Assert.IsTrue(((double) convertedValue).Equals(testValue));
Expand All@@ -77,7 +77,7 @@ public void CovertTypeError()
object value;
try
{
bool res = Converter.ToManaged(s.Handle, type, out value, true);
bool res = Converter.ToManaged(s, type, out value, true);
Assert.IsFalse(res);
var bo = Exceptions.ExceptionMatches(Exceptions.TypeError);
Assert.IsTrue(Exceptions.ExceptionMatches(Exceptions.TypeError)
Expand All@@ -96,13 +96,13 @@ public void ConvertOverflow()
{
using (var num = new PyInt(ulong.MaxValue))
{
IntPtrlargeNum = PyRuntime.PyNumber_Add(num.Handle, num.Handle);
using varlargeNum = PyRuntime.PyNumber_Add(num, num);
try
{
object value;
foreach (var type in _numTypes)
{
bool res = Converter.ToManaged(largeNum, type, out value, true);
bool res = Converter.ToManaged(largeNum.BorrowOrThrow(), type, out value, true);
Assert.IsFalse(res);
Assert.IsTrue(Exceptions.ExceptionMatches(Exceptions.OverflowError));
Exceptions.Clear();
Expand All@@ -111,7 +111,6 @@ public void ConvertOverflow()
finally
{
Exceptions.Clear();
PyRuntime.XDecref(largeNum);
}
}
}
Expand DownExpand Up@@ -147,7 +146,7 @@ public void RawListProxy()
{
var list = new List<string> {"hello", "world"};
var listProxy = PyObject.FromManagedObject(list);
var clrObject = (CLRObject)ManagedType.GetManagedObject(listProxy.Handle);
var clrObject = (CLRObject)ManagedType.GetManagedObject(listProxy);
Assert.AreSame(list, clrObject.inst);
}

Expand All@@ -156,7 +155,7 @@ public void RawPyObjectProxy()
{
var pyObject = "hello world!".ToPython();
var pyObjectProxy = PyObject.FromManagedObject(pyObject);
var clrObject = (CLRObject)ManagedType.GetManagedObject(pyObjectProxy.Handle);
var clrObject = (CLRObject)ManagedType.GetManagedObject(pyObjectProxy);
Assert.AreSame(pyObject, clrObject.inst);

var proxiedHandle = pyObjectProxy.GetAttr("Handle").As<IntPtr>();
Expand Down
8 changes: 4 additions & 4 deletionssrc/embed_tests/TestCustomMarshal.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,11 +23,11 @@ public static void GetManagedStringTwice()
{
const string expected = "FooBar";

IntPtr op = Runtime.Runtime.PyString_FromString(expected);
string s1 = Runtime.Runtime.GetManagedString(op);
string s2 = Runtime.Runtime.GetManagedString(op);
using var op = Runtime.Runtime.PyString_FromString(expected);
string s1 = Runtime.Runtime.GetManagedString(op.BorrowOrThrow());
string s2 = Runtime.Runtime.GetManagedString(op.Borrow());

Assert.AreEqual(1, Runtime.Runtime.Refcount(op));
Assert.AreEqual(1, Runtime.Runtime.Refcount32(op.Borrow()));
Assert.AreEqual(expected, s1);
Assert.AreEqual(expected, s2);
}
Expand Down
10 changes: 5 additions & 5 deletionssrc/embed_tests/TestDomainReload.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -107,7 +107,7 @@ from Python.EmbeddingTest.Domain import MyClass
{
Debug.Assert(obj.AsManagedObject(type).GetType() == type);
// We only needs its Python handle
PyRuntime.XIncref(obj.Handle);
PyRuntime.XIncref(obj);
return obj.Handle;
}
}
Expand All@@ -127,16 +127,16 @@ public override ValueType Execute(ValueType arg)
{
// handle refering a clr object created in previous domain,
// it should had been deserialized and became callable agian.
IntPtrhandle =(IntPtr)arg;
using varhandle =NewReference.DangerousFromPointer((IntPtr)arg);
try
{
using (Py.GIL())
{
IntPtr tp = Runtime.Runtime.PyObject_TYPE(handle);
IntPtr tp_clear =Marshal.ReadIntPtr(tp, TypeOffset.tp_clear);
BorrowedReference tp = Runtime.Runtime.PyObject_TYPE(handle.Borrow());
IntPtr tp_clear =Util.ReadIntPtr(tp, TypeOffset.tp_clear);
Assert.That(tp_clear, Is.Not.Null);

using (PyObject obj = new PyObject(handle))
using (PyObject obj = new PyObject(handle.Steal()))
{
obj.InvokeMethod("Method");
obj.InvokeMethod("StaticMethod");
Expand Down
2 changes: 1 addition & 1 deletionsrc/embed_tests/TestFinalizer.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -212,7 +212,7 @@ public void ValidateRefCount()
Assert.AreEqual(ptr, e.Handle);
Assert.AreEqual(2, e.ImpactedObjects.Count);
// Fix for this test, don't do this on general environment
Runtime.Runtime.XIncref(e.Handle);
Runtime.Runtime.XIncref(e.Reference);
return false;
};
Finalizer.Instance.IncorrectRefCntResolver += handler;
Expand Down
2 changes: 1 addition & 1 deletionsrc/embed_tests/TestNamedArguments.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ def Test3(self, a1 = 1, a2 = 1, a3 = 1, a4 = 1):
return a1 + a2 + a3 + a4

a = cmTest3()
", null, locals.Handle);
", null, locals);

return locals.GetItem("a");
}
Expand Down
1 change: 0 additions & 1 deletionsrc/embed_tests/TestPyInt.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,7 +86,6 @@ public void TestCtorSByte()
public void TestCtorPyObject()
{
var i = new PyInt(5);
Runtime.Runtime.XIncref(i.Handle);
var a = new PyInt(i);
Assert.AreEqual(5, a.ToInt32());
}
Expand Down
8 changes: 4 additions & 4 deletionssrc/embed_tests/TestPyObject.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ def add(self, x, y):
return x + y

a = MemberNamesTest()
", null, locals.Handle);
", null, locals);

PyObject a = locals.GetItem("a");

Expand DownExpand Up@@ -92,13 +92,13 @@ public void GetAttrDefault_IgnoresAttributeErrorOnly()
var typeErrResult = Assert.Throws<PythonException>(
() => ob.GetAttr(nameof(PyObjectTestMethods.RaisesTypeError), fallback)
);
Assert.AreEqual(Exceptions.TypeError, typeErrResult.Type.Handle);
Assert.AreEqual(Exceptions.TypeError, typeErrResult.Type);
}
}

public class PyObjectTestMethods
{
public string RaisesAttributeError => throw new PythonException(new PyType(new BorrowedReference(Exceptions.AttributeError)), value: null, traceback: null);
public string RaisesTypeError => throw new PythonException(new PyType(new BorrowedReference(Exceptions.TypeError)), value: null, traceback: null);
public string RaisesAttributeError => throw new PythonException(new PyType(Exceptions.AttributeError), value: null, traceback: null);
public string RaisesTypeError => throw new PythonException(new PyType(Exceptions.TypeError), value: null, traceback: null);
}
}
6 changes: 3 additions & 3 deletionssrc/embed_tests/TestPySequence.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,9 +87,9 @@ public void TestIndex()
{
var t1 = new PyString("FooBar");

Assert.AreEqual(4, t1.Index(new PyString("a")));
Assert.AreEqual(5, t1.Index(new PyString("r")));
Assert.AreEqual(-1, t1.Index(new PyString("z")));
Assert.AreEqual(4, t1.Index32(new PyString("a")));
Assert.AreEqual(5L, t1.Index64(new PyString("r")));
Assert.AreEqual(-(nint)1, t1.Index(new PyString("z")));
}
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp