[issue13115] tp_as_{number, sequence, mapping} can't be set using PyType_FromSpec

2011-10-06 Thread Andrew Wilkins

New submission from Andrew Wilkins :

I've written an extension using Py_LIMITED_API, and I've created a type using 
PyType_FromSpec with the slot "Py_sq_length" defined. The slot is not being 
picked up, i.e. len(MyType()) fails. I can see that tp_as_sequence has not been 
set, which explains why. All is well if I set it manually (without 
Py_LIMITED_API defined), like so:
  MyType->tp_as_sequence = &((PyHeapTypeObject*)MyType)->as_sequence;

As far as I can see (docs are lacking), there's no way of setting tp_as_number, 
tp_as_sequence or tp_as_mapping in types created with PyType_FromSpec. I would 
expect the presence of any Py_sq_* slots to set tp_as_sequence (likewise for 
number and mapping).

--
components: Interpreter Core
messages: 145013
nosy: awilkins
priority: normal
severity: normal
status: open
title: tp_as_{number,sequence,mapping} can't be set using PyType_FromSpec
versions: Python 3.2

___
Python tracker 
<http://bugs.python.org/issue13115>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12687] Python 3.2 fails to load protocol 0 pickle

2011-08-05 Thread Andrew Wilkins

Andrew Wilkins  added the comment:

In _pickle.c, the load_put function calls _Unpickler_Readline, which may 
prefetch data and place it after the line read in with "readline". load_put 
then calls PyLong_FromString, which doesn't like the trailing data after the 
'\n'.

Maybe just use PyOS_strtol instead? Alternatively, replace the newline with a 
null byte.

--
nosy: +axwalk

___
Python tracker 
<http://bugs.python.org/issue12687>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com