Skip to content

Commit c96c5a9

Browse files
authored
PYTHON-2388 Begin PyMongo 4.0 migration guide (#540)
1 parent 86b40c1 commit c96c5a9

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

doc/changelog.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ Changelog
44
Changes in Version 4.0
55
----------------------
66

7+
.. warning:: PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5.
8+
9+
PyMongo 4.0 brings a number of improvements as well as some backward breaking
10+
changes. For example, all APIs deprecated in PyMongo 3.X have been removed.
11+
Be sure to read the changes listed below and the :doc:`migrate-to-pymongo4`
12+
before upgrading from PyMongo 3.x.
13+
714
Breaking Changes in 4.0
8-
```````````````````````
15+
.......................
916

17+
- Removed support for Python 2.7, 3.4, and 3.5. Python 3.6+ is now required.
1018
- Removed :mod:`~pymongo.thread_util`.
1119

1220
Issues Resolved

doc/index.rst

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ everything you need to know to use **PyMongo**.
3131
:doc:`faq`
3232
Some questions that come up often.
3333

34+
:doc:`migrate-to-pymongo4`
35+
A PyMongo 3.x to 4.x migration guide.
36+
3437
:doc:`migrate-to-pymongo3`
3538
A PyMongo 2.x to 3.x migration guide.
3639

@@ -119,5 +122,6 @@ Indices and tables
119122
contributors
120123
changelog
121124
python3
125+
migrate-to-pymongo4
122126
migrate-to-pymongo3
123127
developer/index

doc/migrate-to-pymongo4.rst

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
PyMongo 4 Migration Guide
2+
=========================
3+
4+
.. contents::
5+
6+
.. testsetup::
7+
8+
from pymongo import MongoClient, ReadPreference
9+
client = MongoClient()
10+
collection = client.my_database.my_collection
11+
12+
PyMongo 4.0 brings a number of improvements as well as some backward breaking
13+
changes. This guide provides a roadmap for migrating an existing application
14+
from PyMongo 3.x to 4.x or writing libraries that will work with both
15+
PyMongo 3.x and 4.x.
16+
17+
PyMongo 3
18+
---------
19+
20+
The first step in any successful migration involves upgrading to, or
21+
requiring, at least that latest version of PyMongo 3.x. If your project has a
22+
requirements.txt file, add the line "pymongo >= 3.12, < 4.0" until you have
23+
completely migrated to PyMongo 4. Most of the key new methods and options from
24+
PyMongo 4.0 are backported in PyMongo 3.12 making migration much easier.
25+
26+
.. note:: Users of PyMongo 2.X who wish to upgrade to 4.x must first upgrade
27+
to PyMongo 3.x by following the :doc:`migrate-to-pymongo3`.
28+
29+
Python 3.6+
30+
-----------
31+
32+
PyMongo 4.0 drops support for Python 2.7, 3.4, and 3.5. Users who wish to
33+
upgrade to 4.x must first upgrade to Python 3.6+. Users upgrading from
34+
Python 2 should consult the :doc:`python3`.
35+
36+
Enable Deprecation Warnings
37+
---------------------------
38+
39+
:exc:`DeprecationWarning` is raised by most methods removed in PyMongo 4.0.
40+
Make sure you enable runtime warnings to see where deprecated functions and
41+
methods are being used in your application::
42+
43+
python -Wd <your application>
44+
45+
Warnings can also be changed to errors::
46+
47+
python -Wd -Werror <your application>
48+
49+
.. note:: Not all deprecated features raise :exc:`DeprecationWarning` when
50+
used. See `Removed features with no migration path`_.
51+
52+
Removed features with no migration path
53+
---------------------------------------

0 commit comments

Comments
 (0)