Opened 9 years ago
Last modified 6 years ago
#5474 new defect
Switch assert statements into proper exceptions
| Reported by: | Christopher Allan Webber | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 0.11.0 |
| Component: | programming | Keywords: | small |
| Cc: | Parent Tickets: |
Description
See this article; we use assert as a "cheap and easy" way to throw errors if we don't want something, but it's not meant for that... and we might even miss serious / dangerous things. Once python is compiled into bytecode, assert might not run.
Change History (4)
comment:1 by , 9 years ago
| Keywords: | small added |
|---|
comment:2 by , 9 years ago
comment:3 by , 8 years ago
| Milestone: | 1.0 → 0.10.0 |
|---|
comment:4 by , 6 years ago
| Milestone: | 0.10.0 → 0.11.0 |
|---|
Note:
See TracTickets
for help on using tickets.

The following command gives a list of files using assertions (minus tests and third-party code):
$ find -name '*.py' -exec grep -nH -e 'assert ' {} + | grep -v test | grep -v site-packages | grep -v 'Paste-2.0' | grep -v 'tox' | grep -v 'extlib' ./mediagoblin/db/base.py:82: assert sess is not None, "Can't save, %r has a detached session" % self ./mediagoblin/db/base.py:188: assert sess is not None, "Not going to delete detached %r" % self ./mediagoblin/db/migration_tools.py:132: assert self.database_current_migration is not None ./mediagoblin/db/migration_tools.py:263: assert migration_number > 0, "Migration number must be > 0!" ./mediagoblin/db/migration_tools.py:264: assert migration_number not in migration_registry, \ ./mediagoblin/db/migration_tools.py:266: assert migration_number <= 44, ('Alembic should be used for ' ./mediagoblin/media_types/stl/processing.py:139: assert os.path.exists(workbench_path) ./mediagoblin/plugins/piwigo/tools.py:99: assert not cmd_name in self._cmd_table ./mediagoblin/plugins/piwigo/tools.py:104: assert not self.cmd_name in self._cmd_table ./mediagoblin/plugins/piwigo/tools.py:163: assert self.in_pwg_session ./mediagoblin/storage/mountstorage.py:70: assert (len(rem_2) > 0) or (None not in table), \ ./mediagoblin/storage/mountstorage.py:72: assert (len(rem_2) > 0) or (len(table) == 0), \ ./mediagoblin/tools/crypto.py:115: assert __itsda_secret is not None