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
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commit960286d

Browse files
authored
Add IsNone() and Runtime.None (pythonnet#1137)
* Add `PyObject.IsNone()`* Add `Runtime.None` which returns a reference to `None` as a `PyObject` to be able to pass it into Python from .NET
1 parent2e0874a commit960286d

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

‎AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
- Luke Stratman ([@lstratman](https://github.com/lstratman))
4646
- Konstantin Posudevskiy ([@konstantin-posudevskiy](https://github.com/konstantin-posudevskiy))
4747
- Matthias Dittrich ([@matthid](https://github.com/matthid))
48+
- Meinrad Recheis ([@henon](https://github.com/henon))
4849
- Mohamed Koubaa ([@koubaa](https://github.com/koubaa))
4950
- Patrick Stewart ([@patstew](https://github.com/patstew))
5051
- Raphael Nestler ([@rnestler](https://github.com/rnestler))

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1414
- Added support for Jetson Nano.
1515
- Added support for__len__ for .NET classes that implement ICollection
1616
- Added PythonException.Format method to format exceptions the same as traceback.format_exception
17+
- Added Runtime.None to be able to pass None as parameter into Python from .NET
18+
- Added PyObject.IsNone() to check if a Python object is None in .NET.
1719

1820
###Changed
1921

‎src/runtime/pyobject.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,10 @@ public bool IsTrue()
979979
returnRuntime.PyObject_IsTrue(obj)!=0;
980980
}
981981

982+
/// <summary>
983+
/// Return true if the object is None
984+
/// </summary>
985+
publicboolIsNone()=>CheckNone(this)==null;
982986

983987
/// <summary>
984988
/// Dir Method

‎src/runtime/runtime.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,16 @@ private static void ResetPyMembers()
473473
internalstaticIntPtrPyNone;
474474
internalstaticIntPtrError;
475475

476+
publicstaticPyObjectNone
477+
{
478+
get
479+
{
480+
varnone=Runtime.PyNone;
481+
Runtime.XIncref(none);
482+
returnnewPyObject(none);
483+
}
484+
}
485+
476486
/// <summary>
477487
/// Check if any Python Exceptions occurred.
478488
/// If any exist throw new PythonException.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp