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

import19: UnboundLocalError: local variable 'editlog_data' referenced before assignment #1824

Open
diepes opened this issue Dec 27, 2024 · 1 comment
Labels
bug Something isn't working cli

Comments

@diepes
Copy link

diepes commented Dec 27, 2024

while trying moin2 through pip

moin --version
Python 3.9.6
Flask 3.1.0
Werkzeug 3.1.3

converting/importing files from moin19 got the error below, the import continued after this

2024-12-28 00:57:35,737 ERROR moin.cli.migration.moin19.import19:386 PageRevision 'ScubaDiving' '00000023' raised exception:
Traceback (most recent call last):
  File "/moin2/lib/python3.9/site-packages/moin/cli/migration/moin19/import19.py", line 377, in iter_revisions
    page_rev = PageRevision(self, revno, os.path.join(revisionspath, fname), self.target_namespace)
  File "/moin2/lib/python3.9/site-packages/moin/cli/migration/moin19/import19.py", line 460, in __init__
    meta.update(editlog_data)
UnboundLocalError: local variable 'editlog_data' referenced before assignment
@ThomasWaldmann ThomasWaldmann changed the title import29: UnboundLocalError: local variable 'editlog_data' referenced before assignment import19: UnboundLocalError: local variable 'editlog_data' referenced before assignment Dec 27, 2024
@ThomasWaldmann ThomasWaldmann added the bug Something isn't working label Dec 27, 2024
@UlrichB22 UlrichB22 added the cli label Dec 28, 2024
@UlrichB22
Copy link
Collaborator

This seems to be related to

try:
editlog_data = editlog.find_rev(revno)
except KeyError:
logging.warning(f"Missing edit log data: name = {item_name}, revision = {revno}")
if 1 <= revno <= item.current:
editlog_data = { # make something up
NAME: [item.name],
MTIME: int(os.path.getmtime(path)),
ACTION: ACTION_SAVE,
}

An else branch with a custom exception is missing there. Did you get the message "Missing edit log data: name = {item_name}, revision = {revno}" from line 452 before the traceback in the log? There seems to be an inconsistency between the "edit-log" file and the revision files in your moin1.9 data. I will add an exception message for this case, but it won't change the resulting moin2 wiki data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli
Projects
None yet
Development

No branches or pull requests

3 participants