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

Modernize import hook#1369

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
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
21 commits
Select commitHold shift + click to select a range
a321daa
(WIP) modernize the import hook
BadSingletonJan 15, 2021
279b535
Add the loaded namespaces tracking
BadSingletonJan 15, 2021
f92e95b
cleanup and changelog entry
BadSingletonJan 15, 2021
afffc18
Fix a bug where clr wasn't in sys.modules after reload
BadSingletonJan 18, 2021
d821c0f
Further refinements to setattr logic on ModuleObjects
BadSingletonJan 19, 2021
e469a8a
fixups, add docs
BadSingletonJan 20, 2021
685b972
merge fixup
BadSingletonMar 4, 2021
be81364
(WIP) import hook in the pytohn module
BadSingletonMar 10, 2021
73958ed
Revert "(WIP) import hook in the pytohn module"
BadSingletonApr 12, 2021
e71a0ef
Import hook as a module, take 2
BadSingletonApr 12, 2021
2af066d
fixup! Merge remote-tracking branch 'origin/master' into modernize-im…
BadSingletonApr 12, 2021
bb490bf
fixup! fixup! Merge remote-tracking branch 'origin/master' into moder…
BadSingletonApr 12, 2021
31ea876
Create a clr.loader module
BadSingletonJun 1, 2021
c02d5c6
Test to test if the test passes
BadSingletonJun 2, 2021
970a189
fix new exception usage
BadSingletonJun 2, 2021
059605b
kick the build because I can't repro
BadSingletonJun 2, 2021
ff170e9
Add Namespaces to the import hook only through AddReference
BadSingletonJun 2, 2021
63de923
Review changes, update API usage
BadSingletonJun 8, 2021
624f7e3
Merge remote-tracking branch 'upstream/master' into modernize-import-…
BadSingletonJun 14, 2021
bd7e745
make PyModule_AddObject in line with CPython
BadSingletonJun 14, 2021
46a85fe
take care of stragglers
BadSingletonJun 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
1 change: 1 addition & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,6 +50,7 @@ One must now either use enum members (e.g. `MyEnum.Option`), or use enum constru
- .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

Expand Down
1 change: 1 addition & 0 deletionssrc/embed_tests/TestPythonException.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,6 +178,7 @@ public void TestPythonException_Normalize_ThrowsWhenErrorSet()
var pythonException = PythonException.FetchCurrentRaw();
Exceptions.SetError(Exceptions.TypeError, "Another error");
Assert.Throws<InvalidOperationException>(() => pythonException.Normalize());
Exceptions.Clear();
}
}
}
2 changes: 1 addition & 1 deletionsrc/embed_tests/pyimport.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ public void SetUp()
Assert.IsFalse(str == IntPtr.Zero);
BorrowedReference path = Runtime.Runtime.PySys_GetObject("path");
Assert.IsFalse(path.IsNull);
Runtime.Runtime.PyList_Append(path, str);
Runtime.Runtime.PyList_Append(path,new BorrowedReference(str));
Runtime.Runtime.XDecref(str);
}

Expand Down
10 changes: 9 additions & 1 deletionsrc/runtime/assemblymanager.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,6 @@ internal class AssemblyManager
// modified from event handlers below, potentially triggered from different .NET threads
private static ConcurrentQueue<Assembly> assemblies;
internal static List<string> pypath;

private AssemblyManager()
{
}
Expand DownExpand Up@@ -312,6 +311,15 @@ public static bool IsValidNamespace(string name)
return !string.IsNullOrEmpty(name) && namespaces.ContainsKey(name);
}

/// <summary>
/// Returns an IEnumerable<string> containing the namepsaces exported
/// by loaded assemblies in the current app domain.
/// </summary>
public static IEnumerable<string> GetNamespaces ()
{
return namespaces.Keys;
}

/// <summary>
/// Returns list of assemblies that declare types in a given namespace
/// </summary>
Expand Down
10 changes: 10 additions & 0 deletionssrc/runtime/converter.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -202,6 +202,16 @@ internal static IntPtr ToPython(object value, Type type)
return ClassDerivedObject.ToPython(pyderived);
}

// ModuleObjects are created in a way that their wrapping them as
// a CLRObject fails, the ClassObject has no tpHandle. Return the
// pyHandle as is, do not convert.
if (value is ModuleObject modobj)
{
var handle = modobj.pyHandle;
Runtime.XIncref(handle);
return handle;
}

// hmm - from Python, we almost never care what the declared
// type is. we'd rather have the object bound to the actual
// implementing class.
Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/extensiontype.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -83,7 +83,7 @@ public static int tp_setattro(IntPtr ob, IntPtr key, IntPtr val)
{
message = "readonly attribute";
}
Exceptions.SetError(Exceptions.TypeError, message);
Exceptions.SetError(Exceptions.AttributeError, message);
return -1;
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp