[ https://issues.apache.org/jira/browse/ZOOKEEPER-921?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nicholas Knight updated ZOOKEEPER-921: -------------------------------------- Summary: zkPython incorrectly checks for existence of required ACL elements (was: zkPython interferes with/corrupts Python's 'logging' module) I've found the actual problem. The direct cause was that I forgot to include the 'perms' element in the ACL. My bad. Contributing to the difficulty in figuring out what the heck was going on was the fact that {{check_is_acl()}} in {{src/contrib/zkpython/src/zookeeper.c}} incorrectly checks for the existence of the required elements: {code:title=zookeeper.c} entry = PyDict_GetItemString( element, "perms" ); if (entry == Py_None) { return 0; } {code} Per the Python C API docs (http://docs.python.org/c-api/dict.html#PyDict_GetItemString), {{PyDict_GetItemString}} returns {{NULL}}, not {{Py_None}}, if the item doesn't exist. There are probably some other checks that should really be done in check_is_acl(), but just changing {{Py_None}} to {{NULL}} in each {{if (entry == ...}} check resulted in the correct behavior -- a useful exception: {{Caught exception: InvalidACLException('invalid acl',)}} > zkPython incorrectly checks for existence of required ACL elements > ------------------------------------------------------------------ > > Key: ZOOKEEPER-921 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-921 > Project: Zookeeper > Issue Type: Bug > Components: contrib-bindings > Affects Versions: 3.3.1, 3.4.0 > Environment: Mac OS X 10.6.4, included Python 2.6.1 > Reporter: Nicholas Knight > Assignee: Nicholas Knight > Fix For: 3.3.3, 3.4.0 > > Attachments: zktest.py > > > Calling {{zookeeper.create()}} seems, under certain circumstances, to be > corrupting a subsequent call to Python's {{logging}} module. > Specifically, if the node does not exist (but its parent does), I end up with > a traceback like this when I try to make the logging call: > {noformat} > Traceback (most recent call last): > File "zktest.py", line 21, in <module> > logger.error("Boom?") > File > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", > line 1046, in error > if self.isEnabledFor(ERROR): > File > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", > line 1206, in isEnabledFor > return level >= self.getEffectiveLevel() > File > "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/logging/__init__.py", > line 1194, in getEffectiveLevel > while logger: > TypeError: an integer is required > {noformat} > But if the node already exists, or the parent does not exist, I get the > appropriate NodeExists or NoNode exceptions. > I'll be attaching a test script that can be used to reproduce this behavior. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.