python / cpython

The Python programming language
https://www.python.org
Other
63.11k stars 30.22k forks source link

logging.Formatter crashes when default_msec_format is None. #84480

Closed 341b2d53-9c47-429a-89a2-f88644ed631d closed 4 years ago

341b2d53-9c47-429a-89a2-f88644ed631d commented 4 years ago
BPO 40300
Nosy @vsajip, @felixxm
PRs
  • python/cpython#19551
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields: ```python assignee = None closed_at = created_at = labels = ['3.7', '3.8', 'type-feature', 'library', '3.9'] title = 'logging.Formatter crashes when default_msec_format is None.' updated_at = user = 'https://github.com/felixxm' ``` bugs.python.org fields: ```python activity = actor = 'vinay.sajip' assignee = 'none' closed = True closed_date = closer = 'vinay.sajip' components = ['Library (Lib)'] creation = creator = 'felixxm' dependencies = [] files = [] hgrepos = [] issue_num = 40300 keywords = ['patch'] message_count = 2.0 messages = ['366589', '366660'] nosy_count = 2.0 nosy_names = ['vinay.sajip', 'felixxm'] pr_nums = ['19551'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue40300' versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9'] ```

    341b2d53-9c47-429a-89a2-f88644ed631d commented 4 years ago

    We would like to subclass logging.Formatter with a custom "default_time_format" and an empty "default_msec_format". Unfortunately logging.Formatter crashes when default_msec_format is None, see [1].

    I'm happy to provide a patch.

    [1] https://github.com/python/cpython/blob/5907e61a8d4da6d0f11bf1062d6d17484560a15e/Lib/logging/__init__.py#L607

    vsajip commented 4 years ago

    New changeset 06a35542aad15666cace307d841a95e33f3cbee6 by Mariusz Felisiak in branch 'master': bpo-40300: Allow empty logging.Formatter.default_msec_format. (GH-19551) https://github.com/python/cpython/commit/06a35542aad15666cace307d841a95e33f3cbee6