From cf46feb79e55ba68f816156e09e4236709b0d68e Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Fri, 4 Jun 2010 12:50:22 -0400 Subject: [PATCH] timestamps need to use unsigned in bson encoder/decoder --- pymongo/_cbsonmodule.c | 5 ++--- pymongo/bson.py | 13 +++++++------ pymongo/connection.py | 2 +- pymongo/timestamp.py | 2 +- test/test_database.py | 4 +++- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pymongo/_cbsonmodule.c b/pymongo/_cbsonmodule.c index b6a45398d..07d7fe78d 100644 --- a/pymongo/_cbsonmodule.c +++ b/pymongo/_cbsonmodule.c @@ -1497,11 +1497,10 @@ static PyObject* get_value(const char* buffer, int* position, int type, } case 17: { - int time, - inc; + unsigned int time, inc; memcpy(&inc, buffer + *position, 4); memcpy(&time, buffer + *position + 4, 4); - value = PyObject_CallFunction(Timestamp, "ii", time, inc); + value = PyObject_CallFunction(Timestamp, "II", time, inc); if (!value) { return NULL; } diff --git a/pymongo/bson.py b/pymongo/bson.py index 2ab73a05e..35a49a11b 100644 --- a/pymongo/bson.py +++ b/pymongo/bson.py @@ -50,9 +50,10 @@ except ImportError: RE_TYPE = type(re.compile("")) -def _get_int(data, as_class=None): +def _get_int(data, as_class=None, unsigned=False): + format = unsigned and "I" or "i" try: - value = struct.unpack("