Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Christian Heimes
Christian Heimes wrote:
> Without support from the descriptor it's not possible to distinguish a
> function from an unbound method any more. I like to add im_class to the
> function object. I don't see negative side effects, do you?

OK, forget that. Pretend I've never said it. I shouldn't submit ideas
until coffee shows its effect.

Christian
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Build Notes for building trunk with Visual Studio 2008 Express Edition

2007-11-24 Thread M.-A. Lemburg
On 2007-11-23 23:12, Paul Moore wrote:
> On 23/11/2007, Christian Heimes <[EMAIL PROTECTED]> wrote:
>> bsddb is automatically build by a build step. But you have to convert
>> the project files in build_win32 to VS 2008 first. Simply open the
>> solution file and let VS convert the projects.
> 
> VS 2008 Express doesn't have a devenv command, so the pre-link step
> doesn't work. You need to open the bsddb project file, and build
> db_static by hand. For a debug Python, you need the Debug
> configuration, for a release Python you need the Release
> configuration. Beware - the default config is Debug_ASCII which is not
> checked by the pre-link step.
> 
> So, from a checkout of Python, plus the various svn externals:
> 
> - dowload nasm, install it somewhere on your PATH, and copy nasm.exe
> to nasmw.exe (Why did you use nasmw.exe rather than nasm.exe? Is there
> a difference in the version you have?)

The OpenSSL build process still uses the old nasmw.exe name
(the build instructions there are for the old NASM version,
but it also works with the latest NASM release).

The NASM project has recently changed the name of the executable
to nasm.exe.

> - Open the bsddb solution file, and build debug and release versions
> of db_static
> - Open the Python pcbuild solution file, and build the solution.
> 
> You'll get a total of 2 failures and 18 successes. Of the failures,
> one (_sqlite3) is not actually fatal (the pre-link step fails, and
> that only the first time), and the module is actually built correctly.
> The other is _tkinter, which isn't sorted out yet.
> 
> You can then run the tests with rt.bat. If you have an openssl.exe on
> your path, test_socket_ssl may hang. Otherwise, everything should
> pass, apart from test_tcl. (Actually, there's a failure in
> test_doctest right now, seems to have come in with r59137, but I don't
> have time to diagnose right now).
> 
> This is the case for both trunk and py3k (ignoring genuine test failures).

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 24 2007)
>>> Python/Zope Consulting and Support ...http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] [python] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Thomas Lee
Michael Foord wrote:
> Guido van Rossum wrote:
>   
>> I'm asking a Py3k question on python-dev because I'd like to have
>> opinions from people who haven't thought about Py3k much yet. Consider
>> the following example:
>>
>>   class C:
>>   def foo(self): pass
>>
>>   C.foo(42)
>>
>> This currently fails with this error message:
>>
>>   TypeError: unbound method foo() must be called with C instance as
>> first argument (got int instance instead)
>>
>> This message is called when isinstance(self, C) returns False, where
>> self is the first argument passed to the unbound method.
>>
>> That's nice, but there is a cost associated with this: the expression
>> "C.foo" can't just return the function object "foo", it has to wrap it
>> in an unbound method object. In Py3k the cost of calling an unbound
>> method object goes up, because the isinstance() check may be
>> overloaded. This typically happens when the class C uses the special
>> metaclass (abc.ABCMeta) used for virtual inheritance (see PEP 3119).
>> in Py3k the I/O stream classes are perhaps the most common use case.
>>
>> Given that the error is of limited value and that otherwise the
>> unbound method behaves exactly the same as the original function
>> object, I'd like to see if there are strenuous objections against
>> dropping unbound method objects altogether (or at least not using them
>> in this case), so that explicit super calls (via the unbound method)
>> may go a little faster. Also, it would make it easier to fix this
>> issue: http://bugs.python.org/issue1109
>>   
>> 
>
> On occasions I've found it a drag that you *can't* call unbound methods 
> with a different type. Python normally allows duck typing and this is 
> one place it actually places type restrictions...
>
> I'd be happy to see this restriction go. :-)
>
> Michael Foord
>
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/krumms%40gmail.com
>   
+1 to getting rid of unbound methods!
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] test_doctest failing

