Skip to content

Commit

Permalink
update docs for v1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vsergeev committed Sep 17, 2014
1 parent 8052d14 commit 7e0adcc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
* Version 1.6
* Version 1.8 - 09/17/2014
* Add support for unpacking maps with array container keys. Thanks to ralphjzhang for the report and suggestion (https://github.com/vsergeev/u-msgpack-python/issues/10).

* Version 1.6 - 01/17/2014
* Fix wide character unicode string serialization. Thanks to cforger for the bug report and fix (https://github.com/vsergeev/u-msgpack-python/issues/8).
* Add module docstrings.
* Add module `version` tuple.
* Add Python standard library style `dumps` and `loads` serialization/deserialization aliases.
* Rename unpack exceptions `KeyNotPrimitiveException` -> `UnhashableKeyException` and `KeyDuplicateException` -> `DuplicateKeyException`. Add aliases for backwards compatibility.

* Version 1.5
* Version 1.5 - 12/09/2013
* Hide internal helper functions from module's exported names.
* Make unit tests more portable among interpreters (CPython, PyPy).
* Update documentation for PyPy support.

* Version 1.4
* Version 1.4 - 11/21/2013
* Add type checking to Ext class initialization.
* Add support for Python 2.6.

* Version 1.2
* Version 1.2 - 10/19/2013
* Add compatibility mode to support old specification "raw" bytes msgpack type.

* Version 1.0
* Version 1.0 - 09/29/2013
* Initial release.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Ivan A. Sergeev
Copyright (c) 2013-2014 Ivan A. Sergeev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# u-msgpack-python v1.6
# u-msgpack-python v1.8

u-msgpack-python is a lightweight [MessagePack](http://msgpack.org/) serializer and deserializer module written in pure Python, compatible with both Python 2 and 3, as well CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md). In particular, it supports the new binary, UTF-8 string, and application ext types.

Expand Down Expand Up @@ -35,28 +35,26 @@ Basic Example:

A more complicated example:
``` python
>>> umsgpack.packb( \
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
>>> umsgpack.packb( [1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb
@\x00\xfc\xd3Z\x85\x87\x94'
>>> umsgpack.unpackb(_)
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02', \
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02',
u'bar': [1, 2, 3, {u'a': [1, 2, 3, {}]}]}, -1, 2.12345]
>>>
```

The more complicated example in Python 3:
``` python
>>> umsgpack.packb( \
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
>>> umsgpack.packb( [1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
b'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb@
\x00\xfc\xd3Z\x85\x87\x94'
>>> umsgpack.unpackb(_)
[1, True, False, 4294967295, {'foo': b'\x80\x01\x02', \
[1, True, False, 4294967295, {'foo': b'\x80\x01\x02',
'bar': [1, 2, 3, {'a': [1, 2, 3, {}]}]}, -1, 2.12345]
>>>
```
Expand Down Expand Up @@ -182,15 +180,15 @@ If a non-byte-string argument is passed to `umsgpack.unpackb()`, it will raise a
>>>
```

* `UnhashableKeyException`: Unhashable key encountered during map unpacking. The serialized map cannot be deserialized into a Python dictionary.
* `UnhashableKeyException`: Unhashable key encountered during map unpacking. The packed map cannot be unpacked into a Python dictionary.

Python dictionaries only support keys that are instances of `collections.Hashable`, so while the map `{ { u'abc': True } : 5 }` has a msgpack encoding, it cannot be unpacked into a valid Python dictionary.

``` python
# Attempt to unpack { {} : False }
>>> umsgpack.unpackb(b"\x82\x80\xc2")
...
umsgpack.UnhashableKeyException: encountered unhashable key type: <type 'dict'>
umsgpack.UnhashableKeyException: encountered unhashable key type: {}, <type 'dict'>
>>>
```

Expand All @@ -214,8 +212,9 @@ If a non-byte-string argument is passed to `umsgpack.unpackb()`, it will raise a
* Python 3
* `str` type objects are packed into, and unpacked from, the msgpack `string` format
* `bytes` type objects are packed into, and unpacked from, the msgpack `binary` format
* The msgpack string format is strictly decoded with UTF-8. An exception is thrown if the string bytes cannot be decoded into a valid UTF-8 string.
* The msgpack array format is unpacked into a Python list, not tuple
* The msgpack string format is strictly decoded with UTF-8 -- an exception is thrown if the string bytes cannot be decoded into a valid UTF-8 string
* The msgpack array format is unpacked into a Python list, unless it is the key of a map, in which case it is unpacked into a Python tuple
* Python tuples and lists are both packed into the msgpack array format
* Python float types are packed into the msgpack float32 or float64 format depending on the system's `sys.float_info`

## Testing
Expand All @@ -226,6 +225,7 @@ u-msgpack-python's included unit tests may be run with `test_umsgpack.py`, under
$ python2 test_umsgpack.py
$ python3 test_umsgpack.py
$ pypy test_umsgpack.py
$ pypy3 test_umsgpack.py
```

## License
Expand Down
18 changes: 9 additions & 9 deletions msgpack.org.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# u-msgpack-python v1.6
# u-msgpack-python v1.8

u-msgpack-python is a lightweight [MessagePack](http://msgpack.org/) serializer and deserializer module written in pure Python, compatible with both Python 2 and 3, as well CPython and PyPy implementations of Python. u-msgpack-python is fully compliant with the latest [MessagePack specification](https://github.com/msgpack/msgpack/blob/master/spec.md).

Expand Down Expand Up @@ -34,28 +34,28 @@ Basic Example:
```
A more complicated example:
``` python
>>> umsgpack.packb( \
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
>>> umsgpack.packb(
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb
@\x00\xfc\xd3Z\x85\x87\x94'
>>> umsgpack.unpackb(_)
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02', \
[1, True, False, 4294967295, {u'foo': '\x80\x01\x02',
u'bar': [1, 2, 3, {u'a': [1, 2, 3, {}]}]}, -1, 2.12345]
>>>
```

The more complicated example in Python 3:
``` python
>>> umsgpack.packb( \
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02", \
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
>>> umsgpack.packb(
[1, True, False, 0xffffffff, {u"foo": b"\x80\x01\x02",
u"bar": [1,2,3, {u"a": [1,2,3,{}]}]}, -1, 2.12345] )
b'\x97\x01\xc3\xc2\xce\xff\xff\xff\xff\x82\xa3foo\xc4\x03\x80\x01
\x02\xa3bar\x94\x01\x02\x03\x81\xa1a\x94\x01\x02\x03\x80\xff\xcb@
\x00\xfc\xd3Z\x85\x87\x94'
>>> umsgpack.unpackb(_)
[1, True, False, 4294967295, {'foo': b'\x80\x01\x02', \
[1, True, False, 4294967295, {'foo': b'\x80\x01\x02',
'bar': [1, 2, 3, {'a': [1, 2, 3, {}]}]}, -1, 2.12345]
>>>
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='u-msgpack-python',
version='1.6',
version='1.8',
description='A portable, lightweight msgpack serializer and deserializer written in pure Python.',
author='vsergeev',
author_email='vsergeev at gmail',
Expand Down

0 comments on commit 7e0adcc

Please sign in to comment.