def _wrap_protocols(self, step_num, step_type):
        read, write = self.pick_protocols(step_num, step_type)

        def read_lines():
            for line in self._read_input():
                try:
                    key, value = read(line.rstrip(b'\r\n'))
                    yield key, value
                except Exception as e:
                    # the strict_protocols option has to default to None
                    # because it's used by runners, so treat None as true
                    if self.options.strict_protocols is not False:
                        raise
                    else:
                        self.increment_counter(
                            'Undecodable input', e.__class__.__name__)

        def write_line(key, value):
            try:
                self.stdout.write(write(key, value))
                self.stdout.write(b'\n')
            except Exception as e:
                # None counts as true, see above
                if self.options.strict_protocols is not False:
                    raise
                else:
                    self.increment_counter(
                        'Unencodable output', e.__class__.__name__)

        return read_lines, write_line
Pick the protocol classes to use for reading and writing
dataset/ETHPy150Open Yelp/mrjob/mrjob/job.py/MRJob._wrap_protocols