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

sharedctypes.RawArray initialization #76040

Open
meetaig mannequin opened this issue Oct 24, 2017 · 1 comment
Open

sharedctypes.RawArray initialization #76040

meetaig mannequin opened this issue Oct 24, 2017 · 1 comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@meetaig
Copy link
Mannequin

meetaig mannequin commented Oct 24, 2017

BPO 31859

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 = None
created_at = <Date 2017-10-24.12:13:37.774>
labels = ['type-bug']
title = 'sharedctypes.RawArray initialization'
updated_at = <Date 2017-10-24.12:13:37.774>
user = 'https://bugs.python.org/meetaig'

bugs.python.org fields:

activity = <Date 2017-10-24.12:13:37.774>
actor = 'meetaig'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2017-10-24.12:13:37.774>
creator = 'meetaig'
dependencies = []
files = []
hgrepos = []
issue_num = 31859
keywords = []
message_count = 1.0
messages = ['304902']
nosy_count = 1.0
nosy_names = ['meetaig']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue31859'
versions = ['Python 3.5', 'Python 3.6']

@meetaig
Copy link
Mannequin Author

meetaig mannequin commented Oct 24, 2017

In the initialization of a new RawArray the size_or_initializer parameter is tested for being an instance of int. When passing something like numpy.int64 here, the code crashes, because it does not recognize this as an integer. The workaround is to cast to int(). Wouldn't it be nicer to compare to types.IntType to allow for custom integer types?

def RawArray(typecode_or_type, size_or_initializer):
    '''
    Returns a ctypes array allocated from shared memory
    '''
    type_ = typecode_to_type.get(typecode_or_type, typecode_or_type)
-    if isinstance(size_or_initializer, int):
+    if size_or_initializer is IntType:

@meetaig meetaig mannequin added the type-bug An unexpected behavior, bug, or error label Oct 24, 2017
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant