Skip to content

Commit 044a1a9

Browse files
committed
small fixes
1 parent 8f9b0dc commit 044a1a9

File tree

4 files changed

+46
-76
lines changed

4 files changed

+46
-76
lines changed

source/compatibility.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ The first column lists the driver version.
5050

5151
.. include:: /includes/language-compatibility-table-pymongo.rst
5252

53-
For more information on how to read the compatibility tables, see our guide on
53+
For more information about how to read the compatibility tables, see
5454
:ref:`MongoDB Compatibility Tables. <about-driver-compatibility>`

source/includes/language-compatibility-table-pymongo.rst

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -212,53 +212,8 @@ as binary data with subtype 0, the default subtype for binary data. In Python 3,
212212
{+driver-short+} decodes these values to instances of the ``bytes`` class. In Python 2,
213213
the driver decodes them to instances of the
214214
`Binary <https://pymongo.readthedocs.io/en/4.11/api/bson/binary.html#bson.binary.Binary>`__
215-
class with subtype 0.
216-
217-
The following code examples show how {+driver-short+} decodes instances of the ``bytes``
218-
class. Select the :guilabel:`Python 2` or :guilabel:`Python 3` tab to view the corresponding
219-
code.
220-
221-
.. tabs::
222-
223-
.. tab:: Python 2
224-
:tabid: python2
225-
226-
.. io-code-block::
227-
:copyable: true
228-
229-
.. input::
230-
:language: python
231-
232-
from pymongo import MongoClient
233-
234-
client = MongoClient()
235-
client.test.test.insert_one({'binary': b'this is a byte string'})
236-
doc = client.test.test.find_one()
237-
print(doc)
238-
239-
.. output::
240-
241-
{u'_id': ObjectId('67afb78298f604a28f0247b4'), u'binary': Binary('this is a byte string', 0)}
242-
243-
.. tab:: Python 3
244-
:tabid: python3
245-
246-
.. io-code-block::
247-
:copyable: true
248-
249-
.. input::
250-
:language: python
251-
252-
from pymongo import MongoClient
253-
254-
client = MongoClient()
255-
client.test.test.insert_one({'binary': b'this is a byte string'})
256-
doc = client.test.test.find_one()
257-
print(doc)
258-
259-
.. output::
260-
261-
{'_id': ObjectId('67afb78298f604a28f0247b4'), 'binary': b'this is a byte string'}
215+
class with subtype 0. For code examples that show the differences, see the
216+
:ref:`Extended JSON <pymongo-serialization-binary-data>` page.
262217

263218
The driver behaves the same way when decoding JSON binary values with subtype 0. In
264219
Python 3, it decodes these values to instances of the ``bytes`` class. In Python 2,

source/read/retrieve.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ the ``"cuisine"`` field has the value ``"Bakery"``:
8383

8484
To learn more about sorting, see the :ref:`sort guide <pymongo-sort>`.
8585

86-
87-
8886
.. _pymongo-retrieve-find-multiple:
8987

9088
Find Multiple Documents

source/serialization.txt

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,44 +91,61 @@ it back into a ``Restaurant`` object from the preceding example:
9191
To learn more about retrieving documents from a collection, see the :ref:`pymongo-retrieve`
9292
guide.
9393

94-
Binary Fields
95-
-------------
94+
.. _pymongo-serialization-binary-data:
95+
96+
Binary Data
97+
-----------
9698

9799
In all versions of Python, {+driver-short+} encodes instances of the
98100
`bytes <https://docs.python.org/3/library/stdtypes.html#bytes>`__ class
99101
as binary data with subtype 0, the default subtype for binary data. In Python 3,
100102
{+driver-short+} decodes these values to instances of the ``bytes`` class. In Python 2,
101-
however, the driver decodes them to instances of the
103+
the driver decodes them to instances of the
102104
`Binary <https://pymongo.readthedocs.io/en/4.11/api/bson/binary.html#bson.binary.Binary>`__
103105
class with subtype 0.
104106

105-
The following code examples use {+driver-short+} to insert a ``bytes`` instance
106-
into MongoDB, and then find the instance.
107-
In Python 2, the byte string is decoded to ``Binary``.
108-
In Python 3, the byte string is decoded back to ``bytes``.
107+
The following code examples show how {+driver-short+} decodes instances of the ``bytes``
108+
class. Select the :guilabel:`Python 2` or :guilabel:`Python 3` tab to view the corresponding
109+
code.
109110

110111
.. tabs::
111112

112-
.. tab:: Python 2.7
113-
:tabid: python-2
113+
.. tab:: Python 2
114+
:tabid: python2
114115

115-
.. code-block:: python
116+
.. io-code-block::
117+
:copyable: true
116118

117-
>>> import pymongo
118-
>>> c = pymongo.MongoClient()
119-
>>> c.test.bintest.insert_one().inserted_id
120-
ObjectId('4f9086b1fba5222021000000')
121-
>>> c.test.bintest.find_one()
122-
{u'binary': Binary('this is a byte string', 0), u'_id': ObjectId('4f9086b1fba5222021000000')}
123-
124-
.. tab:: Python 3.7
125-
:tabid: python-3
119+
.. input::
120+
:language: python
121+
122+
from pymongo import MongoClient
123+
124+
client = MongoClient()
125+
client.test.test.insert_one({'binary': b'this is a byte string'})
126+
doc = client.test.test.find_one()
127+
print(doc)
128+
129+
.. output::
130+
131+
{u'_id': ObjectId('67afb78298f604a28f0247b4'), u'binary': Binary('this is a byte string', 0)}
132+
133+
.. tab:: Python 3
134+
:tabid: python3
135+
136+
.. io-code-block::
137+
:copyable: true
138+
139+
.. input::
140+
:language: python
141+
142+
from pymongo import MongoClient
143+
144+
client = MongoClient()
145+
client.test.test.insert_one({'binary': b'this is a byte string'})
146+
doc = client.test.test.find_one()
147+
print(doc)
126148

127-
.. code-block:: python
149+
.. output::
128150

129-
>>> import pymongo
130-
>>> c = pymongo.MongoClient()
131-
>>> c.test.bintest.insert_one({'binary': b'this is a byte string'}).inserted_id
132-
ObjectId('4f9086b1fba5222021000000')
133-
>>> c.test.bintest.find_one()
134-
{'binary': b'this is a byte string', '_id': ObjectId('4f9086b1fba5222021000000')}
151+
{'_id': ObjectId('67afb78298f604a28f0247b4'), 'binary': b'this is a byte string'}

0 commit comments

Comments
 (0)