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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial - P5
    • Resolution: Fixed
    • None
    • 3.9
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: