[svn] commit: r2086 - in /experiments/python-binding/src/lib/dns/python: TODO message_python.cc name_python.cc rrclass_python.cc rrttl_python.cc rrtype_python.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jun 7 15:27:05 UTC 2010
Author: jelte
Date: Mon Jun 7 15:27:05 2010
New Revision: 2086
Log:
check types in all richcmp functions
Modified:
experiments/python-binding/src/lib/dns/python/TODO
experiments/python-binding/src/lib/dns/python/message_python.cc
experiments/python-binding/src/lib/dns/python/name_python.cc
experiments/python-binding/src/lib/dns/python/rrclass_python.cc
experiments/python-binding/src/lib/dns/python/rrttl_python.cc
experiments/python-binding/src/lib/dns/python/rrtype_python.cc
Modified: experiments/python-binding/src/lib/dns/python/TODO
==============================================================================
--- experiments/python-binding/src/lib/dns/python/TODO (original)
+++ experiments/python-binding/src/lib/dns/python/TODO Mon Jun 7 15:27:05 2010
@@ -4,27 +4,12 @@
same for RRType? (xfrout.py.in line 256)
-__str__ for name, question, everything with to_text()
-rich compare for name (at least so we can have ==)
-
-should Name.downcase() return a ref to itself?
-
-All constructors based on buffers need an optional position
-argument (like question_python has now)
-
-at question.to_wire(bytes) does not seem to work right (only return
-value seems correct, while i'd like in-place addition if possible)
-
creating a render message and not setting opcode/rcode results in a segfault later (nullpointer)
-
+(is this cpp or python problem?)
The function set wrapped is not complete; for instance, in
MessageRenderer, we really only provide the high-level readout
functions. Do we need access to the writers? (there is one set() right
now).
-All constants are now added named in the base module, while they should
-be added as class constants. Dunno how though.
-
-
segfault when comparing with bad type like int (at least for Name and Rcode, but probably for the rest too)
Modified: experiments/python-binding/src/lib/dns/python/message_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/message_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/message_python.cc Mon Jun 7 15:27:05 2010
@@ -624,6 +624,14 @@
{
bool c = false;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
// Only equals and not equals here, unorderable type
switch (op) {
case Py_LT:
@@ -1089,6 +1097,14 @@
{
bool c;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
// Only equals and not equals here, unorderable type
switch (op) {
case Py_LT:
@@ -1295,6 +1311,14 @@
Section_richcmp(s_Section* self, s_Section* other, int op)
{
bool c;
+
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
// Only equals and not equals here, unorderable type
switch (op) {
Modified: experiments/python-binding/src/lib/dns/python/name_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/name_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/name_python.cc Mon Jun 7 15:27:05 2010
@@ -218,7 +218,7 @@
"Concatenates the given Name object to this one and returns the "
"result as a new Name object" },
{ "downcase", (PyCFunction)Name_downcase, METH_NOARGS,
- "Downcases this name object (in-place)." },
+ "Downcases this name object (in-place). Returns a new reference to the Name." },
{ "is_wildcard", (PyCFunction)Name_isWildCard, METH_NOARGS,
"Returns True if the Name object represents a wildcard name." },
{ NULL, NULL, 0, NULL }
@@ -500,6 +500,14 @@
{
bool c;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!n2 ||
+ ((PyObject*)n1)->ob_type != ((PyObject*)n2)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
switch (op) {
case Py_LT:
c = n1->name->lthan(*n2->name);
@@ -572,7 +580,8 @@
Name_downcase(s_Name* self)
{
self->name->downcase();
- Py_RETURN_NONE;
+ Py_INCREF(self);
+ return (PyObject*) self;
}
static PyObject*
Modified: experiments/python-binding/src/lib/dns/python/rrclass_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrclass_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrclass_python.cc Mon Jun 7 15:27:05 2010
@@ -252,6 +252,14 @@
{
bool c;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
switch (op) {
case Py_LT:
c = *self->rrclass < *other->rrclass;
Modified: experiments/python-binding/src/lib/dns/python/rrttl_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrttl_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrttl_python.cc Mon Jun 7 15:27:05 2010
@@ -257,6 +257,14 @@
{
bool c;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
switch (op) {
case Py_LT:
c = *self->rrttl < *other->rrttl;
Modified: experiments/python-binding/src/lib/dns/python/rrtype_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrtype_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrtype_python.cc Mon Jun 7 15:27:05 2010
@@ -260,6 +260,14 @@
{
bool c;
+ // Check for null and if the types match. If different type,
+ // simply return False
+ if (!other ||
+ ((PyObject*)self)->ob_type != ((PyObject*)other)->ob_type
+ ) {
+ Py_RETURN_FALSE;
+ }
+
switch (op) {
case Py_LT:
c = *self->rrtype < *other->rrtype;
More information about the bind10-changes
mailing list