Skip to content

Commit 61ec201

Browse files
committed
OIDs: Add dotted_form and byte_form properties
This introduces two new properties, dotted_form, for querying the dotted form of the OID, and byte_form, for querying the raw OID encoding. By making __bytes__ and __hash__ rely on byte_form, infinite recursion is prevented when deriving a subclass that overrides __bytes__. Signed-off-by: Alexander Scheel <[email protected]>
1 parent 1254810 commit 61ec201

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gssapi/raw/oids.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,12 @@ cdef class OID:
156156
pos += 1
157157
return decoded
158158

159+
@property
160+
def dotted_form(self):
161+
return '.'.join(str(x) for x in self._decode_asn1ber())
162+
159163
def __repr__(self):
160-
dotted_oid = '.'.join(str(x) for x in self._decode_asn1ber())
161-
return "<OID {0}>".format(dotted_oid)
164+
return "<OID {0}>".format(self.dotted_form)
162165

163166
def __hash__(self):
164167
return hash(self.__bytes__())

0 commit comments

Comments
 (0)