NameError: global name 'Dropbox' is not defined

Bug #1795227 reported by Pedro Gimeno on 2018-09-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Duplicity
Medium
Unassigned

Bug Description

Using the current head (1334 at the time of writing), I'm getting an exception when trying to backup using the dpbx scheme:

Traceback (innermost last):
  File "./duplicity.py", line 1668, in <module>
    with_tempdir(main)
  File "./duplicity.py", line 1654, in with_tempdir
    fn()
  File "./duplicity.py", line 1488, in main
    action = commandline.ProcessCommandLine(sys.argv[1:])
  File "<redacted>/duplicity/commandline.py", line 1180, in ProcessCommandLine
    backup, local_pathname = set_backend(args[0], args[1])
  File "<redacted>/duplicity/commandline.py", line 1051, in set_backend
    globals.backend = backend.get_backend(bend)
  File "<redacted>/duplicity/backend.py", line 223, in get_backend
    obj = get_backend_object(url_string)
  File "<redacted>/duplicity/backend.py", line 209, in get_backend_object
    return factory(pu)
  File "<redacted>/duplicity/backends/dpbxbackend.py", line 110, in __init__
    self.login()
  File "<redacted>/duplicity/backends/dpbxbackend.py", line 163, in login
    self.api_client = Dropbox(self.load_access_token())
 NameError: global name 'Dropbox' is not defined

The problem was introduced with the removal of the globals in revision 1297:

https://bazaar.launchpad.net/~duplicity-team/duplicity/0.8-series/revision/1297#duplicity/backends/dpbxbackend.py

Re-adding the globals makes the problem disappear. I have NOT checked other backends modified in the same revision for similar problems, so it's possible that others are affected.

Pedro Gimeno (pgimeno) wrote :

For clarity, I've attached a patch that reverts the removal of the globals.

Without this patch, the imported identifiers are local to the __init__() constructor where the import statements are, and the rest of the code can't use them.

Changed in duplicity:
importance: Undecided → Medium
milestone: none → 0.8.00
status: New → Fix Committed
Changed in duplicity:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers