plone / Products.MimetypesRegistry

Provide a persistent registry of mimetypes for Plone
1 stars 7 forks source link

more python3 fixes #12

Closed pbauer closed 6 years ago

pbauer commented 6 years ago

I'm not sure how to deal with the isinstance(mt, InstanceType) thing. InstanceType should only apply to old-style classes (not inheriting from object) which are gone in py3 (all classes inherit from object) but here it looks like it is (ab)used to check if mimetype class has been instanciated or not. I did not really look what a mt is so some help would be nice.

jensens commented 6 years ago

What about using

import inspect

if inspect.isclass(mt):
    mt = mt()

Anyway, overall the whole assumption is ugly.

ale-rt commented 6 years ago

I am fine to merge the PR as it is.

Anyway a possible fix for the missing InstanceType is:

try:
    from types import InstanceType
except ImportError:
    InstanceType = object
pbauer commented 6 years ago

@ale-rt your approach would always return true (since isinstance(xx, object) is true for classes and instances of classes. I think inspect.isclass(xx) is correct though.

ale-rt commented 6 years ago

Right!