[pydotorg-www] Bug in code example on wiki page about BitManipulation

Mats Wichmann mats at wichmann.us
Thu Sep 1 10:37:03 EDT 2016


On 09/01/2016 02:39 AM, Felix Widmaier wrote:
> Hi all,
> 
> I just noticed a small bug in the code example for bit fields on this
> page: https://wiki.python.org/moin/BitManipulation
> 
> There is a ctypes.Union defined as follows:
> 
>     class Flags( ctypes.Union ):
>         _fields_ = [
>                     ("b",      Flags_bits ),
>                     ("asByte", c_uint8    )
>                    ]
>         _anonymous_ = ("b")
> 
> However, the `_anonymous_` attribute should be a tuple, i.e. the
> following would be correct:
> 
>     _anonymous_ = ("b",)
> 
> I guess in the given example it works without the comma since the name
> "b" consists of only one character and therefore "b"[0] == ("b",)[0] but
> for names with more than one char it does not work like this.
> 
> It would be great if someone with permission to edit the page could fix
> this (I don't have an account and I think it would not be worth the
> effort to create one for such a tiny edit).

hmmm, not only are you right about that, but according to the
documentation, "_anonymous_ must be already defined when _fields_ is
assigned, otherwise it will have no effect"  so there seems to be an
additional problem in the example.

perhaps you could file an issue in the tracker, if you don't want to get
an account and fix it yourself (we would give you edit permission)

https://github.com/python/pythondotorg

thanks!


More information about the pydotorg-www mailing list