Opened on 09/11/2018 at 01:07:45 PM
Closed on 09/24/2018 at 10:43:12 AM
#6941 closed change (fixed)
[python-abp] Remove asserts from production code
Reported by: | kvas | Assignee: | atudor |
---|---|---|---|
Priority: | P4 | Milestone: | |
Module: | Sitescripts | Keywords: | goodfirstbug |
Cc: | Blocked By: | ||
Blocking: | Platform: | Unknown / Cross platform | |
Ready: | yes | Confidential: | no |
Tester: | Unknown | Verified working: | no |
Review URL(s): |
Description
Background
Filter parser in python-abp includes the following snippet:
assert line.to_string().replace(' ', '') == content.replace(' ', '')
It ensures that parsing a filter followed by serialization to string produces the original filter. However, asserts in production code are not a reliable way of detecting errors because they are not executed if the script is run with optimizations (also it might not be the best if things crash in production). They are a performance cost however (except when run with optimizations).
What to change
- Remove the assert line from production code.
- Execute the same assertion in tests either by wrapping abp.filters.parser.parse_line or by a separate test (separate test seems preferable for simplicity and clarity but if there are good reasons to wrap, that option can be considered).
Attachments (0)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Solved in this commit: https://github.com/adblockplus/python-abp/commit/0f85a2afe908b751f4e8b851e74a5228ee378c49