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

AttributeError: 'Cursor' object has no attribute '_Cursor__killed'

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 3.9
    • Affects Version/s: None
    • Component/s: None
    • None

      Reported and fixed in https://github.com/mongodb/mongo-python-driver/pull/421:

      If the constructor of Cursor is called with unexpected arguments (ie when calling a `find` wrongly), the `__init__` method does not run at all, but `__del__` is still called and will (of course) crash.
      
      This leads to some noise in the logged error on top of the real TypeError:
      ```
      >>> pymongo.cursor.Cursor(wrong=1)
      Exception ignored in: <function Cursor.__del__ at 0x1048129d8>
      Traceback (most recent call last):
        File "/Users/arthur/dev/.venvs/Users--arthur--dev--dragonstone/lib/python3.7/site-packages/pymongo/cursor.py", line 241, in __del__
          self.__die()
        File "/Users/arthur/dev/.venvs/Users--arthur--dev--dragonstone/lib/python3.7/site-packages/pymongo/cursor.py", line 298, in __die
          already_killed = self.__killed
      AttributeError: 'Cursor' object has no attribute '_Cursor__killed'
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: __init__() got an unexpected keyword argument 'wrong'
      ```
      

      Note this is very similar to PYTHON-1427 but not quite the same.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: