[svn] commit: r2728 - in /trunk/src/lib/dns/python: message_python.cc name_python.cc question_python.cc rrclass_python.cc rrset_python.cc rrttl_python.cc rrtype_python.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Aug 14 00:47:22 UTC 2010
Author: jinmei
Date: Sat Aug 14 00:47:21 2010
New Revision: 2728
Log:
minor cleanup:
- catch exceptions by reference
- and constify them
should be trivial enough, so I'm skipping explicit review.
Modified:
trunk/src/lib/dns/python/message_python.cc
trunk/src/lib/dns/python/name_python.cc
trunk/src/lib/dns/python/question_python.cc
trunk/src/lib/dns/python/rrclass_python.cc
trunk/src/lib/dns/python/rrset_python.cc
trunk/src/lib/dns/python/rrttl_python.cc
trunk/src/lib/dns/python/rrtype_python.cc
Modified: trunk/src/lib/dns/python/message_python.cc
==============================================================================
--- trunk/src/lib/dns/python/message_python.cc (original)
+++ trunk/src/lib/dns/python/message_python.cc Sat Aug 14 00:47:21 2010
@@ -589,7 +589,7 @@
try {
self->rcode = new Rcode(code);
self->static_code = false;
- } catch (isc::OutOfRange) {
+ } catch (const isc::OutOfRange&) {
PyErr_SetString(PyExc_OverflowError,
"rcode out of range");
return (-1);
@@ -1221,7 +1221,7 @@
try {
self->message->setHeaderFlag(*messageflag->messageflag);
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
@@ -1238,7 +1238,7 @@
try {
self->message->clearHeaderFlag(*messageflag->messageflag);
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
@@ -1269,7 +1269,7 @@
self->message->setDNSSECSupported(false);
}
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1289,10 +1289,10 @@
try {
self->message->setUDPSize(size);
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageUDPSize imus) {
+ } catch (const InvalidMessageUDPSize& imus) {
PyErr_SetString(po_InvalidMessageUDPSize, imus.what());
return (NULL);
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1312,7 +1312,7 @@
try {
self->message->setQid(id);
Py_RETURN_NONE;
- } catch (InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1344,7 +1344,7 @@
try {
self->message->setRcode(*rcode->rcode);
Py_RETURN_NONE;
- } catch (InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1379,7 +1379,7 @@
try {
self->message->setOpcode(*opcode->opcode);
Py_RETURN_NONE;
- } catch (InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1482,7 +1482,7 @@
self->message->addRRset(*section->section, rrset->rrset, false);
}
Py_RETURN_NONE;
- } catch (InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
}
@@ -1541,7 +1541,7 @@
// If we return NULL it is seen as an error, so use this for
// None returns
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_Clear();
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
@@ -1565,16 +1565,16 @@
try {
self->message->fromWire(inbuf);
Py_RETURN_NONE;
- } catch (isc::dns::InvalidMessageOperation imo) {
+ } catch (const InvalidMessageOperation& imo) {
PyErr_SetString(po_InvalidMessageOperation, imo.what());
return (NULL);
- } catch (isc::dns::DNSMessageFORMERR dmfe) {
+ } catch (const DNSMessageFORMERR& dmfe) {
PyErr_SetString(po_DNSMessageFORMERR, dmfe.what());
return (NULL);
- } catch (isc::dns::DNSMessageBADVERS dmfe) {
+ } catch (const DNSMessageBADVERS& dmfe) {
PyErr_SetString(po_DNSMessageBADVERS, dmfe.what());
return (NULL);
- } catch (isc::dns::MessageTooShort mts) {
+ } catch (const MessageTooShort& mts) {
PyErr_SetString(po_MessageTooShort, mts.what());
return (NULL);
}
Modified: trunk/src/lib/dns/python/name_python.cc
==============================================================================
--- trunk/src/lib/dns/python/name_python.cc (original)
+++ trunk/src/lib/dns/python/name_python.cc Sat Aug 14 00:47:21 2010
@@ -291,26 +291,26 @@
self->name = new Name(n, downcase == Py_True);
self->position = 0;
- } catch (EmptyLabel) {
+ } catch (const EmptyLabel&) {
PyErr_SetString(po_EmptyLabel, "EmptyLabel");
return (-1);
- } catch (TooLongLabel) {
+ } catch (const TooLongLabel&) {
PyErr_SetString(po_TooLongLabel, "TooLongLabel");
return (-1);
- } catch (BadLabelType) {
+ } catch (const BadLabelType&) {
PyErr_SetString(po_BadLabelType, "BadLabelType");
return (-1);
- } catch (BadEscape) {
+ } catch (const BadEscape&) {
PyErr_SetString(po_BadEscape, "BadEscape");
return (-1);
- } catch (TooLongName) {
+ } catch (const TooLongName&) {
PyErr_SetString(po_TooLongName, "TooLongName");
return (-1);
- } catch (IncompleteName) {
+ } catch (const IncompleteName&) {
PyErr_SetString(po_IncompleteName, "IncompleteName");
return (-1);
#ifdef CATCHMEMERR
- } catch (std::bad_alloc) {
+ } catch (const std::bad_alloc&) {
PyErr_NoMemory();
return (-1);
#endif
@@ -338,11 +338,11 @@
buffer.setPosition(position);
self->name = new Name(buffer, downcase == Py_True);
self->position = buffer.getPosition();
- } catch (InvalidBufferPosition) {
+ } catch (const InvalidBufferPosition&) {
PyErr_SetString(po_InvalidBufferPosition,
"InvalidBufferPosition");
return (-1);
- } catch (DNSMessageFORMERR) {
+ } catch (const DNSMessageFORMERR&) {
PyErr_SetString(po_DNSMessageFORMERR, "DNSMessageFORMERR");
return (-1);
} catch (...) {
@@ -373,7 +373,7 @@
}
try {
return (Py_BuildValue("I", self->name->at(pos)));
- } catch (isc::OutOfRange oor) {
+ } catch (const isc::OutOfRange&) {
PyErr_SetString(PyExc_IndexError,
"name index out of range");
return (NULL);
@@ -472,7 +472,7 @@
ret->name = NULL;
try {
ret->name = new Name(self->name->split(first, n));
- } catch(isc::OutOfRange oor) {
+ } catch(const isc::OutOfRange& oor) {
PyErr_SetString(PyExc_IndexError, oor.what());
ret->name = NULL;
}
@@ -487,7 +487,7 @@
ret->name = NULL;
try {
ret->name = new Name(self->name->split(n));
- } catch(isc::OutOfRange oor) {
+ } catch(const isc::OutOfRange& oor) {
PyErr_SetString(PyExc_IndexError, oor.what());
ret->name = NULL;
}
@@ -572,7 +572,7 @@
if (ret != NULL) {
try {
ret->name = new Name(self->name->concatenate(*other->name));
- } catch (isc::dns::TooLongName tln) {
+ } catch (const TooLongName& tln) {
PyErr_SetString(po_TooLongName, tln.what());
return (NULL);
}
Modified: trunk/src/lib/dns/python/question_python.cc
==============================================================================
--- trunk/src/lib/dns/python/question_python.cc (original)
+++ trunk/src/lib/dns/python/question_python.cc Sat Aug 14 00:47:21 2010
@@ -156,15 +156,15 @@
self->question = QuestionPtr(new Question(inbuf));
return (0);
}
- } catch (isc::dns::DNSMessageFORMERR dmfe) {
+ } catch (const DNSMessageFORMERR& dmfe) {
PyErr_Clear();
PyErr_SetString(po_DNSMessageFORMERR, dmfe.what());
return (-1);
- } catch (isc::dns::IncompleteRRClass irc) {
+ } catch (const IncompleteRRClass& irc) {
PyErr_Clear();
PyErr_SetString(po_IncompleteRRClass, irc.what());
return (-1);
- } catch (isc::dns::IncompleteRRType irt) {
+ } catch (const IncompleteRRType& irt) {
PyErr_Clear();
PyErr_SetString(po_IncompleteRRType, irt.what());
return (-1);
Modified: trunk/src/lib/dns/python/rrclass_python.cc
==============================================================================
--- trunk/src/lib/dns/python/rrclass_python.cc (original)
+++ trunk/src/lib/dns/python/rrclass_python.cc Sat Aug 14 00:47:21 2010
@@ -188,7 +188,7 @@
}
// Incomplete is never thrown, a type error would have already been raised
//when we try to read the 2 bytes above
- } catch (InvalidRRClass ic) {
+ } catch (const InvalidRRClass& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRClass, ic.what());
return (-1);
Modified: trunk/src/lib/dns/python/rrset_python.cc
==============================================================================
--- trunk/src/lib/dns/python/rrset_python.cc (original)
+++ trunk/src/lib/dns/python/rrset_python.cc Sat Aug 14 00:47:21 2010
@@ -284,7 +284,7 @@
RRset_toText(s_RRset* self) {
try {
return (Py_BuildValue("s", self->rrset->toText().c_str()));
- } catch (EmptyRRset ers) {
+ } catch (const EmptyRRset& ers) {
PyErr_SetString(po_EmptyRRset, ers.what());
return (NULL);
}
@@ -321,7 +321,7 @@
// None returns
Py_RETURN_NONE;
}
- } catch (EmptyRRset ers) {
+ } catch (const EmptyRRset& ers) {
PyErr_Clear();
PyErr_SetString(po_EmptyRRset, ers.what());
return (NULL);
@@ -341,7 +341,7 @@
try {
self->rrset->addRdata(*rdata->rdata);
Py_RETURN_NONE;
- } catch (std::bad_cast) {
+ } catch (const std::bad_cast&) {
PyErr_Clear();
PyErr_SetString(PyExc_TypeError,
"Rdata type to add must match type of RRset");
Modified: trunk/src/lib/dns/python/rrttl_python.cc
==============================================================================
--- trunk/src/lib/dns/python/rrttl_python.cc (original)
+++ trunk/src/lib/dns/python/rrttl_python.cc Sat Aug 14 00:47:21 2010
@@ -177,7 +177,7 @@
PyErr_Clear();
return (0);
}
- } catch (IncompleteRRTTL icc) {
+ } catch (const IncompleteRRTTL& icc) {
// Ok so one of our functions has thrown a C++ exception.
// We need to translate that to a Python Exception
// First clear any existing error that was set
@@ -186,7 +186,7 @@
PyErr_SetString(po_IncompleteRRTTL, icc.what());
// And return negative
return (-1);
- } catch (InvalidRRTTL ic) {
+ } catch (const InvalidRRTTL& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRTTL, ic.what());
return (-1);
Modified: trunk/src/lib/dns/python/rrtype_python.cc
==============================================================================
--- trunk/src/lib/dns/python/rrtype_python.cc (original)
+++ trunk/src/lib/dns/python/rrtype_python.cc Sat Aug 14 00:47:21 2010
@@ -217,7 +217,7 @@
PyErr_Clear();
return (0);
}
- } catch (IncompleteRRType icc) {
+ } catch (const IncompleteRRType& icc) {
// Ok so one of our functions has thrown a C++ exception.
// We need to translate that to a Python Exception
// First clear any existing error that was set
@@ -226,7 +226,7 @@
PyErr_SetString(po_IncompleteRRType, icc.what());
// And return negative
return (-1);
- } catch (InvalidRRType ic) {
+ } catch (const InvalidRRType& ic) {
PyErr_Clear();
PyErr_SetString(po_InvalidRRType, ic.what());
return (-1);
More information about the bind10-changes
mailing list