[issue46957] Logger with a custom class breaks on copy

2022-03-08 Thread Eric V. Smith


Eric V. Smith  added the comment:

In what way does it break? You haven't shown an error.

Why are you deepcopying the logger?

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46957] Logger with a custom class breaks on copy

2022-03-08 Thread Govinda Totla


New submission from Govinda Totla :

The logging module allows you set a custom Logger class as the default logger. 
However, this breaks when we try to copy the logger which was created before 
setting the logger class

```
import copy
import logging

# Some module we don't control
oldLogger = logging.getLogger("abc")

# Some module where we want to change over to custom logging
class MyLogger(logging.Logger):
pass

# Override the manager, root, etc., so everything uses our class
logging.setLoggerClass(MyLogger)
logging.root = root = MyLogger("", logging.WARNING)
logging.Logger.manager = logging.Manager(root)

newLogger = logging.getLogger("def")

# Later on this happens, which internally calls __reduce__
copy.deepcopy(oldLogger)
```

--
components: Library (Lib)
messages: 414750
nosy: govinda18
priority: normal
severity: normal
status: open
title: Logger with a custom class breaks on copy
type: crash
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com