Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging failure when patching builtins on python 3.7.7 (patched open() doesn't take keyword arguments) #683

timt8 opened this issue Jan 29, 2021 · 3 comments


Copy link

@timt8 timt8 commented Jan 29, 2021

Running python 3.7.7, and monkey patching builtins, I see the following exception when configuring logging.
Looks like the patched open() call should take in keyword args?

In setup logging
Traceback (most recent call last):
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 563, in configure
    handler = self.configure_handler(handlers[name])
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 736, in configure_handler
    result = factory(**kwargs)
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 148, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 55, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 1087, in __init__
    StreamHandler.__init__(self, self._open())
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 1116, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
TypeError: open() got an unexpected keyword argument 'encoding'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./", line 46, in <module>
  File "./", line 43, in setup_logging
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 800, in dictConfig
  File "/Users/tim/.pyenv/versions/3.7.7/lib/python3.7/logging/", line 571, in configure
    '%r' % name) from e
ValueError: Unable to configure handler 'file'

Script used to reproduce:

#!/usr/bin/env python

import eventlet

import logging.config

logging_dict = {
    'version': 1,
    'loggers': {
            '': {
                'level': 'INFO',
               'handlers': ['file'],
               'propagate': False
    'handlers': {
            'file': {
                'class': 'logging.handlers.RotatingFileHandler',
                'level': 'INFO',
                'formatter': 'detailed',
                'filename': '/tmp/foo.log',
                'mode': 'a',
                'maxBytes': 10485760,
                'backupCount': 9,
    'formatters': {
            'detailed': {
                'format': '%(asctime)s [%(name)s|%(process)d|%(thread)d|%(threadName)s] | %(filename)s:%(funcName)s:(lineno)d (%(levelname)s) - %(message)s'  # noqa: E501

def setup_logging():
    print('In setup logging')

if __name__ == "__main__":
temoto added a commit that referenced this issue Jan 29, 2021
Copy link

@temoto temoto commented Jan 30, 2021

@timt8 fix is merged into master. Please, try again with latest code.

pip install

Copy link

@timt8 timt8 commented Jan 31, 2021

Thank you so much @temoto! Will this be included in an upcoming release? I may have missed it, but I don't think I saw the changes in the latest (0.30.0) release.

@timt8 timt8 closed this Jan 31, 2021
Copy link

@temoto temoto commented Feb 2, 2021

@timt8 it's in v0.30.1

bors bot added a commit to duckinator/ that referenced this issue Feb 3, 2021
Merge #73
73: Update eventlet to 0.30.1 r=duckinator a=pyup-bot

This PR updates [eventlet]( from **0.30.0** to **0.30.1**.

   ### 0.30.1
* patcher: built-in open() did not accept kwargs eventlet/eventlet#683


  - PyPI:
  - Changelog:
  - Homepage:

Co-authored-by: pyup-bot <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants