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("