code: def _save_state(self):
          
          ns_prefixes_floating_in = copy.copy(self._ns_prefixes_floating_in)
          ns_prefixes_floating_out = copy.copy(self._ns_prefixes_floating_out)
          ns_decls_floating_in = copy.copy(self._ns_decls_floating_in)
          curr_ns_map = copy.copy(self._curr_ns_map)
          ns_map_stack = copy.copy(self._ns_map_stack)
          pending_start_element = self._pending_start_element
          ns_counter = self._ns_counter
          # XXX: I have been unable to find a test justifying copying this :/
          # for completeness, I’m still doing it
          ns_auto_prefixes_floating_in = \
              copy.copy(self._ns_auto_prefixes_floating_in)
          try:
              yield
          except:  # NOQA: E722
              self._ns_prefixes_floating_in = ns_prefixes_floating_in
              self._ns_prefixes_floating_out = ns_prefixes_floating_out
              self._ns_decls_floating_in = ns_decls_floating_in
              self._pending_start_element = pending_start_element
              self._curr_ns_map = curr_ns_map
              self._ns_map_stack = ns_map_stack
              self._ns_counter = ns_counter
              self._ns_auto_prefixes_floating_in = ns_auto_prefixes_floating_in
              raise
docs: Helper context manager for :meth:`buffer` which saves the whole state.
  
          This is broken out in a separate method for readability and tested
          indirectly by testing :meth:`buffer`.