Commit Graph

132 Commits

Author SHA1 Message Date
Bernie Hackett
0558e4b3a4 PYTHON-996 - More aggressively lower recursion limit 2015-09-23 16:42:42 -07:00
Bernie Hackett
40e0d9d14b PYTHON-996 - Work around overflow handling change in python 3.5 2015-09-23 16:11:11 -07:00
Bernie Hackett
4bbe2133a1 PYTHON-996 - Adjust regex tests for python 3.5 2015-09-22 15:17:50 -07:00
Luke Lovett
3321b66d34 PYTHON-977 - Fix __hash__ method on BSON types that inherit from Python builtin types.
In Python 2, objects automatically inherit the __hash__ of their parent
class. In Python 3, objects that override __eq__ do not automatically inherit
__hash__, so these objects were not hashable under Python 3.  Additionally,
mutable BSON types and types that overide __eq__ but did not explicitly define
__hash__ had broken __hash__ methods under Python 2.  This commit unifies the
hashing behavior between Python versions and fixes the __hash__ methods such
that two BSON objects hash the same only if they are equal.

N.B.: bson.code.Code and bson.regex.Regex are no longer hashable under Python 2
because they are mutable.
2015-09-04 14:45:24 -07:00
Luke Lovett
880394fe99 PYTHON-222 - Add a 'tzinfo' attribute to CodecOptions that specifies a timezone to which to decode datetime objects. 2015-07-09 13:32:23 -07:00
aherlihy
39308c4b2f PYTHON-721 - Add unicode_decode_error_handler to CodecOptions. 2015-07-09 15:08:02 -04:00
Bernie Hackett
3716b449cc PYTHON-871 - Fix encoding of defaultdict. 2015-03-27 14:35:09 -07:00
Bernie Hackett
c87424e7af PYTHON-856 - as_class -> document_class
This commit changes the name of the as_class option
in CodecOptions to document_class, to match the name
of the MongoClient option.
2015-03-09 14:32:42 -07:00
A. Jesse Jiryu Davis
9da835ab3d PYTHON-825 BSON API changes and internal options handling.
This change resolves four issues:

PYTHON-826 The new codec_options submodule is moved from pymongo to bson.

PYTHON-827 Use codec_options in BSON APIs.

Functions and methods of the bson module that accepted the options as_class,
tz_aware, and uuid_subtype now accept a codec_options parameter instead.

For example, the function definition for bson.decode_all changes from this:

def decode_all(data, as_class=dict, tz_aware=True,
               uuid_subtype=OLD_UUID_SUBTYPE)

to:

def decode_all(data, codec_options=CodecOptions())

The following functions are changed:

- decode_all
- decode_iter
- decode_file_iter

The following methods are changed:

- BSON.encode
- BSON.decode

This is a breaking change for any application that uses the BSON API directly
and changes any of the named parameter defaults. No changes are required for
applications that use the default values for these options. The behavior
remains the same.

PYTHON-828 Internal BSON module changes to support CodecOptions

The pure Python BSON module passes around a CodecOptions instance instead of
as_class, tz_aware, and uuid_subtype. C extensions pass these values around in
a struct.

