mdshw5 / pyfaidx

Efficient pythonic random access to fasta subsequences
https://pypi.python.org/pypi/pyfaidx
Other
449 stars 75 forks source link

Python 3.7: RuntimeError: generator raised StopIteration #145

Closed tillea closed 5 years ago

tillea commented 5 years ago

Hi, there is a bug reported against the Debian packaged version. The packaged version is lagging behind (unfortunately) but I took this as reason to package the latest version. When doing so I was running into the same issue:

======================================================================
ERROR: test_fetch_whole_fasta (test_FastaRecord_iter.TestFastaRecordIter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/python-pyfaidx-0.5.5.1/pyfaidx/__init__.py", line 825, in __iter__
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 21, in test_fetch_whole_fasta
    result = list(chain(*([line for line in record] for record in Fasta('data/genes.fasta', as_raw=True))))
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 21, in <genexpr>
    result = list(chain(*([line for line in record] for record in Fasta('data/genes.fasta', as_raw=True))))
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 21, in <listcomp>
    result = list(chain(*([line for line in record] for record in Fasta('data/genes.fasta', as_raw=True))))
RuntimeError: generator raised StopIteration

======================================================================
ERROR: test_reverse_iter (test_FastaRecord_iter.TestFastaRecordIter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/python-pyfaidx-0.5.5.1/pyfaidx/__init__.py", line 825, in __iter__
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 30, in test_reverse_iter
    expect = list(chain(*([line[::-1] for line in record][::-1] for record in Fasta('data/genes.fasta', as_raw=True))))
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 30, in <genexpr>
    expect = list(chain(*([line[::-1] for line in record][::-1] for record in Fasta('data/genes.fasta', as_raw=True))))
  File "/build/python-pyfaidx-0.5.5.1/tests/test_FastaRecord_iter.py", line 30, in <listcomp>
    expect = list(chain(*([line[::-1] for line in record][::-1] for record in Fasta('data/genes.fasta', as_raw=True))))
RuntimeError: generator raised StopIteration

Name                  Stmts   Miss  Cover   Missing
---------------------------------------------------
pyfaidx/__init__.py     712    146    79%   14-15, 165, 170, 293, 336-347, 350, 360-367, 377-381, 389, 393, 418-419, 444, 447, 483, 485, 491, 545-546, 590, 597-600, 665-668, 711,    724, 726, 746, 761-772, 778, 803, 810, 850, 893-904, 927, 939, 943, 945, 947, 952, 1007, 1015-1016, 1019, 1054, 1061, 1083-1122, 1125, 1134-1154, 1198-1203, 1211-1212, 1250, 1258, 1264- 1265
pyfaidx/cli.py          256    128    50%   31-36, 47-50, 78, 80, 91-106, 120-140, 181-182, 186, 190, 192, 195, 202-207, 211-217, 231, 234, 240-242, 251-253, 259, 268-281, 285, 289- 290, 293-296, 311-318, 324-331, 337-345, 351-361, 364
---------------------------------------------------
TOTAL                   968    274    72%
----------------------------------------------------------------------
Ran 139 tests in 14.694s

FAILED (SKIP=36, errors=2)

Kind regards, Andreas.

mdshw5 commented 5 years ago

Fantastic. Thanks for reporting! Guess I need to add 3.7 to my test suite.

mdshw5 commented 5 years ago

I’ve pushed a 3.7 compatible version to CI, and it should be released to PyPI within the hour. Thanks for propagating the bug report over here!

tillea commented 5 years ago

On Fri, Oct 26, 2018 at 07:29:27PM -0700, Matt Shirley wrote:

I’ve pushed a 3.7 compatible version to CI, and it should be released to PyPI within the hour. Thanks for propagating the bug report over here! Thanks in turn for the very quick fix. Debian Package is uploaded.