The next() method is gone from the return value of open() in Python 3 and I
don't think it was every necessary. As per the iterator protcool (
https://docs.python.org/2/library/stdtypes.html#iterator-types ), __iter__
is meant to return an iterator over the object, and *that* is what the
next() method - __next__ on Python 3 - should be attached to. Django's
File.__iter__ is a generator function, thus it returns a generator, with
comes with a next()/__next__().

I think you should just try iterating your files by calling iter() on them
first, it's Python 3 compatible too.

On 27 July 2017 at 17:24, Cristiano Coelho <cristianocc...@gmail.com> wrote:

> Hello,
>
> I have recently found an interesting issue, using a project that relies on
> different storage backends, when switching from a custom one to django's
> file system storage, I found that existing code that would iterate files
> with the next() call would start to fail, since although django's File is
> iterable, it doesn't define the next method.
>
> Now I'm wondering if this is on purpose, or a bug. It's odd that every
> stream (or almost) from the python library such as everything from the .io
> module or simply the object returned by open() (python 2) supports the next
> call but the django File wrapper doesn't.
>
> This happened with django 1.10 and I believe it wasn't changed with Django
> 1.11
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/09ffad76-e473-4593-ac84-
> 4bca7f76e92c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/09ffad76-e473-4593-ac84-4bca7f76e92c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM394-B26RzXpfhCqb8MYJPwpu%2B_eELpttFDqk6Zfn4Rvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to