Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-922

ReadPreference instances aren't copyable

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.2
    • Affects Version/s: 3.0
    • Component/s: None
    • Labels:
      None
    • Fully Compatible

      Discovered while helping port django_mongodb_engine to PyMongo 3.

      >>> import copy
      >>> from pymongo import *
      >>> copy.copy(ReadPreference.SECONDARY)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/Users/emptysquare/.virtualenvs/official/mongo-python-driver/pymongo/read_preferences.py", line 116, in __repr__
          self.name, self.__tag_sets)
      AttributeError: _ServerMode__tag_sets
      

      I think the _ServerMode base class needs __getstate__ and __setstate__.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: