diff options
author | bastb <bastb@tenberge-ict.nl> | 2016-05-27 20:46:27 +0200 |
---|---|---|
committer | bastb <bastb@tenberge-ict.nl> | 2016-05-27 20:46:27 +0200 |
commit | e69b20323ee74d5b63a688d6f875120fffed474f (patch) | |
tree | 10cdb62537abf4de91f58cf0ea12c4a2c0098474 | |
parent | a0c96ff8584ec59659656eed3e0e42d29f52dade (diff) | |
download | py-amqp-e69b20323ee74d5b63a688d6f875120fffed474f.tar.gz |
Fixes issue #85: the module can be imported on python 2.7.3 running in unicode mode. I guess sys.setdefaultencoding('utf-8') breaks the arguments to the pack
-rw-r--r-- | amqp/basic_message.py | 13 | ||||
-rw-r--r-- | amqp/exceptions.py | 2 | ||||
-rw-r--r-- | amqp/serialization.py | 4 |
3 files changed, 15 insertions, 4 deletions
diff --git a/amqp/basic_message.py b/amqp/basic_message.py index b7921fe..8cd5a11 100644 --- a/amqp/basic_message.py +++ b/amqp/basic_message.py @@ -16,6 +16,17 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 from __future__ import absolute_import, unicode_literals +# Intended to fix #85: ImportError: cannot import name spec +# Encountered on python 2.7.3 +# "The submodules often need to refer to each other. For example, the +# surround [sic] module might use the echo module. In fact, such +# references are so common that the import statement first looks in +# the containing package before looking in the standard module search +# path." +# Source: +# http://stackoverflow.com/a/14216937/4982251 +from .spec import Basic + from . import spec from .serialization import GenericContent @@ -24,7 +35,7 @@ __all__ = ['Message'] class Message(GenericContent): """A Message for use with the Channnel.basic_* methods.""" - CLASS_ID = spec.Basic.CLASS_ID + CLASS_ID = Basic.CLASS_ID #: Instances of this class have these attributes, which #: are passed back and forth as message properties between diff --git a/amqp/exceptions.py b/amqp/exceptions.py index 9216002..f7aaf87 100644 --- a/amqp/exceptions.py +++ b/amqp/exceptions.py @@ -254,4 +254,4 @@ METHOD_NAME_MAP = { for _method_id, _method_name in list(METHOD_NAME_MAP.items()): - METHOD_NAME_MAP[unpack('>I', pack('>HH', *_method_id))[0]] = _method_name + METHOD_NAME_MAP[unpack(str('>I'), pack(str('>HH'), *_method_id))[0]] = _method_name diff --git a/amqp/serialization.py b/amqp/serialization.py index c66b9f7..4c7284d 100644 --- a/amqp/serialization.py +++ b/amqp/serialization.py @@ -30,7 +30,7 @@ from io import BytesIO from struct import pack, unpack_from from time import mktime -from . import spec +from .spec import Basic from .exceptions import FrameSyntaxError from .five import int_types, long_t, string, string_t, items from .utils import bytes_to_str as pstr_t, str_to_bytes @@ -470,7 +470,7 @@ def decode_properties_basic(buf, offset=0, return properties, offset PROPERTY_CLASSES = { - spec.Basic.CLASS_ID: decode_properties_basic, + Basic.CLASS_ID: decode_properties_basic, } |