Commit Graph

148 Commits

Author SHA1 Message Date
Shane Harvey
7ca04999e9
PYTHON-1603 Truncate large datetimes properly (#362) 2018-07-09 16:28:48 -07:00
Bernie Hackett
8573099c4b Move time consuming utf8 tests out of the main suite 2018-06-24 20:45:59 -07:00
stephan-hof
9b632c776c Refactor the the assert into a separate function. 2018-06-24 19:59:16 -07:00
stephan-hof
e113a338e9 Improve the check for legal utf8 in the bson module.
Now python and bson have the same understanding of legal utf8.
2018-06-24 19:59:16 -07:00
Bernie Hackett
ba7c95a9df PYTHON-1462 - Import ABCs from collections.abc 2018-02-12 19:42:44 -08:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
gzcf
9051b65510 PYTHON-1299 fix Regex __eq__ method (#337) 2017-09-29 10:57:21 -07:00
Anthony Sottile
41be71f09f Trim trailing whitespace 2017-08-31 22:26:39 -07:00
Shane Harvey
47ab8c3187 PYTHON-1343 Use unsigned long to encode Timestamps.
The time and increment portions of a Timestamp are unsigned 32-bit integers
which are not guaranteed to fit inside a long.
2017-08-04 11:33:49 -07:00
Bernie Hackett
788debfdd6 PYTHON-1228 - Fix BSON test failures with Jython 2.7
The 'replace' and 'ignore' handlers for Jython generate output that
differs from CPython / PyPy.

Jython doesn't properly handle NaN with payload from struct.(un)pack.
2017-02-17 13:55:50 -08:00
Bernie Hackett
82db71e1e8 PYTHON-1068 - Support for BSON Decimal128 2016-08-29 15:07:07 -07:00
Bernie Hackett
f8aa26c549 Change solution to max recursion depth test issue
Changing max recursion depth to work around the CPython
issue seems to cause random failures in previous
python versions.
2016-08-26 13:52:22 -07:00
Luke Lovett
6692e8877a PYTHON-1131 - Fix inconsistent handling of scope, unicode support for Code. 2016-08-19 15:22:19 -07:00
Shane Harvey
bc6da8333d PYTHON-1122 Fix test_bad_encode on OS X Python 2.6 2016-07-28 11:08:25 -07:00
Bernie Hackett
53a7bea492 PYTHON-1022 - Drop support for Python 3.2
This change removes the u() helper from bson.py3compat
and all of its uses in the driver and tests. PyPy3 continues
to be supported since, even though it is based on python 3.2.5,
it has always supported the u string prefix.

The README and install docs are now explicit about PyPy(3) support.
2016-06-15 10:05:43 -07:00
Bernie Hackett
6a14d70120 PYTHON-1044 - Fix up unknown BSON type handing 2016-01-28 11:21:34 -08:00
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