From 04b720c17145a2c41a867d16216990ecbbd28cbe Mon Sep 17 00:00:00 2001 From: sagitter Date: Jun 21 2018 18:30:01 +0000 Subject: New patch for fixing Nexus/AlignIO tests (python-3.7.0 issue) --- diff --git a/python-biopython-bug1693.patch b/python-biopython-bug1693.patch deleted file mode 100644 index 9f158ea..0000000 --- a/python-biopython-bug1693.patch +++ /dev/null @@ -1,12 +0,0 @@ -index 18b0a9f9c7..6faf95e569 100644 ---- a/Bio/Nexus/Nexus.py -+++ b/Bio/Nexus/Nexus.py -@@ -444,6 +444,8 @@ def _kill_comments_and_break_lines(text): - - NOTE: this function is very slow for large files, and obsolete when using C extension cnexus - """ -+ if not text: -+ return "" - contents = iter(text) - newtext = [] - newline = [] diff --git a/python-biopython-bug1695.patch b/python-biopython-bug1695.patch new file mode 100644 index 0000000..a356131 --- /dev/null +++ b/python-biopython-bug1695.patch @@ -0,0 +1,108 @@ +From 1d4c4a16c49d95d3c52e77c1e62c687ec64b284d Mon Sep 17 00:00:00 2001 +From: peterjc +Date: Thu, 21 Jun 2018 14:29:31 +0100 +Subject: [PATCH 1/3] Avoid leaking StopIteration in Bio/bgzf.py + +Still using this as an internal end-of-file, thus +end-of-iteration signal, which is perhaps not ideal. + +See https://www.python.org/dev/peps/pep-0479/ +--- + Bio/bgzf.py | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/Bio/bgzf.py b/Bio/bgzf.py +index efa6262afa..e539ec4905 100755 +--- a/Bio/bgzf.py ++++ b/Bio/bgzf.py +@@ -391,18 +391,25 @@ def BgzfBlocks(handle): + data_start = 0 + while True: + start_offset = handle.tell() +- # This may raise StopIteration which is perfect here +- block_length, data = _load_bgzf_block(handle) ++ try: ++ block_length, data = _load_bgzf_block(handle) ++ except StopIteration: ++ break + data_len = len(data) + yield start_offset, block_length, data_start, data_len + data_start += data_len + + + def _load_bgzf_block(handle, text_mode=False): +- """Load the next BGZF block of compressed data (PRIVATE).""" ++ """Load the next BGZF block of compressed data (PRIVATE). ++ ++ Returns a tuple (block size and data), or at end of file ++ will raise StopIteration. ++ """ + magic = handle.read(4) + if not magic: +- # End of file ++ # End of file - should we signal this differently now? ++ # See https://www.python.org/dev/peps/pep-0479/ + raise StopIteration + if magic != _bgzf_magic: + raise ValueError(r"A BGZF (e.g. a BAM file) block should start with " + +From 0694c396ef7988e3c032d27e86fb131257812687 Mon Sep 17 00:00:00 2001 +From: peterjc +Date: Thu, 21 Jun 2018 16:12:14 +0100 +Subject: [PATCH 2/3] Return None in generator functions, not StopIteration + +See https://www.python.org/dev/peps/pep-0479/ +--- + Bio/TogoWS/__init__.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Bio/TogoWS/__init__.py b/Bio/TogoWS/__init__.py +index 4018244bcf..3cf5309c8a 100644 +--- a/Bio/TogoWS/__init__.py ++++ b/Bio/TogoWS/__init__.py +@@ -199,7 +199,7 @@ def search_iter(db, query, limit=None, batch=100): + """ + count = search_count(db, query) + if not count: +- raise StopIteration ++ return + # NOTE - We leave it to TogoWS to enforce any upper bound on each + # batch, they currently return an HTTP 400 Bad Request if above 100. + remain = count + +From 86eb2275448da22aa6976c6c7c46f9779af95cf1 Mon Sep 17 00:00:00 2001 +From: peterjc +Date: Thu, 21 Jun 2018 16:22:51 +0100 +Subject: [PATCH 3/3] Fix Nexus StopIteration error under Python 3.7.0rc1 + +Reported as Biopython GitHub issue #1693 via Fedora +packaging work for Python 3.7. + +The StopIteration from the Nexus comment parsing could +propogate up to AlignIO and cause a failure there too. +See: + +https://github.com/biopython/biopython/issues/1693 + +This is in some way triggered by the changes for PEP479, +where inappropriate StopIteration exceptions get turned +into RuntimeError exceptions instead, see: + +https://www.python.org/dev/peps/pep-0479/ +--- + Bio/Nexus/Nexus.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/Bio/Nexus/Nexus.py b/Bio/Nexus/Nexus.py +index 18b0a9f9c7..6faf95e569 100644 +--- a/Bio/Nexus/Nexus.py ++++ b/Bio/Nexus/Nexus.py +@@ -444,6 +444,8 @@ def _kill_comments_and_break_lines(text): + + NOTE: this function is very slow for large files, and obsolete when using C extension cnexus + """ ++ if not text: ++ return "" + contents = iter(text) + newtext = [] + newline = [] diff --git a/python-biopython.spec b/python-biopython.spec index 14a1eb6..fbeaec6 100644 --- a/python-biopython.spec +++ b/python-biopython.spec @@ -31,7 +31,8 @@ Summary: Python tools for computational molecular biology Source0: https://github.com/biopython/biopython/archive/biopython-171.tar.gz#/biopython-biopython-171.tar.gz # https://github.com/biopython/biopython/issues/1693 -Patch0: python-biopython-bug1693.patch +# # https://github.com/biopython/biopython/issues/1695 +Patch0: python-biopython-bug1695.patch # Starting from biopython-1.69, BioPython is released under the # "Biopython License Agreement"; it looks like a MIT variant