Skip to content

Commit

Permalink
Abandoned old syntax when raising ValueError in module ldif and more …
Browse files Browse the repository at this point in the history
…information in some exceptions.
  • Loading branch information
stroeder committed Jun 5, 2015
1 parent d071d81 commit a4c3400
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Changes since 2.4.19:
* New wrapping of OpenLDAP's function ldap_sasl_bind_s() allows
to intercept the SASL handshake (thanks to René Kijewski)

Lib/
* Abandoned old syntax when raising ValueError in module ldif and
some more information in exceptions.

----------------------------------------------------------------
Released 2.4.19 2015-01-10

Expand Down Expand Up @@ -1152,4 +1156,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.339 2015/05/02 16:19:23 stroeder Exp $
$Id: CHANGES,v 1.340 2015/06/05 20:55:05 stroeder Exp $
18 changes: 9 additions & 9 deletions Lib/ldif.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
$Id: ldif.py,v 1.78 2015/01/10 17:18:13 stroeder Exp $
$Id: ldif.py,v 1.79 2015/06/05 20:55:06 stroeder Exp $
Python compability note:
Tested with Python 2.0+, but should work with Python 1.5.2+.
Expand Down Expand Up @@ -165,7 +165,7 @@ def _unparseChangeRecord(self,modlist):
elif mod_len==3:
changetype = 'modify'
else:
raise ValueError,"modlist item of wrong length"
raise ValueError("modlist item of wrong length: %d" % (mod_len))
self._unparseAttrTypeandValue('changetype',changetype)
for mod in modlist:
if mod_len==2:
Expand All @@ -174,7 +174,7 @@ def _unparseChangeRecord(self,modlist):
mod_op,mod_type,mod_vals = mod
self._unparseAttrTypeandValue(MOD_OP_STR[mod_op],mod_type)
else:
raise ValueError,"Subsequent modlist item of wrong length"
raise ValueError("Subsequent modlist item of wrong length")
if mod_vals:
for mod_val in mod_vals:
self._unparseAttrTypeandValue(mod_type,mod_val)
Expand All @@ -197,7 +197,7 @@ def unparse(self,dn,record):
elif isinstance(record,types.ListType):
self._unparseChangeRecord(record)
else:
raise ValueError, "Argument record must be dictionary or list"
raise ValueError('Argument record must be dictionary or list instead of %s' % (repr(record)))
# Write empty line separating the records
self._output_file.write(self._line_sep)
# Count records written
Expand Down Expand Up @@ -354,20 +354,20 @@ def parse(self):
if attr_type=='dn':
# attr type and value pair was DN of LDIF record
if dn!=None:
raise ValueError, 'Two lines starting with dn: in one record.'
raise ValueError('Two lines starting with dn: in one record.')
if not is_dn(attr_value):
raise ValueError, 'No valid string-representation of distinguished name %s.' % (repr(attr_value))
raise ValueError('No valid string-representation of distinguished name %s.' % (repr(attr_value)))
dn = attr_value
elif attr_type=='version' and dn is None:
version = 1
elif attr_type=='changetype':
# attr type and value pair was DN of LDIF record
if dn is None:
raise ValueError, 'Read changetype: before getting valid dn: line.'
raise ValueError('Read changetype: before getting valid dn: line.')
if changetype!=None:
raise ValueError, 'Two lines starting with changetype: in one record.'
raise ValueError('Two lines starting with changetype: in one record.')
if not valid_changetype_dict.has_key(attr_value):
raise ValueError, 'changetype value %s is invalid.' % (repr(attr_value))
raise ValueError('changetype value %s is invalid.' % (repr(attr_value)))
changetype = attr_value
elif attr_value!=None and \
not self._ignored_attr_types.has_key(attr_type.lower()):
Expand Down

0 comments on commit a4c3400

Please sign in to comment.