def _interpret_hadoop_jar_command_stderr(stderr, record_callback=None):
    """Parse stderr from the ``hadoop jar`` command. Works like
    :py:func:`_parse_step_log` (same return format)  with a few extra features
    to handle the output of the ``hadoop jar`` command on the fly:

    - Converts ``bytes`` lines to ``str``
    - Pre-filters non-log4j stuff from Hadoop Streaming so it doesn't
      get treated as part of a multi-line message
    - Handles "stderr" from a PTY (including treating EIO as EOF and
      pre-filtering stdout lines from Hadoop Streaming)
    - Optionally calls *record_callback* for each log4j record (see
      :py:func:`~mrjob.logs.log4j._parse_hadoop_log4j_records`).
    """
    def yield_lines():
        try:
            for line in stderr:
                yield to_string(line)
        except __HOLE__ as e:
            # this is just the PTY's way of saying goodbye
            if e.errno == errno.EIO:
                return
            else:
                raise

    def pre_filter(line):
        return bool(_HADOOP_STREAMING_NON_LOG4J_LINE_RE.match(line))

    def yield_records():
        for record in _parse_hadoop_log4j_records(yield_lines(),
                                                  pre_filter=pre_filter):
            if record_callback:
                record_callback(record)
            yield record

    result = _parse_step_log_from_log4j_records(yield_records())

    _add_implied_job_id(result)
    for error in result.get('errors') or ():
        _add_implied_task_id(error)

    return result
dataset/ETHPy150Open Yelp/mrjob/mrjob/logs/step.py/_interpret_hadoop_jar_command_stderr