takluyver / bookbook

Tools to use a collection of notebooks as 'chapters'
MIT License
99 stars 24 forks source link

pathlib support bug - TypeError: can only concatenate str (not "WindowsPath") to str #19

Open flutefreak7 opened 4 years ago

flutefreak7 commented 4 years ago

https://github.com/takluyver/bookbook/blob/50678bfaef28f18ac51dfbaf79247fb0d79e9529/bookbook/latex.py#L79

Full Traceback:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 77, in combine_notebooks
    combined_nb.cells.extend(add_sec_label(nb.cells[0], nbname))
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 53, in add_sec_label
    raise NoHeader
__main__.NoHeader

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 163, in <module>
    main()
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 160, in main
    combine_and_convert(args.source_dir, args.output_file, args.pdf, args.template)
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 144, in combine_and_convert
    combined_nb = combine_notebooks(notebook_files)
  File "C:\Python37\lib\site-packages\bookbook\latex.py", line 79, in combine_notebooks
    raise NoHeader("Failed to find header in " + filename)
TypeError: can only concatenate str (not "WindowsPath") to str

Looks like the line linked above just needs str(filename) so that the NoHeader error gets raised correctly. This won't solve my real problem of something to do with a header, but it's a bug nonetheless.

takluyver commented 4 years ago

Yup, I think you're right. Or it could use .format() to put the path into the message. Do you want to make a PR?

takluyver commented 4 years ago

Yup, I think you're right. Or it could use .format() to put the path into the message. Do you want to make a PR?