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

  1. Remove the assert line from production code.
  2. 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)

comment:1 Changed on 09/24/2018 at 10:16:57 AM by atudor

  • Owner set to atudor

comment:2 Changed on 09/24/2018 at 10:43:04 AM by atudor

comment:3 Changed on 09/24/2018 at 10:43:12 AM by atudor

  • Resolution set to fixed
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from atudor.
 
Note: See TracTickets for help on using tickets.