Staging instance, all changes can be removed at any time

Skip to content

writer/__init__.py: Fix UnboundLocalError

I noticed docker tests were failing since a couple of days (see https://jenkins.softwareheritage.org/view/all/job/swh-docker-dev/286/ for instance).

This is due to the following error being raised since a9fb7c73:

;1mswh-storage_1                   | Traceback (most recent call last):
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
;1mswh-storage_1                   |     rv = self.dispatch_request()
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
;1mswh-storage_1                   |     return self.view_functions[rule.endpoint](**req.view_args)
;1mswh-storage_1                   |   File "</srv/softwareheritage/venv/lib/python3.7/site-packages/decorator.py:decorator-gen-100>", line 2, in origin_add_one
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/core/api/negotiation.py", line 144, in _negotiate
;1mswh-storage_1                   |     return f.negotiator(*args, **kwargs)
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/core/api/negotiation.py", line 79, in __call__
;1mswh-storage_1                   |     result = self.func(*args, **kwargs)
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/core/api/__init__.py", line 374, in _f
;1mswh-storage_1                   |     obj_meth = getattr(backend_factory(), meth_name)
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/storage/api/server.py", line 22, in get_storage
;1mswh-storage_1                   |     storage = get_swhstorage(**app.config['storage'])
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/storage/__init__.py", line 62, in get_storage
;1mswh-storage_1                   |     return Storage(**kwargs)
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/storage/storage.py", line 76, in __init__
;1mswh-storage_1                   |     self.journal_writer = get_journal_writer(**journal_writer)
;1mswh-storage_1                   |   File "/srv/softwareheritage/venv/lib/python3.7/site-packages/swh/journal/writer/__init__.py", line 11, in get_journal_writer
;1mswh-storage_1                   |     warnings.warn(
;1mswh-storage_1                   | UnboundLocalError: local variable 'warnings' referenced before assignment

This simple diff fixes the issue but I do not really understand why we get such an error though.


Migrated from D2496 (view on Phabricator)

Merge request reports

Loading