FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/pymodule.cs at master · ashsvis/pythonnet · GitHub
ashsvis
pythonnet
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
pymodule.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (37 loc) · 1.45 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
pymodule.cs
Copy path
File metadata and controls
41 lines (37 loc) · 1.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using
System
;
namespace
Python
.
Runtime
{
public
class
PyModule
:
PyScope
{
internal
PyModule
(
ref
NewReference
reference
)
:
base
(
ref
reference
,
PyScopeManager
.
Global
)
{
}
public
PyModule
(
PyObject
o
)
:
base
(
o
.
Reference
,
PyScopeManager
.
Global
)
{
}
/// <summary>
/// Given a module or package name, import the
/// module and return the resulting module object as a <see cref="PyModule"/>.
/// </summary>
/// <param name="name">Fully-qualified module or package name</param>
public
static
PyModule
Import
(
string
name
)
{
NewReference
op
=
Runtime
.
PyImport_ImportModule
(
name
)
;
PythonException
.
ThrowIfIsNull
(
op
)
;
return
new
PyModule
(
ref
op
)
;
}
/// <summary>
/// Reloads the module, and returns the updated object
/// </summary>
public
PyModule
Reload
(
)
{
NewReference
op
=
Runtime
.
PyImport_ReloadModule
(
this
.
Reference
)
;
PythonException
.
ThrowIfIsNull
(
op
)
;
return
new
PyModule
(
ref
op
)
;
}
public
static
PyModule
FromString
(
string
name
,
string
code
)
{
using
NewReference
c
=
Runtime
.
Py_CompileString
(
code
,
"none"
,
(
int
)
RunFlagType
.
File
)
;
PythonException
.
ThrowIfIsNull
(
c
)
;
NewReference
m
=
Runtime
.
PyImport_ExecCodeModule
(
name
,
c
)
;
PythonException
.
ThrowIfIsNull
(
m
)
;
return
new
PyModule
(
ref
m
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL