Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Fix some of the feedback
  • Loading branch information
slide committed Jul 28, 2021
commit d4a32ed37dcc36d9ce9a9b9b5a8f4e502be9af26
9 changes: 7 additions & 2 deletions src/runtime/pymodule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,19 @@ public static bool IsInSysModules(string name)

public static PyModule Create(string name, string filename=null)
{
if(string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException(nameof(name));
}

NewReference op = Runtime.PyModule_New(name);
Comment thread
slide marked this conversation as resolved.
PythonException.ThrowIfIsNull(op);

if (filename != null)
{
BorrowedReference globals = Runtime.PyModule_GetDict(new BorrowedReference(op.DangerousGetAddress()));
BorrowedReference globals = Runtime.PyModule_GetDict(op);
PythonException.ThrowIfIsNull(globals);
int rc = Runtime.PyDict_SetItemString(globals, "__file__", new BorrowedReference(filename.ToPython().Handle));
int rc = Runtime.PyDict_SetItemString(globals, "__file__", filename.ToPython().Reference);
PythonException.ThrowIfIsNotZero(rc);
}

Expand Down