It seems silly to me to create duplicate code in PEAK-Rules when we can fix it in one place for any/all subclasses of AddOn.  When you say &quot;most&quot;, it is implied that there may be someone out there who has an AddOn that also redefines __new__ (just as BitmapIndex does).  This fix should work for all of those classes.<br>
<br><div class="gmail_quote">On Tue, Jul 14, 2009 at 3:31 PM, Sergey Schetinin <span dir="ltr">&lt;<a href="mailto:maluke@gmail.com">maluke@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I think it would be better to apply that patch to PEAK-Rules -- create<br>
a new AddOn subclass with that __new__ method and use it as a<br>
baseclass for the classes that cause the warning.<br>
<br>
Most AddOn subclasses in other packages don&#39;t redefine __new__ and<br>
don&#39;t need the fix.<br>
<div><div></div><div class="h5"><br>
On 2009-07-15, Kyle VanderBeek &lt;<a href="mailto:kylev@kylev.com">kylev@kylev.com</a>&gt; wrote:<br>
&gt; Actually, I found this to be the more correct way to smash arguments before<br>
&gt; continuing on in the &quot;super&quot; sequence up to object:<br>
&gt;<br>
&gt;     def __new__(cls, *args):<br>
&gt;          # Work around for python 2.6 DeprecationWarning<br>
&gt;         return super(AddOn, cls).__new__(cls)<br>
&gt;<br>
&gt; Can anyone apply this change to the AddOn object and test to make sure<br>
&gt; things you&#39;re doing don&#39;t break?  All the tests run by &quot;python setup.py<br>
&gt; test&quot; pass currently.  I&#39;ll likely apply this patch to Fedora&#39;s packaged<br>
&gt; version soon.<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Jul 8, 2009 at 2:13 PM, Kyle VanderBeek &lt;<a href="mailto:kylev@kylev.com">kylev@kylev.com</a>&gt; wrote:<br>
&gt; &gt; I think just about the only answer for this would be to define a __new__<br>
&gt; in AddOn.  I agree the deprecation makes things odd and it annoys me.<br>
&gt; &gt;<br>
&gt; &gt; def __new__(cls, *args):<br>
&gt; &gt;     return object.__new__(cls)<br>
&gt; &gt;<br>
&gt; &gt; Does that look like something reasonable that would work?  I&#39;ve seen it in<br>
&gt; a couple other packages, but don&#39;t have time to test it at the moment.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Tue, Jun 23, 2009 at 5:07 PM, P.J. Eby &lt;<a href="mailto:pje@telecommunity.com">pje@telecommunity.com</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; At 02:08 PM 6/23/2009 -0700, Kyle VanderBeek wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; A great deal of PEAK-Rules will cause DeprecationWarnings to be<br>
&gt; &gt; &gt; &gt; issued.  As a maintainer of several related and dependent Fedora<br>
&gt; &gt; &gt; &gt; packages, I need to get this fixed.  Even a trivial use such as this<br>
&gt; &gt; &gt; &gt; will cause problems:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; from peak.rules import before<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; def foo():<br>
&gt; &gt; &gt; &gt;    pass<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; @before(foo, &quot;True&quot;)<br>
&gt; &gt; &gt; &gt; def bar():<br>
&gt; &gt; &gt; &gt;    pass<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; This results in:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; /usr/local/py26/lib/python2.6/site-packages/PEAK_Rules-0.5a1.dev_r2582-py2.6.egg/peak/rules/indexing.py:220:<br>
&gt; &gt; &gt; &gt; DeprecationWarning: object.__new__() takes no parameters<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; Essentially, object() in 2.6 shouldn&#39;t get any parameters to its<br>
&gt; &gt; &gt; &gt; __new__ special method, and that&#39;s exactly what BitmapIndex is doing.<br>
&gt; &gt; &gt; &gt; Does anyone have a patch to fix this?  I&#39;m working on fully<br>
&gt; &gt; &gt; &gt; understanding peak.rules, so I haven&#39;t quite wrapped my head around<br>
&gt; &gt; &gt; &gt; the right fix yet.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; The place to fix this would be in DecoratorTools or AddOns, actually.  I<br>
&gt; suppose DecoratorTools&#39; classy.__new__ or AddOns&#39; AddOn.__new__ could check<br>
&gt; if its superclass __new__ is object __new__, and if so terminate the __new__<br>
&gt; upcalling.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; (Not that it&#39;s your problem, but making __new__ *not* take arbitrary<br>
&gt; parameters is a design flaw of 2.6, since it makes it impossible to write an<br>
&gt; inheritance-agnostic mixin where __new__ is concerned.)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I&#39;m not entirely sure what to do about this myself because this could<br>
&gt; potentially either introduce a significant performance hit, or create bugs<br>
&gt; in other packages, if somebody has a __new__ that comes *after* AddOn in the<br>
&gt; method resolution order.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Consider this class:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;   class MyAddOn(AddOn, MyOtherClass):<br>
&gt; &gt; &gt;        def __new__(cls, ...)<br>
&gt; &gt; &gt;            # do stuff, then...<br>
&gt; &gt; &gt;            return super(MyAddOn, cls).__new__(cls, ...)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; If &#39;MyOtherClass.__new__&#39; uses those arguments, then a change to<br>
&gt; AddOn.__new__ that drops the arguments unconditionally is now a problem.<br>
&gt; Conversely, having AddOn check for object.__new__-ness will induce needless<br>
&gt; overhead for this case.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Any suggestions?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; <a href="mailto:kylev@kylev.com">kylev@kylev.com</a><br>
&gt; &gt;  Some people have a way with words, while others... erm... thingy.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; <a href="mailto:kylev@kylev.com">kylev@kylev.com</a><br>
&gt;   Some people have a way with words, while others... erm... thingy.<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt;  PEAK mailing list<br>
&gt;  <a href="mailto:PEAK@eby-sarna.com">PEAK@eby-sarna.com</a><br>
&gt;  <a href="http://www.eby-sarna.com/mailman/listinfo/peak" target="_blank">http://www.eby-sarna.com/mailman/listinfo/peak</a><br>
&gt;<br>
<font color="#888888"><br>
<br>
--<br>
Best Regards,<br>
Sergey Schetinin<br>
<br>
<a href="http://s3bk.com/" target="_blank">http://s3bk.com/</a> -- S3 Backup<br>
<a href="http://word-to-html.com/" target="_blank">http://word-to-html.com/</a> -- Word to HTML Converter<br>
</font></blockquote></div><br><br clear="all"><br>-- <br><a href="mailto:kylev@kylev.com">kylev@kylev.com</a><br>  Some people have a way with words, while others... erm... thingy.<br><br>