[Patches] [ python-Patches-1649190 ] Adding support for _Bool to ctypes as c_bool

SourceForge.net noreply at sourceforge.net
Thu Feb 1 21:22:08 CET 2007


Patches item #1649190, was opened at 2007-01-31 22:04
Message generated for change (Comment added) made by theller
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1649190&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: David Remahl (chmod007)
>Assigned to: Thomas Heller (theller)
Summary: Adding support for _Bool to ctypes as c_bool

Initial Comment:
Adds support for the C99 _Bool type to ctypes. Requires struct patch that has already been accepted in the python 2.6 train.

Updates ctypes C extension, ctypes __init__.py, ctypes documentation and ctypes tests.

----------------------------------------------------------------------

>Comment By: Thomas Heller (theller)
Date: 2007-02-01 21:22

Message:
Logged In: YES 
user_id=11105
Originator: NO

David, I encountered these issues with the patch:

1. a typo in Lib/ctypes/test/test_numbers.py:
   'bool_type' should be 'bool_types'
   It is trivial to fix this.

2. ctypes/__init__.py should be cean for 'from ctypes import *',
   but with your patch it exposes the 'struct_error' symbol.

   I would recommend to change Modules/_ctypes/cfield.c so that a
   c_bool type can be created even if HAVE_C99_BOOL is undefined (I think
   you took that approach in your _Bool struct patch).

   Then, ctypes/__init__.py would not have to depend on the struct 't'
   typecode at all.  The '_check_size(c_bool, "t")' check can probably be
   removed.

3. ctypes/test/test_repr.py does not work.

   Easy to fix this: just add c_bool to the list of types starting
   at line 5.

These changes would also ensure compatibility with previous Python
versions, with one exception: A check for the _Bool type must be added
to Modules/ctypes/libffi/configure.in.

To answer your question: No, it is not needed to prepare a patch
relative to ctypes/trunk/ctypes.  This repository contains
svn:external properties for the 'source' and 'ctypes' directories that
point into the 'release25-maint/Modules/_ctypes' and
'release25-maint/Lib/ctypes' directories from Python.


----------------------------------------------------------------------

Comment By: David Remahl (chmod007)
Date: 2007-02-01 16:50

Message:
Logged In: YES 
user_id=2135
Originator: YES

Should I prepare the patch relative to /ctypes/trunk/ctypes instead?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2007-01-31 23:05

Message:
Logged In: YES 
user_id=21627
Originator: NO

Thomas, can you take a look?

I think this needs to take into account Python versions without bool
support in the struct module, as the same ctypes code is used with older
Python releases as well.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1649190&group_id=5470


More information about the Patches mailing list