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

display_format: pretty and display_format: short lead to crash #1263

Closed
micahellison opened this issue Jun 19, 2021 · 6 comments · Fixed by #1495
Closed

display_format: pretty and display_format: short lead to crash #1263

micahellison opened this issue Jun 19, 2021 · 6 comments · Fixed by #1495
Labels
bug Something isn't working 📌 This can't go stale

Comments

@micahellison
Copy link
Member

Bug Report

Environment

  • jrnl --diagnostic output:
jrnl: v2.8.1
Python: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
OS: Windows 10
  • Install method: pipx

Current Behavior

Setting the display_format configuration operation to pretty or short causes jrnl to crash when viewing the contents of the journal.

Expected Behavior

It should use the selected format instead of crashing.

Repro Steps

Other Information

Stack trace is the same whether on pretty or short:

Traceback (most recent call last):
  File "c:\users\micah\.pyenv\pyenv-win\versions\3.8.2\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\micah\.pyenv\pyenv-win\versions\3.8.2\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\micah\.local\bin\jrnl.exe\__main__.py", line 7, in <module>
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\cli.py", line 35, in cli
    return run(args)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 73, in run
    search_mode(**kwargs)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 179, in search_mode
    _display_search_results(**kwargs)
  File "c:\users\micah\.local\pipx\venvs\jrnl\lib\site-packages\jrnl\jrnl.py", line 340, in _display_search_results
    print(exporter.export(journal, args.filename))
AttributeError: 'NoneType' object has no attribute 'export'
@micahellison micahellison added bug Something isn't working 🆕 New! labels Jun 19, 2021
@micahellison micahellison removed the 🆕 New! label Jun 26, 2021
@viegasfh
Copy link
Contributor

viegasfh commented Jul 5, 2021

I also found this bug a few days ago. Thanks for bringing it up!

@MinchinWeb
Copy link
Contributor

This is because (under the current code base), display_format runs an exporter under the hood, but "short" and "pretty" aren't defined as exporters, but a CLI switches that call specialized "print" functions of the Journal class.

#1216 (among many other things) fixes this by dropping the special cases of "short" and "pretty" and promoting them from "only" CLI switches to "proper" exporters. My logic was to thus allow these formats to be overridden by user-supplied plugins (i.e. define your own "short" format), but it will fix this too. C.f. #1006.

@tjapro
Copy link

tjapro commented Jan 12, 2022

Just a bug report from other source about the same problem: https://bugzilla.redhat.com/show_bug.cgi?id=2039871

@micahellison
Copy link
Member Author

H @tjapro, I get an access denied error when I view that link. Is it a bug report about jrnl, and/or is there anything from it specifically that you can share here?

@tjapro
Copy link

tjapro commented Jan 15, 2022

The issue is now public, but the report is here:

Version-Release number of selected component:
jrnl-2.8.3-1.fc35

Additional info:
reporter:       libreport-2.15.2
cgroup:         0::/user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-4e5d19ff-4bd5-45e5-aee5-b18b97f2ad36.scope
cmdline:        /usr/bin/python3 -s /usr/bin/jrnl -to today
crash_function: _display_search_results
exception_type: AttributeError
executable:     /usr/bin/jrnl
interpreter:    python3-3.10.1-2.fc35.x86_64
kernel:         5.15.12-200.fc35.x86_64
runlevel:       N 5
type:           Python3
uid:            1000

Truncated backtrace:
jrnl.py:340:_display_search_results:AttributeError: 'NoneType' object has no attribute 'export'

Traceback (most recent call last):
  File "/usr/bin/jrnl", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3.10/site-packages/jrnl/cli.py", line 34, in cli
    return run(args)
  File "/usr/lib/python3.10/site-packages/jrnl/jrnl.py", line 73, in run
    search_mode(**kwargs)
  File "/usr/lib/python3.10/site-packages/jrnl/jrnl.py", line 179, in search_mode
    _display_search_results(**kwargs)
  File "/usr/lib/python3.10/site-packages/jrnl/jrnl.py", line 340, in _display_search_results
    print(exporter.export(journal, args.filename))
AttributeError: 'NoneType' object has no attribute 'export'

Local variables in innermost frame:
args: Namespace(debug=False, preconfig_cmd=None, postconfig_cmd=None, filename=None, on_date=None, today_in_history=False, month=None, day=None, year=None, start_date=None, end_date='today', contains=None, strict=False, starred=False, limit=None, excluded=[], edit=False, delete=False, export=False, tags=False, short=False, config_override=[], text=[], journal_name='default')
journal: <Journal with 1 entries>
kwargs: {'config': {'colors': {'body': 'NONE', 'date': 'GREEN', 'tags': 'YELLOW', 'title': 'BLUE'}, 'default_hour': 9, 'default_minute': 0, 'display_format': 'pretty', 'editor': 'nano', 'encrypt': False, 'highlight': True, 'indent_character': '|', 'journals': {'default': '~/Projects/jrnl/journal.txt', 'story': {'journal': '~/Projects/jrnl/story.txt'}}, 'linewrap': 80, 'tagsymbols': '#', 'template': False, 'timeformat': '%a, %d %b %Y %H:%M:%S', 'version': 'v2.8.3', 'journal': '~/Projects/jrnl/journal.txt'}, 'old_entries': [<Entry 'Este texto é um teste' on 2022-01-10 19:02>]}
exporter: None

@musicinmybrain
Copy link
Contributor

At @tjapro’s request as the original submitter, the downstream bug report is now public.

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

Successfully merging a pull request may close this issue.

6 participants