Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "Sven R. Kunze" Newsgroups: comp.lang.python Subject: Re: monkey patching __code__ Date: Fri, 18 Mar 2016 15:33:34 +0100 Lines: 14 Message-ID: References: <56EBEB5A.7050207@mail.de> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 8Djsh6bQuSBXLJ+pP/y5Fg3XUFNpIOz7fU05YAXwpEsA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'defaults': 0.05; 'attributes': 0.07; ':-)': 0.12; '2016': 0.16; 'attribute?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'sense': 0.26; 'fri,': 0.27; 'function': 0.28; 'code': 0.30; 'received:10.0': 0.34; 'add': 0.34; 'best,': 0.35; 'replace': 0.35; 'but': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'thanks': 0.37; 'version': 0.38; 'why': 0.39; 'takes': 0.39; 'well.': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; "you'll": 0.61; 'charset:windows-1252': 0.62; 'mar': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1458311615; bh=vceojng0EpOr8+4ACWnI6fOxsUymDcYhbz37UX7vs+E=; h=Subject:To:References:From:Date:In-Reply-To:From; b=iTYGiVvDPfVpeeLeiCPcZIEY/N0pFWTL3qlMAqwhU4gE9CaQPkV+Rofak8DpWPg1t PRzKfB1xtRncZB3AnAaxvj8cjlV834shghHrPlGCR18+q1KCoyO01azrCN0eSricv5 CvOaNrImPT7SwSck4soD9uAeV3jgM7OHWbCXn0GA= In-Reply-To: X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 514 X-purgate-ID: 154282::1458311615-000018ED-E12B457A/0/0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:105220 On 18.03.2016 15:23, Ian Kelly wrote: > On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly wrote: >> Your patched version takes two extra arguments. Did you add the >> defaults for those to the function's __defaults__ attribute? > And as an afterthought, you'll likely need to replace the function's > __globals__ with your own as well. Thanks again. :-) Again, why would it make sense for those dunder attributes to be part of the function but not of the code object? Best, Sven