Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: cannot access local variable 'url' where it is not associated with a value #245

Open
mohsen-mahmoodi opened this issue Nov 17, 2024 · 0 comments · May be fixed by #246
Open

Comments

@mohsen-mahmoodi
Copy link

Checklist

  • [ V] I have verified that I am using a GIS-enabled database, such as PostGIS or Spatialite.
  • [ V] I have verified that that issue exists against the master branch of django-cities.
  • [ V] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [ V] I have reduced the issue to the simplest possible case.
  • [ X] I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Steps to reproduce

Configure CITIES_FILES for a pre-downloaded file without URL:

CITIES_FILES = {
        'country': {
            'filename': 'not-existing',
            'urls': []
        },
}

Run the import command:

python manage.py cities --import=country

Expected behavior

Exception: File not found and download failed: citiesxx500.zip [[]]

Actual behavior

UnboundLocalError: cannot access local variable 'url' where it is not associated with a value

Reason

In the file cities/management/commands/citities.py method def download(self, filekey):, we have a line to raise an exception like this:

raise Exception("File not found and download failed: {} [{}]".format(filename, url))

It should be changed to:

raise Exception("File not found and download failed: {} [{}]".format(filename, urls))
mohsen-mahmoodi added a commit to mohsen-mahmoodi/django-cities that referenced this issue Nov 17, 2024
@mohsen-mahmoodi mohsen-mahmoodi linked a pull request Nov 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant