Skip to content

Update use of StopIteration for PEP479 #967

Closed

Description

@conchoecia

I'm using biopython v1.68 in anaconda 3.5.1 and am using a structure to read through a fastq file like so:

handle = gzip.open(path, "rt")
for record in SeqIO.parse(handle, "fastq"):
    do_stuff()
handle.close()

I keep getting this error and can't find anything about it in the source. Does anyone know what is going on here? Thanks!

/Bio/SeqIO/QualityIO.py:1031: PendingDeprecationWarning: generator 'FastqGeneralIterator' raised StopIteration
for title_line, seq_string, quality_string in FastqGeneralIterator(handle):

Activity

  1. peterjc commented on Oct 12, 2016

    @peterjc
    Member

    The good news is this not your fault, and it is harmless for now.

    (Curiously by default a PendingDeprecationWarning is silent so something has changed your setup's warning settings to make this more visible.)

    Biopython file Bio/SeqIO/QualityIO.py line 1031 is calling our function FastqGeneralIterator which does this:

        raise StopIteration

    See line 955 https://github.com/biopython/biopython/blob/biopython-168/Bio/SeqIO/QualityIO.py#L955

    I believe this is from PEP479, a deliberate change in Python itself: https://www.python.org/dev/peps/pep-0479/

    In this particular case, I think we can just remove that line (or replace it with a plain return).

  2. changed the title [-]PendingDeprecationWarning[/-] [+]Update use of StopIteration for PEP479[/+] on Oct 12, 2016
  3. peterjc commented on Oct 12, 2016

    @peterjc
    Member

    Retitling the bug - we need to audit the code base for all usage of raise StopIteration (there are currently over 30 cases).

  4. conchoecia commented on Oct 12, 2016

    @conchoecia
    Author

    Indeed, maybe it's coming from Python 3.5 based on this line in PEP479.

    Python 3.5: Enable new semantics under future import; silent deprecation warning if StopIteration bubbles out of a generator not under future import.

    The warning printed to stdout when I was using unittest to test a function iterating through SeqIO.parse(). Not sure if that makes a difference. Thanks!

  5. added a commit that references this issue on Jan 28, 2017
  6. added a commit that references this issue on Jul 20, 2017
    c1bf639
  7. added a commit that references this issue on Jul 20, 2017
    b99e2f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions