Minor bug in ldif.py

Roger Moore rwmoore at fnal.gov
Fri Jun 1 01:15:39 CEST 2001


I just noticed a slight bug in ldif.py to do with the deletion of the
object class list. The problem is that if you name the attribute
'objectClass' then the first attrs.remove() statement generates an
exception and the second statement is not reached. To fix this you can
check for the key first. I've attached the patch to this email.

As a very quick work around call the attribute 'objectclass'.

-------------- next part --------------
--- /usr/lib/python1.5/site-packages/python-ldap/ldif.py	Sun Jul 30 07:27:51 2000
+++ ldif.py	Thu May 31 18:10:53 2001
@@ -87,11 +87,10 @@
   for oc in objectclasses:
     result.append('objectclass: %s\n' % oc)
   attrs = entry.keys()[:]
-  try:
-    attrs.remove('objectclass')
-    attrs.remove('objectClass')
-  except:
-    pass
+  if attrs.has_key('objectclass'):
+      attrs.remove('objectclass')
+  if attrs.has_key('objectClass'):
+      attrs.remove('objectClass')
   for attr in attrs:
     if attr in binary_attrs:

More information about the python-ldap mailing list