Skip to content

Commit

Permalink
Try to fix the metaclass mess on Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Jan 19, 2017
1 parent 05d3fe0 commit 342fa8c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Persistence/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ def __setstate__(self, state):

else: # pragma: no cover

class PersistentMapping(six.with_metaclass(
def with_metaclass(meta, *bases):
# Adopted from six.with_metaclass.

# Create a base class with a metaclass.
# This requires a bit of explanation: the basic idea is to make a dummy
# metaclass for one level of class instantiation that replaces itself
# with the actual metaclass.

class metaclass(meta): # NOQA

def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
# Use ExtensionClass.__new__ instead of type.__new__
return ExtensionClass.__new__(metaclass, 'temporary_class', (), {})

class PersistentMapping(with_metaclass(
_Meta, Persistent, _BasePersistentMapping)):
"""Legacy persistent mapping class
Expand Down

0 comments on commit 342fa8c

Please sign in to comment.