@@ -37,12 +37,27 @@ public ModuleObject(string name) : base() {
37
37
cache = new Dictionary < string , ManagedType > ( ) ;
38
38
_namespace = name ;
39
39
40
+ // Use the filename from any of the assemblies just so there's something for
41
+ // anything that expects __file__ to be set.
42
+ string filename = "unknown" ;
43
+ string docstring = "Namespace containing types from the following assemblies:\n \n " ;
44
+ foreach ( Assembly a in AssemblyManager . GetAssemblies ( name ) ) {
45
+ filename = a . Location ;
46
+ docstring += "- " + a . FullName + "\n " ;
47
+ }
48
+
40
49
dict = Runtime . PyDict_New ( ) ;
41
50
IntPtr pyname = Runtime . PyString_FromString ( moduleName ) ;
51
+ IntPtr pyfilename = Runtime . PyString_FromString ( filename ) ;
52
+ IntPtr pydocstring = Runtime . PyString_FromString ( docstring ) ;
53
+ IntPtr pycls = TypeManager . GetTypeHandle ( this . GetType ( ) ) ;
42
54
Runtime . PyDict_SetItemString ( dict , "__name__" , pyname ) ;
43
- Runtime . PyDict_SetItemString ( dict , "__file__" , Runtime . PyNone ) ;
44
- Runtime . PyDict_SetItemString ( dict , "__doc__" , Runtime . PyNone ) ;
55
+ Runtime . PyDict_SetItemString ( dict , "__file__" , pyfilename ) ;
56
+ Runtime . PyDict_SetItemString ( dict , "__doc__" , pydocstring ) ;
57
+ Runtime . PyDict_SetItemString ( dict , "__class__" , pycls ) ;
45
58
Runtime . Decref ( pyname ) ;
59
+ Runtime . Decref ( pyfilename ) ;
60
+ Runtime . Decref ( pydocstring ) ;
46
61
47
62
Marshal . WriteIntPtr ( this . pyHandle , ObjectOffset . DictOffset ( this . pyHandle ) , dict ) ;
48
63
0 commit comments