Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tp_as_{number,sequence,mapping} can't be set using PyType_FromSpec #57324

Closed
awilkins mannequin opened this issue Oct 6, 2011 · 3 comments
Closed

tp_as_{number,sequence,mapping} can't be set using PyType_FromSpec #57324

awilkins mannequin opened this issue Oct 6, 2011 · 3 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@awilkins
Copy link
Mannequin

awilkins mannequin commented Oct 6, 2011

BPO 13115
Nosy @loewis, @amauryfa

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-01-04.10:37:30.003>
created_at = <Date 2011-10-06.14:10:25.949>
labels = ['interpreter-core', 'type-bug']
title = "tp_as_{number,sequence,mapping} can't be set using PyType_FromSpec"
updated_at = <Date 2014-01-04.10:37:30.001>
user = 'https://bugs.python.org/awilkins'

bugs.python.org fields:

activity = <Date 2014-01-04.10:37:30.001>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2014-01-04.10:37:30.003>
closer = 'loewis'
components = ['Interpreter Core']
creation = <Date 2011-10-06.14:10:25.949>
creator = 'awilkins'
dependencies = []
files = []
hgrepos = []
issue_num = 13115
keywords = []
message_count = 3.0
messages = ['145013', '163680', '207280']
nosy_count = 3.0
nosy_names = ['loewis', 'amaury.forgeotdarc', 'awilkins']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue13115'
versions = ['Python 3.2', 'Python 3.3']

@awilkins
Copy link
Mannequin Author

awilkins mannequin commented Oct 6, 2011

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).

@awilkins awilkins mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 6, 2011
@pitrou pitrou added the type-bug An unexpected behavior, bug, or error label Oct 6, 2011
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 23, 2012

For 3.3, this is fixed in bb6df3781edb. However, this needs to be backported to 3.2.

@loewis
Copy link
Mannequin

loewis mannequin commented Jan 4, 2014

Since 3.2 has seen its last bugfix release, this won't be added to 3.2 anymore.

@loewis loewis mannequin closed this as completed Jan 4, 2014
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant