Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zipfile raises error when "assert self.fp is None" in Python3.6 #1681

Closed
AndreasMadsen opened this issue Apr 10, 2017 · 3 comments
Closed

Zipfile raises error when "assert self.fp is None" in Python3.6 #1681

AndreasMadsen opened this issue Apr 10, 2017 · 3 comments

Comments

@AndreasMadsen
Copy link

AndreasMadsen commented Apr 10, 2017

I only get this error on occasion and only in a production-like environment after running some code for several hours. The only thing related to nltk is that I use the MosesTokenizer.

I've tried quite a things even setting self.fp = None manually after self.close() is called, nothing worked. In the end I had to just make OpenOnDemandZipFile an alias for zipfile.ZipFile.

I'm using python 3.6 which may be the cause of the error.

  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/corpus/reader/wordlist.py", line 78, in words
    return [line for line in line_tokenize(self.raw(fileids))
  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/corpus/reader/wordlist.py", line 28, in raw
    return concat([self.open(f).read() for f in fileids])
  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/corpus/reader/wordlist.py", line 28, in <listcomp>
    return concat([self.open(f).read() for f in fileids])
  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/corpus/reader/api.py", line 211, in open
    stream = self._root.join(file).open(encoding)
  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/data.py", line 511, in open
    data = self._zipfile.read(self._entry)
  File "/zhome/ff/2/77654/stdpy3/lib/python3.6/site-packages/nltk/data.py", line 995, in read
    assert self.fp is None
@alvations
Copy link
Contributor

alvations commented Apr 10, 2017

Yes, definitely Python 3.6 is the problem because ZipFile works a little differently on 3.5 -> 3.6.

Related issue: #1659

In fact, this is one of the major roadblock to support Python3.6, any module that uses zipfile from nltk.data would result in similar error at the assertion line.

@AndreasMadsen want to try a poke at #1659 ? ;P

@AndreasMadsen
Copy link
Author

AndreasMadsen commented Apr 10, 2017

@alvations I don't need it enough to allocate the hours to fix it, sorry.

@alvations alvations changed the title MosesTokenizer error "assert self.fp is None" Zipfile raises error when "assert self.fp is None" in Python3.6 Apr 17, 2017
@alvations
Copy link
Contributor

Similar to #1696.

We're preparing for #1659, anyone still having this issue on Python 2.7, 3.5 or > 3.6.1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants