pybsddb with cffi

Check-in [bb079ca309]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:passed test_compare
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:bb079ca3091fe91fd550f4c0cc3be8fc82127bf7
User & Date: broker-3 2013-02-07 13:56:13
Context
2013-02-07
14:39
Trying to pass test_distributed_transactions - no success check-in: 98750dee3e user: broker-3 tags: trunk
13:56
passed test_compare check-in: bb079ca309 user: broker-3 tags: trunk
13:42
passed test_dbshelve check-in: d2e59555d5 user: broker-3 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to bsddb3/db.py.

811
812
813
814
815
816
817

818

819
820
821
822
823
824
825
826
827
828
829
        @ffi.callback("int (*)(DB *, const DBT *, const DBT *)")
        def c_callback(db_, left, right):
            left = ffi.buffer(left.data, left.size)[:]
            right = ffi.buffer(right.data, right.size)[:]
            try:
                ret = callback(left, right)
                if not isinstance(ret, int):

                    raise TypeError("Compare callback MUST return an int.")

            except:
                import traceback
                traceback.print_exc()
                return 0
            return ret
        return c_callback

    def set_bt_compare(self, callback):
        if hasattr(self, "_bt_compare_callback"):
            raise RuntimeError("set_bt_compare() cannot be called more than once")








>
|
>



|







811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
        @ffi.callback("int (*)(DB *, const DBT *, const DBT *)")
        def c_callback(db_, left, right):
            left = ffi.buffer(left.data, left.size)[:]
            right = ffi.buffer(right.data, right.size)[:]
            try:
                ret = callback(left, right)
                if not isinstance(ret, int):
                    import traceback
                    traceback.print_exception(TypeError, "Compare callback MUST return an int.", None)
                    return cmp(left, right)
            except:
                import traceback
                traceback.print_exc()
                return cmp(left, right)
            return ret
        return c_callback

    def set_bt_compare(self, callback):
        if hasattr(self, "_bt_compare_callback"):
            raise RuntimeError("set_bt_compare() cannot be called more than once")