summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/messaging/message.py8
-rw-r--r--qpid/python/qpid/tests/messaging/message.py4
2 files changed, 9 insertions, 3 deletions
diff --git a/qpid/python/qpid/messaging/message.py b/qpid/python/qpid/messaging/message.py
index a9660b05b1..d89fa00dc3 100644
--- a/qpid/python/qpid/messaging/message.py
+++ b/qpid/python/qpid/messaging/message.py
@@ -47,20 +47,22 @@ TYPE_MAPPINGS={
None.__class__: None
}
+DEFAULT_CODEC = (lambda x: x, lambda x: x)
+
TYPE_CODEC={
"amqp/map": codec("map"),
"amqp/list": codec("list"),
"text/plain; charset=utf8": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")),
"text/plain": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")),
- "": (lambda x: x, lambda x: x),
- None: (lambda x: x, lambda x: x)
+ "": DEFAULT_CODEC,
+ None: DEFAULT_CODEC
}
def get_type(content):
return TYPE_MAPPINGS[content.__class__]
def get_codec(content_type):
- return TYPE_CODEC[content_type]
+ return TYPE_CODEC.get(content_type, DEFAULT_CODEC)
UNSPECIFIED = object()
diff --git a/qpid/python/qpid/tests/messaging/message.py b/qpid/python/qpid/tests/messaging/message.py
index 654076588b..f2701af64b 100644
--- a/qpid/python/qpid/tests/messaging/message.py
+++ b/qpid/python/qpid/tests/messaging/message.py
@@ -107,3 +107,7 @@ class MessageEchoTests(Base):
msg.properties = MessageEchoTests.TEST_MAP
msg.reply_to = "reply-address"
self.check(msg)
+
+ def testContentTypeUnknown(self):
+ msg = Message(content_type = "this-content-type-does-not-exist")
+ self.check(msg)