Serhiy Storchaka added the comment:
This is a duplicate of issue27613.
--
nosy: +serhiy.storchaka
resolution: -> duplicate
status: open -> closed
superseder: -> Empty iterator with fake __len__ is rendered as a single
bracket ] when using json's iterencode
_
Walter Dörwald added the comment:
The problem here is that StreamArray lies about the length of the iterator.
This confuses json.encoder._make_iterencode._iterencode_list(), (which is
called by json.dump()), because it first does a check for "if not lst" and then
assumes in the loop that it w
Eric V. Smith added the comment:
You should ask your question on this mailing list:
https://mail.python.org/mailman/listinfo/python-list
The bug tracker is not a place for asking how to use Python. If you actually
find a bug in Python, you can re-open this issue. I do not believe that what
New submission from Clément Boyer :
I use a class to write easily json when having generator.
```python
class StreamArray(list):
def __init__(self, generator):
super().__init__()
self.generator = generator
def __iter__(self):
return self.generator
def __len__(s