2007-11-24 Thread skip

Titus> Skip, this set_trace rewrite fixes the problem in both 25-maint and
Titus> trunk:

...

Thanks, Titus.  Both the doctest and trace tests pass with your change.
Checked back in.  I didn't run the full test suite, as test_sqlite causes a
bus error on my Mac which I've yet to investigate.

Titus> Let me know if you want a formal patch or somethin'.  And thanks
Titus> for tackling the doctest/trace situation - some users have been
Titus> complaining about it to me and it was on my list for tomorrow!

Actually, there was little tackling on my part.  More like googling.  I
searched for "trace and doctest".  The second hit was a patch against 2.4
from February 2006:

http://bugs.python.org/issue1429818

I blindly applied the patches it contained, verified they solved the
problems I was having, then checked it in.  Again, my apologies to Brett and
others for the buildbot breakage.

Skip
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Guido van Rossum
On Nov 23, 2007 11:10 PM, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Guido van Rossum wrote:
> >
> > Index: Objects/funcobject.c
> > ===
> > --- Objects/funcobject.c(revision 59154)
> > +++ Objects/funcobject.c(working copy)
> > @@ -643,8 +643,10 @@
> >  static PyObject *
> >  func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
> >  {
> > -   if (obj == Py_None)
> > -   obj = NULL;
> > +   if (obj == Py_None || obj == NULL) {
> > +   Py_INCREF(func);
> > +   return func;
> > +   }
> > return PyMethod_New(func, obj, type);
> >  }
> >
> > [well, except those should be tabs not spaces]
>
> I've created a preliminary patch. Several unit tests are still failing.

Thanks for the patch! Now I'm hoping someone will look into those
remaining six test failures.

Also, there was discussion of this before:
http://mail.python.org/pipermail/python-dev/2005-January/050625.html
-- why didn't we decide to do it then?

> The patch is also changing some semantics. For example in Python 2.5:
>
> >>> import inspect
> >>> class Class(object):
> ... def method(self): pass
> ...
> >>> inspect.ismethod(Class().method)
> True
> >>> inspect.ismethod(Class.method)
> True
>
> But in py3k:
>
> >>> import inspect
> >>> class Class:
> ... def method(self): pass
> ...
> >>> inspect.ismethod(Class().method)
> True
> >>> inspect.ismethod(Class.method)
> False # !!!

As it should be.


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread André Malo
* Greg Ewing wrote:

> Phillip J. Eby wrote:
> > class MoneyField(Field):
> > # does need staticmethod because two_decimal_places
> > # doesn't take a self
> > converter = staticmethod(two_decimal_places)
>
> Okay, I see what you mean now. But you could just as well wrap
> it in a function that takes self and discards it, 

I always thought, that this is exactly what staticmethod does.

> so I still 
> don't think staticmethod is essential in the absence of
> unbound methods.

Actually I don't see why those issues were bound together in the first 
place.

nd
-- 
Winnetous Erbe: 
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Phillip J. Eby
At 09:56 AM 11/24/2007 -0800, Guido van Rossum wrote:
>Also, there was discussion of this before:
>http://mail.python.org/pipermail/python-dev/2005-January/050625.html
>-- why didn't we decide to do it then?

http://mail.python.org/pipermail/python-dev/2005-January/051236.html

There were also a few protests of use cases that could not be worked 
around (e.g. pickling methods), and a few people pointed out that the 
type checking actually *is* useful when using explicit base calls 
(BaseClass.somemethod(self,...)), as it usually catches when you 
forget to include the self argument.)

(Note that super() doesn't do away with the need for such explicit 
upcalls, especially in __init__, as multiple-inheriting classes with 
non-cooperative bases usually need to individually call the base 
class __init__ methods.)

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] test_doctest failing