PYTHON-801 Rename uuid_subtype to uuid_representation.
2015-02-05 23:09:23 -06:00
A. Jesse Jiryu Davis
2ba730722b PYTHON-526 Remove 'compile_re' option.
PyMongo now never attempts to compile BSON regular expressions as Python native
regular expressions.
2014-12-05 14:06:38 -05:00
Bernie Hackett
811b636fae Fix decode_(file_)iter tests for 3.0-dev. 2014-11-24 13:14:39 -08:00
Heewa Barfchin
b948b08854 Add generator versions of decode_all in bson.
When decoding large collections of bson documents, the python representation
of dicts are time and space costly, so it's sometimes useful to generate and
consume the documents iteratively. This patch adds two new functions to do
that: decode_iter and decode_file_iter. The first is given all the bson data,
but yields one document at a time, while the second reads from a file object
enough to yield one document at a time (to avoid reading in an entire file).
2014-11-24 13:14:39 -08:00
Bernie Hackett
9c8852d93f PYTHON-760 - BSONInt64 -> Int64 2014-09-23 11:43:41 -07:00
Bernie Hackett
3396ea94cc PYTHON-505 - Fix bson tests under Jython2.7.
Re-introduces a workaround for http://bugs.jython.org/issue1728,
which looks like it will finally be fixed in Jython2.7b4.
2014-08-22 16:43:05 -07:00
Luke Lovett
17fb3a2a02 PYTHON-505 Allow C extensions to encode any mapping type, not just dicts. 2014-08-13 16:16:25 +00:00
Luke Lovett
5136bb723c PYTHON-707 Add a BSONInt64 type. 2014-07-18 14:59:21 +00:00
Luke Lovett
141200083e PYTHON-680 Stop using nose in favor of pure unittest/unittest2 2014-04-25 22:57:33 +00:00
Bernie Hackett
b26459cd6a Remove useless uuid module checks.
These were only needed for python 2.4 which does
not provide a uuid module.
2014-04-24 10:09:21 -07:00
Luke Lovett
4d6d1e067b PYTHON-676 python 2/3 single-source for the test module 2014-04-23 18:37:02 +00:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
Kyle Erf
e100ddcb20 PYTHON-623: do not allow sending _ids with a key starting with $ 2014-01-14 12:51:37 -08:00
A. Jesse Jiryu Davis
07c4b0b048 Note Python 3’s re.UNICODE behavior, and fix test_regex_from_native for Python 3. 2013-12-08 22:26:15 -05:00
A. Jesse Jiryu Davis
d625ff2bc9 Rename Regex.compile() to try_compile() and add a warning, add from_native(), PYTHON-500. 2013-12-07 15:37:12 -05:00
A. Jesse Jiryu Davis
489f941d44 Implement rich comparison for Timestamps, PYTHON-609. 2013-12-06 13:39:54 -05:00
A. Jesse Jiryu Davis
c972894953 Implement rich comparison operators for MinKey and MaxKey, PYTHON-604. 2013-12-04 20:38:23 -05:00
A. Jesse Jiryu Davis
8650bdcf5f Don't test error messages in test_bson 2013-10-21 21:07:03 -04:00
A. Jesse Jiryu Davis
72a90b75c6 Wrap all BSON-decoding errors in InvalidBSON exception. PYTHON-494 2013-10-21 20:41:13 -04:00
A. Jesse Jiryu Davis
e4cf504559 Option to not compile BSON regexes. PYTHON-500
Add a 'compile_re' parameter to Collection.find, Collection.find_one, and
json_util.loads. If it's False, regular expressions are encoded as a new class,
Regex, instead of passed to re.compile(). This allows PyMongo to handle regular
expressions that don't compile in Python but are valid in other contexts like
MongoDB queries.
2013-10-20 17:18:32 -04:00
Bernie Hackett
989a0f4f4d Avoid unsigned overflow wrapping PYTHON-571 2013-10-15 17:25:16 -07:00
Bernie Hackett
2b1ea1fdeb Fix _cbson DBPointer decoding in py3 PYTHON-586 2013-10-15 16:58:08 -07:00
behackett
ab4d63b658 Better handling of corrupt/invalid BSON PYTHON-571 2013-10-08 13:41:32 -07:00
Bernie Hackett
a83f1d62e4 Add bson only test_bad_dbref. 2013-08-30 16:20:12 -07:00
A. Jesse Jiryu Davis
f1f7b14bf6 Allow MongoClients to be GC'ed after test runs.
Work around http://bugs.python.org/issue11798 to reduce max connection count during tests.
2013-08-27 09:00:50 -04:00
A. Jesse Jiryu Davis
d133396162 Revert "Capture all BSON decode errors and wrap with InvalidBSON. PYTHON-494"
This reverts commit ba66a2dde7.
2013-08-17 22:35:17 -04:00
A. Jesse Jiryu Davis
ba66a2dde7 Capture all BSON decode errors and wrap with InvalidBSON. PYTHON-494 2013-08-14 11:50:36 -04:00
A. Jesse Jiryu Davis
9103755d06 Better error message when C extension raises InvalidStringData, PYTHON-533 2013-06-06 13:33:48 -05:00
A. Jesse Jiryu Davis
d35bec12e5 Tests use MongoClient instead of Connection PYTHON-451 2013-02-11 20:57:17 -05:00
Bernie Hackett
168fdc61cd Fix accuracy issues in datetime decoding PYTHON-392 2012-12-14 13:21:32 -08:00
Bernie Hackett
7c67e5b7f4 Work around Jython dict equality issue PYTHON-441
See http://bugs.jython.org/issue1728
2012-11-23 10:00:53 -08:00
A. Jesse Jiryu Davis
461e2529f7 Informative message whenever skipping a test 2012-08-21 23:24:47 -04:00
Bernie Hackett
a66304f7a2 Fix BSON size validation PYTHON-370 2012-07-23 08:11:03 -07:00
behackett
0ee7170cc2 It's 2012... 2012-04-19 12:40:38 -07:00
Bernie Hackett
909d54c80c Work around a Jython-2.5.2 bug. 2012-03-30 22:58:48 -07:00
behackett
12592be1fe Python 3 unittest changes PYTHON-84. 2012-03-28 11:53:47 -07:00
behackett
2d21ba9376 Replace deprecated unittest assert method aliases.
assert_ -> assertTrue
assertEquals -> assertEqual

This is needed to clean up deprecation warnings
in python >= 3.2
2012-03-16 17:20:21 -07:00
Ross Lawley
271767f5b3 Can now store type 13 - JS without scope
Changes the default behaviour of bson.Code as now if
not passing scope it will convert to type 13 not 15.
2012-02-08 14:35:49 -08:00
behackett
8bdb7821a9 Always decode to UUID PYTHON-267 2011-09-14 15:11:58 -07:00
behackett
258f81870e Store UUIDs as BSON binary subtype 4 PYTHON-267
The default binary subtype for UUIDs has changed
to 4. You can use bson.binary.UUIDLegacy to query
on UUIDs previously stored as subtype 3. See the
UUIDLegacy docstring for more details.
2011-09-14 13:12:36 -07:00
behackett
ae0dc87c6f Fix a test failure caused by the Binary change. 2011-08-03 14:26:57 -07:00
behackett
1e100405be More invalid BSON handling PYTHON-252 2011-06-14 11:53:06 -07:00