mnemosyne.script: crash on relative data_path

Bug #1723670 reported by Julian Mehne
This bug affects 1 person
Affects Status Importance Assigned to Milestone
The Mnemosyne Project
Fix Committed

Bug Description

Using a relative data_path with the script module crashes mnemosyne on the pbienst and mnemosyne-proj branches (with the Mnemosyne(None) fix applied). In the example below, the path does not exist. Using an existing path leads to a different error, but I think it has the same cause:

from mnemosyne.script import Mnemosyne

m = Mnemosyne('foobar')

Error message:

Previous drive letter no longer available.
If you are using a USB key, refer to the instructions on the website so as not to be affected by drive letter changes.
An unexpected error has occurred.
Please forward the following info to the developers:

Traceback (innermost last):
  File "./", line 11, in <module>
    m = Mnemosyne('foobar')
  File "/home/kelvin/tmp/mnemosyne-pbienst/mnemosyne/mnemosyne/script/", line 45, in __init__
  File "/home/kelvin/tmp/mnemosyne-pbienst/mnemosyne/mnemosyne/libmnemosyne/", line 220, in initialise
  File "/home/kelvin/tmp/mnemosyne-pbienst/mnemosyne/mnemosyne/libmnemosyne/", line 359, in load_database
  File "/home/kelvin/tmp/mnemosyne-pbienst/mnemosyne/mnemosyne/libmnemosyne/controllers/", line 615, in show_open_file_dialog
  File "/home/kelvin/tmp/mnemosyne-pbienst/mnemosyne/mnemosyne/libmnemosyne/", line 154, in flush_sync_server
 TypeError: stop_media() missing 1 required positional argument: 'self'
An unexpected error has occurred.

Some observations:

In mnemosyne/libmnemosyne/
path = expand_path(filename, self.config().data_dir)
-> path = expand_path('default.db', 'foobar')
returns path: 'foobar/default.db'

In mnemosyne/libmnemosyne/databases/
self._path = expand_path(path, self.config().data_dir)
-> self._path = expand_path('foobar/default.db', 'foobar')
returns _path: 'foobar/foobar/default.db'
This is probably wrong.

- Calling "mnemosyne/pyqt_ui/mnemosyne -d foobar" works fine, because "mnemosyne/pyqt_ui/mnemosyne" converts every path to an absolute path, before creating the Mnemosyne class.
- This papers over the crash, but the real fix would be somewhere else, I guess:
=== modified file 'mnemosyne/mnemosyne/script/'
--- mnemosyne/mnemosyne/script/ 2017-10-09 11:42:41 +0000
+++ mnemosyne/mnemosyne/script/ 2017-10-14 22:08:21 +0000
@@ -2,6 +2,8 @@
 # script <email address hidden>

+import os.path
 from mnemosyne.libmnemosyne import Mnemosyne as MnemosyneParent
 from mnemosyne.libmnemosyne.ui_components.main_widget import MainWidget
 from mnemosyne.libmnemosyne.ui_components.review_widget import ReviewWidget
@@ -41,4 +43,8 @@
             ("mnemosyne.script", "ScriptReviewWidget"))
         self.gui_for_component["ScheduledForgottenNew"] = \
             [("mnemosyne.script", "ScriptReviewWidget")]
+ if data_dir is not None:
+ data_dir = os.path.abspath(data_dir)

Revision history for this message
Peter Bienstman (peter-bienstman) wrote :

committed in pbienst, thanks!

Changed in mnemosyne-proj:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.