Skip to content

Commit

Permalink
Fix immutable methods in Artwork class.
Browse files Browse the repository at this point in the history
This fixes an issue with several immutable methods in the Artwork class,
inherited from the parent UserString class. As the Artwork class is
modified for use as a property, and not intended to be called directly
for storage of a string, the inherited UserString methods that returned
a new instance using the __class__ attribute would fail. This adds a
__new__ method that detects such uses and forces the call to return a
standard str type instead.
  • Loading branch information
wagnerrp committed Oct 23, 2012
1 parent beb9f8e commit 9f66fa0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mythtv/bindings/python/MythTV/dataheap.py
Expand Up @@ -48,6 +48,14 @@ def data(self):
raise RuntimeError("Artwork property must be used through an " +\
"object, not independently.")

def __new__(cls, attr, parent=None, imagetype=None):
if (imagetype is None) and (attr not in cls._types):
# usage appears to be export from immutable UserString methods
# return a dumb string
return str.__new__(str, attr)
else:
return super(Artwork, cls).__new__(cls, attr, parent, imagetype)

def __init__(self, attr, parent=None, imagetype=None):
# replace standard MutableString init to not overwrite self.data
from warnings import warnpy3k
Expand Down

0 comments on commit 9f66fa0

Please sign in to comment.