Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'script,': 0.07; 'python': 0.08; '(self,': 0.09; 'exception:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'wrong,': 0.09; 'error:': 0.10; 'output': 0.10; 'def': 0.13; 'argument': 0.15; 'this:': 0.15; 'executed.': 0.16; 'intermittent': 0.16; 'occasionally': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'runner': 0.16; 'unbound': 0.16; 'waited': 0.16; 'wrote:': 0.16; 'instance': 0.18; 'subject:problem': 0.19; '(most': 0.21; 'later': 0.21; 'subject:not': 0.21; 'from:addr:web.de': 0.23; "skip:' 40": 0.23; 'starts': 0.24; 'traceback': 0.24; 'code': 0.25; 'function': 0.27; 'looks': 0.27; 'raise': 0.28; 'script': 0.28; 'odd': 0.28; 'script.': 0.28; 'yield': 0.28; 'problem': 0.29; 'class': 0.29; '(and': 0.29; 'typeerror:': 0.30; '(e.g.': 0.30; 'yet': 0.32; 'to:addr:python-list': 0.33; 'last):': 0.34; 'occurs': 0.34; 'try:': 0.34; 'header:X-Complaints-To:1': 0.34; 'file': 0.35; 'run': 0.37; 'passed': 0.37; 'received:org': 0.37; 'why': 0.39; 'except': 0.39; 'being': 0.39; 'called': 0.39; 'subject:: ': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'data': 0.40; 'type': 0.60; 'limit': 0.67; 'failure': 0.74; 'owen': 0.84; 'russell': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Generator problem: parent class not seen Date: Thu, 02 Feb 2012 00:15:01 +0100 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084a859.dip.t-dialin.net X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328138107 news.xs4all.nl 6966 [2001:888:2000:d::a6]:46506 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19750 Russell E. Owen wrote: > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > self=; class hierarchy=[( 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > (,))]] > > The code looks like this: > > def run(self, sr): > try: > self.initAll() > .... > except Exception: > traceback.print_exc(file=sys.stderr) > sys.stderr.write("self=%r; class hierarchy=%s\n" % (self, > inspect.getclasstree([type(self)]))) > raise > > As a detail that may be important: the code is a generator that is being > run by a script runner class (an instance of which is passed into the > run function as argument sr). When the user starts a script the script > runner calls the script's "run" generator. The script runner calls the > run generator again later when conditions are right (e.g. data that is > being waited for arrives, a time limit is reached...). In this case the > failure occurs at the very start of the script, so a yield has not yet > executed. > > I am puzzled why Python thinks the class type is wrong, given the output > of inspect.getclasstree. Any ideas on what might be wrong and how to > track it down (and why it would be so intermittent)? Do you reload()?