[Python-Dev] Rationale for different signatures of tuple.__new__ and namedtuple.__new__

2013-02-18 Thread John Reid
Hi,

I can do

tuple([1,2,3])

but not:

from collections import namedtuple
namedtuple('B', 'x y z')([1,2,3])

I get a TypeError: __new__() takes exactly 4 arguments (2 given)
However I can do:

namedtuple('B', 'x y z')._make([1,2,3])

So namedtuple's _make classmethod looks a lot like tuple's __new__().
What's the rationale for this? Wouldn't it be better to share the same
signature for __new__?

IPython's serialization code depends on a tuple's __new__() having the
signature that tuple has and therefore does not work with namedtuples.
See discussion here:
http://article.gmane.org/gmane.comp.python.general/726849

Thanks,
John.


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


[Python-Dev] *** glibc detected *** gdb: malloc(): smallbin double linked list

2010-11-05 Thread John Reid

Hi,

I've compiled
Python 2.7 (r27:82500, Nov  2 2010, 09:00:37)
[GCC 4.4.3] on linux2

with the following configure options
./configure --prefix=/home/john/local/python-dbg --with-pydebug

I've installed numpy and some other packages but when I try to run my 
extension code under gdb I get the errors below. Does anyone have any 
ideas of how to track down what's happening here? I imagine I've 
misconfigured something somewhere. Is valgrind the answer?


Thanks,
John.



*** glibc detected *** gdb: malloc(): smallbin double linked list 
corrupted: 0x04de7ad0 ***

=== Backtrace: =
/lib/libc.so.6(+0x775b6)[0x7f0a252215b6]
/lib/libc.so.6(+0x7b8e9)[0x7f0a252258e9]
/lib/libc.so.6(__libc_malloc+0x6e)[0x7f0a2522658e]
gdb(xmalloc+0x18)[0x45bc38]
gdb[0x476df1]
gdb[0x474c9b]
gdb[0x474ee8]
gdb(execute_command+0x2dd)[0x458d1d]
gdb(catch_exception+0x50)[0x535510]
gdb[0x4b5191]
gdb(interp_exec+0x17)[0x535637]
gdb(mi_cmd_interpreter_exec+0x6c)[0x4b9adc]
gdb[0x4ba71a]
gdb(catch_exception+0x50)[0x535510]
gdb(mi_execute_command+0x97)[0x4ba137]
gdb[0x53a0f8]
gdb(gdb_do_one_event+0x29a)[0x53b38a]
gdb(catch_errors+0x5b)[0x53531b]
gdb(start_event_loop+0x1e)[0x53a90e]
gdb[0x44f619]
gdb(catch_errors+0x5b)[0x53531b]
gdb[0x450166]
gdb(catch_errors+0x5b)[0x53531b]
gdb(gdb_main+0x24)[0x44f554]
gdb(main+0x2e)[0x44f51e]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7f0a251c8c4d]
gdb[0x44f429]
=== Memory map: 
0040-00818000 r-xp  08:05 4832730 
 /usr/bin/gdb
00a17000-00a18000 r--p 00417000 08:05 4832730 
 /usr/bin/gdb
00a18000-00a25000 rw-p 00418000 08:05 4832730 
 /usr/bin/gdb

00a25000-00a43000 rw-p  00:00 0
0287f000-0b92 rw-p  00:00 0 
 [heap]

7f0a1c00-7f0a1c021000 rw-p  00:00 0
7f0a1c021000-7f0a2000 ---p  00:00 0
7f0a20fc-7f0a20fd6000 r-xp  08:05 3498245 
 /lib/libgcc_s.so.1
7f0a20fd6000-7f0a211d5000 ---p 00016000 08:05 3498245 
 /lib/libgcc_s.so.1
7f0a211d5000-7f0a211d6000 r--p 00015000 08:05 3498245 
 /lib/libgcc_s.so.1
7f0a211d6000-7f0a211d7000 rw-p 00016000 08:05 3498245 
 /lib/libgcc_s.so.1
7f0a211fd000-7f0a21211000 r--p 000dc000 08:05 4825848 
 /usr/lib/libstdc++.so.6.0.13
7f0a21211000-7f0a21218000 r--p 00018000 08:05 4841756 
 /usr/lib/debug/lib/librt-2.11.1.so
7f0a21218000-7f0a21226000 r--p 1000 08:05 4841756 
 /usr/lib/debug/lib/librt-2.11.1.so
7f0a21226000-7f0a2123e000 r--p 000bc000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a2123e000-7f0a21287000 r--p 003dd000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a21287000-7f0a21299000 r--p 00425000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a21299000-7f0a213e7000 r--p 0018c000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a213e7000-7f0a2152f000 r--p 0207c000 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so
7f0a2152f000-7f0a22027000 r--p 01585000 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so

7f0a22027000-7f0a2240 rw-p  00:00 0
7f0a22408000-7f0a224d1000 r--p 00315000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a224d1000-7f0a224ff000 r--p 002e8000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a224ff000-7f0a22526000 r--p 00038000 08:05 4653310 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/myrrh_pylib-d
7f0a22526000-7f0a2259c000 r--p 0151 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so
7f0a2259c000-7f0a2280c000 r--p 012a 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so

7f0a2280c000-7f0a2343f000 rw-p  00:00 0
7f0a23443000-7f0a2344c000 r--p 0001a000 08:05 6169643 
 /home/john/local/python-dbg/lib/python2.7/lib-dynload/datetime.so
7f0a2344c000-7f0a2345c000 r--p 002d9000 08:05 4653290 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_python.so.1.44.0
7f0a2345c000-7f0a23461000 r--p 0005e000 08:05 4653310 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/myrrh_pylib-d
7f0a23461000-7f0a23477000 r--p 0001f000 08:05 4653310 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/myrrh_pylib-d
7f0a23477000-7f0a2347d000 r--p 4000 08:05 4653095 


/home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/libboost_system.so.1.44.0
7f0a2347d000-7f0a2350c000 r--p 00757000 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so
7f0a2350c000-7f0a23555000 r--p 021c3000 08:05 4653324 
 /home/john/Dev/MyProjects/Bio/MotifSearch/python/stempy/_debug/_stempy.so
7f0a23555000-7f0a2355b000 r--p 00048000 08:05 6169627 
 /home