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
Incompatibility with Python 3.7.6 #189
Comments
@ZLLentz Thanks, I have not yet tried 3.7.6 myself. I'm not sure I fully understand that error message, but it looks like tolerance for not-so-well-defined wrapping of a C structure has been reduced. And it does look like that typedef struct ca_access_rights {
unsigned read_access:1;
unsigned write_access:1;
} caar;
/* arguments passed to user access rights handlers */
struct access_rights_handler_args {
chanId chid; /* channel id */
caar ar; /* new access rights state */
}; which we translated to Python as class access_rights_handler_args(ctypes.Structure):
"access rights arguments"
_fields_ = [('chid', chid_t),
('read_access', uint_t, 1),
('write_access', uint_t, 1)] So, maybe the exception message is saying that we need to make a mapping of a Does anyone else have an idea about why this might be failing? |
Here's where that exception comes from: I wonder if this is just due to how bitfield layout isn't so well defined? Reference I'd be curious to hear from an expert about it. An easy workaround would be to remove the bitfield, changing it into |
@klauer Thanks -- I thought you were the expert ;). I thought maybe the message was enforcing that the second element of the @ZLLentz I was able to reproduce this, and it looks like a simple This does seem slightly urgent, but I don't really know what the solution will be. I'll try to look at this soon. |
@klauer Would you be willing to check if this looks right to you:
class access_rights_handler_args(ctypes.Structure):
"access rights arguments"
_fields_ = [('chid', chid_t), ('access', uint_t)]
def _onAccessRightsEvent(args):
'Access rights callback'
try:
entry = _chid_cache[_chid_to_int(args.chid)]
except KeyError:
return
read = bool(args.access % 2)
write = bool(args.access>=2)
entry.run_access_event_callbacks(read, write) This seems like it works for me with like 2 minutes of testing with 2 PVs (one RW, one RO). |
@newville Wish I could say I'm an expert on bitfield portability and ctypes magic ;) I think I'd do something like this, which keeps backward-compatibility and is a bit friendlier: class access_rights_handler_args(ctypes.Structure):
"access rights arguments"
_fields_ = [('chid', chid_t), ('access', uint_t)]
@property
def read_access(self):
return bool(self.access & 1)
@property
def write_access(self):
return bool((self.access >> 1) & 1) What do you think? |
Python 3.7.6 was released on Dec 11th and is incompatible with pyepics, failing on import. Steps to reproduce:
Using
The text was updated successfully, but these errors were encountered: