-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Trivial - P5
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
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.
- causes
-
MOTOR-402 Fix test.test_cursor.TestCursor.test_delete_not_initialized
-
- Closed
-