moggers87 / salmon

A Python Mail Server
Other
644 stars 69 forks source link

Misuse of `assert` #138

Closed moggers87 closed 4 years ago

moggers87 commented 4 years ago

There are places in Salmon where assertions are used to protect against programming errors, e.g. https://github.com/moggers87/salmon/blob/6a0345aea423550fc9135ac2eafa84bb75f9aade/salmon/bounce.py#L284-L288

This is no good as assertions are dropped if optimisation is requested: https://docs.python.org/3/reference/simple_stmts.html#the-assert-statement

Assertions should be swapped for something that raises a more appropriate exception.