summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-10-26 08:44:06 +0200
committerIlya Etingof <etingof@gmail.com>2018-10-26 08:44:06 +0200
commitc8d699ca0a1245b1fd0c630611b9c523bf90329a (patch)
treee1cc4683708da6aa5e6410208a05a152cbda622f
parent5057a1fd59e1f1e5818f5da945677835bae38ad9 (diff)
downloadpysnmp-git-c8d699ca0a1245b1fd0c630611b9c523bf90329a.tar.gz
Expose ASN.1 `Null` type through `rfc1902` module
-rw-r--r--CHANGES.txt1
-rw-r--r--docs/source/docs/api-reference.rst14
-rw-r--r--pysnmp/proto/rfc1902.py27
3 files changed, 41 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index f2563d03..ed0d26bd 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
Revision 4.4.7, released 2018-11-XX
-----------------------------------
+- Exposed ASN.1 `Null` type through `rfc1902` module for convenience.
- Use `compile()` before `exec`'ing MIB modules to attach filename to
the stack frames (ultimately shown in traceback/debugger)
- Fixed hlapi/v3arch transport target caching to ensure transport targets
diff --git a/docs/source/docs/api-reference.rst b/docs/source/docs/api-reference.rst
index d867db46..bc6f5693 100644
--- a/docs/source/docs/api-reference.rst
+++ b/docs/source/docs/api-reference.rst
@@ -340,6 +340,20 @@ data description language. PySNMP types are derived from
.. toctree::
:maxdepth: 2
+.. _null:
+
+Null type
++++++++++
+
+.. autoclass:: pysnmp.proto.rfc1902.Null(initializer)
+ :members:
+
+.. note::
+
+ The `NULL` type actually belongs to the base ASN.1 types. It is not defined
+ in :RFC:`1902#section-2` as an SNMP type. The `Null` type is exposed through
+ `rfc1902` module just for convenience.
+
.. _integer32:
Integer32 type
diff --git a/pysnmp/proto/rfc1902.py b/pysnmp/proto/rfc1902.py
index 3caa81d7..4bd82669 100644
--- a/pysnmp/proto/rfc1902.py
+++ b/pysnmp/proto/rfc1902.py
@@ -10,7 +10,32 @@ from pysnmp.proto import rfc1155, error
__all__ = ['Opaque', 'TimeTicks', 'Bits', 'Integer', 'OctetString',
'IpAddress', 'Counter64', 'Unsigned32', 'Gauge32', 'Integer32',
- 'ObjectIdentifier', 'Counter32']
+ 'ObjectIdentifier', 'Counter32', 'Null']
+
+
+class Null(univ.Null):
+ """Creates an instance of SNMP Null class.
+
+ :py:class:`~pysnmp.proto.rfc1902.Null` type represents the absence
+ of value.
+
+ Parameters
+ ----------
+ initializer: str
+ Python string object. Must be an empty string.
+
+ Raises
+ ------
+ PyAsn1Error :
+ On constraint violation or bad initializer.
+
+ Examples
+ --------
+ >>> from pysnmp.proto.rfc1902 import *
+ >>> Null('')
+ Null('')
+ >>>
+ """
class Integer32(univ.Integer):