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

SDWriter.close() fails when the underlying stream has an error #498

Closed
greglandrum opened this issue May 2, 2015 · 0 comments
Closed

SDWriter.close() fails when the underlying stream has an error #498

greglandrum opened this issue May 2, 2015 · 0 comments
Labels
Milestone

Comments

@greglandrum
Copy link
Member

Here's a python3 example. The stream error is caused by another problem that still needs to be tracked down:

In [1]: from rdkit import Chem

In [2]: import gzip

In [3]: m = Chem.MolFromSmiles('C')

In [4]: f = gzip.open('/tmp/out.sdf.gz','wb+')

In [5]: w = Chem.SDWriter(f)

In [6]: w.write(m)

In [7]: w.flush()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-bc2f85e59f78> in <module>()
----> 1 w.flush()

/home/glandrum/anaconda/envs/py34/lib/python3.4/gzip.py in write(self, data)
    341         if len(data) > 0:
    342             self.size = self.size + len(data)
--> 343             self.crc = zlib.crc32(data, self.crc) & 0xffffffff
    344             self.fileobj.write( self.compress.compress(data) )
    345             self.offset += len(data)

TypeError: 'str' does not support the buffer interface

In [8]: w.close()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-cae8a84f7881> in <module>()
----> 1 w.close()

/home/glandrum/anaconda/envs/py34/lib/python3.4/gzip.py in write(self, data)
    341         if len(data) > 0:
    342             self.size = self.size + len(data)
--> 343             self.crc = zlib.crc32(data, self.crc) & 0xffffffff
    344             self.fileobj.write( self.compress.compress(data) )
    345             self.offset += len(data)

TypeError: 'str' does not support the buffer interface

In [9]: w=None
terminate called after throwing an instance of 'boost::python::error_already_set'
Aborted (core dumped)
@greglandrum greglandrum added the bug label May 2, 2015
@greglandrum greglandrum added this to the 2015_09_2 milestone May 2, 2015
greglandrum added a commit that referenced this issue May 2, 2015
sriniker pushed a commit to sriniker/rdkit that referenced this issue Oct 20, 2015
sriniker pushed a commit to sriniker/rdkit that referenced this issue Oct 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant