1616
1717import collections
1818import warnings
19- from types import GeneratorType
2019
2120from bson .code import Code
2221from bson .objectid import ObjectId
@@ -469,7 +468,7 @@ def insert_one(self, document):
469468 self .write_concern .acknowledged )
470469
471470 def insert_many (self , documents , ordered = True ):
472- """Insert a list or generator of documents.
471+ """Insert an iterable of documents.
473472
474473 >>> db.test.count()
475474 0
@@ -480,7 +479,7 @@ def insert_many(self, documents, ordered=True):
480479 2
481480
482481 :Parameters:
483- - `documents`: A list or generator of documents to insert.
482+ - `documents`: A iterable of documents to insert.
484483 - `ordered` (optional): If ``True`` (the default) documents will be
485484 inserted on the server serially, in the order provided. If an error
486485 occurs all remaining inserts are aborted. If ``False``, documents
@@ -492,7 +491,7 @@ def insert_many(self, documents, ordered=True):
492491
493492 .. versionadded:: 3.0
494493 """
495- if not isinstance (documents , ( list , GeneratorType ) ) or not documents :
494+ if not isinstance (documents , collections . Iterable ) or not documents :
496495 raise TypeError ("documents must be a non-empty list" )
497496 inserted_ids = []
498497 def gen ():
0 commit comments