2007-11-24 Thread Guido van Rossum
On Nov 24, 2007 6:35 AM,  <[EMAIL PROTECTED]> wrote:
> Thanks, Titus.  Both the doctest and trace tests pass with your change.
> Checked back in.  I didn't run the full test suite, as test_sqlite causes a
> bus error on my Mac which I've yet to investigate.

It's easy though to run all tests *except* a known failure:
.../runtest.py -x test_sqline

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] test_doctest failing

2007-11-24 Thread Titus Brown
On Sat, Nov 24, 2007 at 10:23:06AM -0800, Guido van Rossum wrote:
-> On Nov 24, 2007 6:35 AM,  <[EMAIL PROTECTED]> wrote:
-> > Thanks, Titus.  Both the doctest and trace tests pass with your change.
-> > Checked back in.  I didn't run the full test suite, as test_sqlite causes a
-> > bus error on my Mac which I've yet to investigate.
-> 
-> It's easy though to run all tests *except* a known failure:
-> .../runtest.py -x test_sqline

Just to make sure ... do you mean regrtest?

./python Lib/test/regrtest.py -x test_sqlite

?

(There's no 'runtest.py' in the trunk, and 'runtests.py' exists under
Lib/ctypes/.)

--titus
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Terry Reedy

"Guido van Rossum" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| Also, there was discussion of this before:
| http://mail.python.org/pipermail/python-dev/2005-January/050625.html
| -- why didn't we decide to do it then?

1. Nobody ran with it.
2. There was mild concern with breaking 2.x code. 



___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Greg Ewing
André Malo wrote:
> * Greg Ewing wrote:
 >
> > But you could just as well wrap
> > it in a function that takes self and discards it, 
> 
> I always thought, that this is exactly what staticmethod does.

Not quite -- staticmethod prevents a self from getting
passed in the first place, so there's no need to discard
it. Which is probably slightly more efficient, but if
unbound methods had never been invented in the first
place, I doubt that staticmethod would have been created
just for that reason.

The other thing about staticmethod is that it makes it
possible to call the method via either a class or an
instance, but I've never found a real need for that in
anything I've written or seen.

--
Greg
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] test_doctest failing

2007-11-24 Thread Brett Cannon
On Nov 24, 2007 1:57 PM, Titus Brown <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 24, 2007 at 10:23:06AM -0800, Guido van Rossum wrote:
> -> On Nov 24, 2007 6:35 AM,  <[EMAIL PROTECTED]> wrote:
> -> > Thanks, Titus.  Both the doctest and trace tests pass with your change.
> -> > Checked back in.  I didn't run the full test suite, as test_sqlite 
> causes a
> -> > bus error on my Mac which I've yet to investigate.
> ->
> -> It's easy though to run all tests *except* a known failure:
> -> .../runtest.py -x test_sqline
>
> Just to make sure ... do you mean regrtest?
>
> ./python Lib/test/regrtest.py -x test_sqlite
>
> ?

Yep, he means regrtest.  I really need to write a "How to run and
write unit test for Python and its Standard Library" some day.

-Brett
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Should we do away with unbound methods in Py3k?

2007-11-24 Thread Nick Coghlan
Guido van Rossum wrote:
> 
> Also, there was discussion of this before:
> http://mail.python.org/pipermail/python-dev/2005-January/050625.html
> -- why didn't we decide to do it then?

Skimming that thread, the issues seem to be:
   - worse error messages from explicit base class calls if you forget 
to supply self
   - breaking code that uses im_func, im_class, im_self

This led to a mixture of a few +1's and several -0's, so it didn't happen.

Py3k severely reduces the weight of the latter objection though, and we 
can use the Py3k warnings feature in 2.6 to complain if any code 
attempts to access im_self, im_class or im_func on an instancemethod 
object when im_class is None.

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
 http://www.boredomandlaziness.org
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com