~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/counted_lock.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        it is taken in read mode.
57
57
        """
58
58
        if self._lock_mode:
59
 
            assert self._lock_mode in ('r', 'w'), \
60
 
                   "invalid lock mode %r" % self._lock_mode
61
59
            self._lock_count += 1
62
60
        else:
63
 
            assert self._lock_count == 0
64
61
            self._real_lock.lock_read()
65
62
            self._lock_count = 1
66
63
            self._lock_mode = 'r'
71
68
        If the lock was originally acquired in read mode this will fail.
72
69
        """
73
70
        if self._lock_count == 0:
74
 
            assert self._lock_mode is None
75
71
            self._real_lock.lock_write()
76
72
            self._lock_mode = 'w'
77
73
        elif self._lock_mode != 'w':