From elliot at rpath.com Fri Mar 25 11:03:08 2011 From: elliot at rpath.com (Elliot Peele) Date: Fri, 25 Mar 2011 15:03:08 +0000 Subject: xobj: don't try to use instance methods as python types Message-ID: <201103251503.p2PF384i015121@scc.eng.rpath.com> changeset: 20be7d80a305 user: Elliot Peele date: Fri, 25 Mar 2011 11:03:06 -0400 don't try to use instance methods as python types diff --git a/py/xobj/xobj.py b/py/xobj/xobj.py --- a/py/xobj/xobj.py +++ b/py/xobj/xobj.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2008-2009 rPath, Inc. +# Copyright (c) 2008-2011 rPath, Inc. # # This program is distributed under the terms of the MIT License as found # in a file called LICENSE. If it is not present, the license @@ -9,9 +9,11 @@ # without any waranty; without even the implied warranty of merchantability # or fitness for a particular purpose. See the MIT License for full details. +import types +import inspect +from StringIO import StringIO + from lxml import etree -import types -from StringIO import StringIO DocumentInvalid = etree.DocumentInvalid @@ -150,9 +152,12 @@ pass +def isMethod(func): + return inspect.ismethod(func) or inspect.ismethoddescriptor(func) + def findPythonType(xobj, key): pc = getattr(xobj.__class__, key, None) - if pc is not None: + if pc is not None and not isMethod(pc): return pc md = getattr(xobj.__class__, '_xobj', None)