code: def _commit(self):
      # CAUTION:  It's vital that _commit() succeed, and _commit() can
      # be called from __del__().  Therefore we must never reference a
      # global in this routine.
      if self._index is None or not self._modified:
          return  # nothing to do
  
      try:
          self._os.unlink(self._bakfile)
      except OSError:
          pass
  
      try:
          self._os.rename(self._dirfile, self._bakfile)
      except OSError:
          pass
  
      with self._io.open(self._dirfile, "w", encoding="Latin-1") as f:
          self._chmod(self._dirfile)
          for key, pos_and_siz_pair in self._index.items():
              # Use Latin-1 since it has no qualms with any value in any
              # position; UTF-8, though, does care sometimes.
              entry = "%r, %r\n" % (
                  key.decode("Latin-1"),
                  pos_and_siz_pair,
              )
              f.write(entry)
  
imports: import ast
  import io
  import os
  import collections.abc
label_desc: Use image node_id 4 for calling the _Database obj's underlying member method code with example usage: obj._commit() without return types