Check PIL support for tostring and fromstring (#3690)
Check PIL support for tostring and fromstring (#3690)

The current code checks whether the methods tostring and fromstring
exist in a PIL image object like this:

  getattr(image, 'tobytes', image.tostring)

This code raises an exception when image doesn't have the tostring
method. That seems to be the case in recent pillow versions!

Check if the tostring or tobytes method exists (in this order).

This is related to #644.

Co-authored-by: sirbiscuit <c645f49a5499e6a4445c208f80a231d66f4e8feb@users.noreply.github.com>
rdkit/rdkit,ptosco/rdkit,bp-kelley/rdkit,greglandrum/rdkit,ptosco/rdkit,bp-kelley/rdkit,rdkit/rdkit,bp-kelley/rdkit,bp-kelley/rdkit,greglandrum/rdkit,rdkit/rdkit,greglandrum/rdkit,ptosco/rdkit,rdkit/rdkit,greglandrum/rdkit,rdkit/rdkit,bp-kelley/rdkit,rdkit/rdkit,greglandrum/rdkit,greglandrum/rdkit,ptosco/rdkit,rdkit/rdkit,bp-kelley/rdkit,ptosco/rdkit,rdkit/rdkit,bp-kelley/rdkit,greglandrum/rdkit,ptosco/rdkit,greglandrum/rdkit,ptosco/rdkit,bp-kelley/rdkit,ptosco/rdkit