<issue_start><issue_comment>Title: test_python_dispatch fails under pytest
username_0: ## 🐛 Bug
```
--- Logging error ---
Traceback (most recent call last):
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/site-packages/_pytest/logging.py", line 65, in format
    return super().format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/raid/rzou/pt/workspace-env/bin/pytest", line 11, in <module>
```

## To Reproduce

`pytest test/test_python_dispatch.py -v`
<issue_comment>username_1: Mixing different format functions.

The old-style % formatting uses % codes for formatting:
```python
'It will cost $%d Rupees.' % 100
```
The new-style {} formatting uses {} codes and the .format method
```python
'It will cost ${0} Rupees.'.format(100)
```
Note that with old-style formatting, you have to specify multiple arguments using a tuple:
```python
'%d days and %d nights' % (40, 40)
```
<issue_comment>username_0: @username_1 do you have a proposed fix?
<issue_comment>username_1: Will you tell me how to reproduce ?
@username_0
<issue_comment>username_1: @username_0 can you review my PR and correct errors (if any) please.
<issue_comment>username_2: Hello, I am a beginner and I want to contribute to this project. Can you please help me to get started?
<issue_comment>username_3: I have solved the issue my PR kindly approve it
<issue_comment>username_3: https://github.com/username_3/pytorch/commit/74f11123aa1da67013a04ebca79d2d90915c6469 this is  what I meant
<issue_comment>username_4: ERROR:
BUG:    Traceback (most recent call last):
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 1025, in emit
    msg = self.format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 869, in format
    return fmt.format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/site-packages/_pytest/logging.py", line 65, in format
    return super().format(record)
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 608, in format
    record.message = record.getMessage()
  File "/scratch/rzou/pt/workspace-env/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/raid/rzou/pt/workspace-env/bin/pytest", line 11, in <module>


SOLUTION:
def handleError(self, record):
    """
    Handle errors which occur during an emit() call.

    This method should be called from handlers when an exception is
    encountered during an emit() call. If raiseExceptions is false,
    exceptions get silently ignored. This is what is mostly wanted
    for a logging system - most users will not care about errors in
    the logging system, they are more interested in application errors.
    You could, however, replace this with a custom handler if you wish.
    The record which was being processed is passed in to this method.
    """
    if raiseExceptions:
        ei = sys.exc_info()
        try:
            traceback.print_exception(ei[0], ei[1], ei[2],
                                      None, sys.stderr)
            sys.stderr.write('Logged from file %s, line %s\n' % (
                             record.filename, record.lineno))
        except IOError:
            pass    # see issue 5971
        finally:
            del ei