Skip to content

send_mail fails with KeyError: 1 under Django >=1.8.3 #26

@nealtodd

Description

@nealtodd

The Django 1.8.3 security update introduces a backport (django/django@76c526f) which casts the verbosity argument to an int.

This results in the error:

  File ".../django-mailer/django_mailer/management/commands/__init__.py", line 13, in create_handler
    handler.setLevel(LOGGING_LEVEL[verbosity])
KeyError: 1

In my fork I just needed to change LOGGING_LEVEL in https://github.com/SmileyChris/django-mailer-2/blob/master/django_mailer/management/commands/__init__.py#L4 from:

LOGGING_LEVEL = {'0': logging.ERROR, '1': logging.WARNING, '2': logging.DEBUG}

to:
LOGGING_LEVEL = {0: logging.ERROR, 1: logging.WARNING, 2: logging.DEBUG}

because I don't need to maintain backwards compatibility with earlier Django versions.

A backwards compatible fix in this source repo would need either a version check to set LOGGING_LEVEL appropriately or a try-catch in create_handler to cast if there's a KeyError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions