Rev 4774: quick patch to allow bencode to handle StaticTuple objects. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-btree-string-intern
John Arbash Meinel
john at arbash-meinel.com
Tue Oct 13 15:36:59 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-btree-string-intern
------------------------------------------------------------
revno: 4774
revision-id: john at arbash-meinel.com-20091013143650-3f2gwb5uzi50tdcl
parent: john at arbash-meinel.com-20091012220919-aybso111vma3deqj
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple-btree-string-intern
timestamp: Tue 2009-10-13 09:36:50 -0500
message:
quick patch to allow bencode to handle StaticTuple objects.
-------------- next part --------------
=== modified file 'bzrlib/_bencode_pyx.pyx'
--- a/bzrlib/_bencode_pyx.pyx 2009-06-05 01:48:32 +0000
+++ b/bzrlib/_bencode_pyx.pyx 2009-10-13 14:36:50 +0000
@@ -58,6 +58,11 @@
void D_UPDATE_TAIL(Decoder, int n)
void E_UPDATE_TAIL(Encoder, int n)
+from bzrlib._static_tuple_c cimport StaticTuple, StaticTuple_CheckExact, \
+ import_static_tuple_c
+
+import_static_tuple_c()
+
cdef class Decoder:
"""Bencode decoder"""
@@ -371,7 +376,8 @@
self._encode_int(x)
elif PyLong_CheckExact(x):
self._encode_long(x)
- elif PyList_CheckExact(x) or PyTuple_CheckExact(x):
+ elif (PyList_CheckExact(x) or PyTuple_CheckExact(x)
+ or StaticTuple_CheckExact(x)):
self._encode_list(x)
elif PyDict_CheckExact(x):
self._encode_dict(x)
=== modified file 'bzrlib/util/_bencode_py.py'
--- a/bzrlib/util/_bencode_py.py 2009-06-10 03:56:49 +0000
+++ b/bzrlib/util/_bencode_py.py 2009-10-13 14:36:50 +0000
@@ -154,6 +154,13 @@
encode_int(int(x), r)
encode_func[BooleanType] = encode_bool
+try:
+ from bzrlib._static_tuple_c import StaticTuple
+except ImportError:
+ pass
+else:
+ encode_func[StaticTuple] = encode_list
+
def bencode(x):
r = []
More information about the bazaar-commits
mailing list