Repository navigation
Possible fix for Python 3.7 RuntimeError in MMCIF2Dict - #1835
Conversation
|
@peterjc a new failure, now across all Python versions: It looks like the test failure relates to testing for an empty handle, but I have no familiarity with the PDB module I'm afraid, and I'm confused as to how the test didn't fail before but does not. |
|
Good question, I don't immediately see it either. Wild guess, might this work instead ( try:
token = next(tokens)
except StopIteration:
continue # for Python 3.7 and PEP 479 |
|
Some formats are excused from these empty handle tests, I don't know if |
|
Is the issue on Python 3.7 the call to If so, the code could be refactored to remove this call: tokens = self._tokenize(handle)
i = 0
n = 0
for ti, token in enumerate(tokens):
if ti == 0:
self[token[0:5]] = token[5:]
continue
if token.lower() == "loop_":
...NB I haven't checked this works. |
|
I think I mostly understand now. The current implementation actually has a subtle bug, which coincidentally allows it correctly handle the empty file test case! Consider the following toy example in Py 3.6: Outputs: For So if I'm right then refactoring the code into a @peterjc Is that clear? I think the solution is either exclude the relevant formats from the test cases here if empty files are not allowed, or by addressing the |
|
That sounds sensible @chris-rands. @StefansM Should the CIF formats added to SeqIO in #1635 accept empty files as meaning no sequence (like FASTA files), or an error (like an XML format)? |
|
I don't think that empty mmCIF files make any sense. It's been a while since I took a proper look at the spec, but I think valid mmCIF files must contain at least a I think |
|
Your analysis seems sound @chris-rands but if |
|
@jgreener64 It does raise a @peterjc @StefansM Hopefully the build passes now, but travis isn't checking Python 3.7 for some reason? Is the added commit sufficient? If we want to add a custom traceback for empty files across various formats and appropriate unit tests, perhaps they could form a separate PR? |
Ah I see, fair enough. |
Codecov Report
@@ Coverage Diff @@
## master #1835 +/- ##
==========================================
+ Coverage 85.41% 85.46% +0.04%
==========================================
Files 301 301
Lines 49304 49308 +4
==========================================
+ Hits 42113 42140 +27
+ Misses 7191 7168 -23
Continue to review full report at Codecov.
|
|
TravisCI does not currently have Python 3.7 available, but we are using it on AppVeyors (Windows). |
This pull request might address issue #1693 (see also #1635), but it is untested, please don't consider merging until the tests are complete.
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile and understand that AppVeyor andTravisCI will be used to confirm the Biopython unit tests and
flake8stylechecks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)