karlicoss / orgparse

Python module for reading Emacs org-mode files
https://orgparse.readthedocs.org
BSD 2-Clause "Simplified" License
371 stars 43 forks source link

orgparse.load() is broken for file-like objects #32

Closed odahoda closed 3 years ago

odahoda commented 3 years ago

Hi,

The docstring says that the argument can be "str or file-like" and I've been using it with the latter. But that got broken by a recent venv update.

Looks like commit https://github.com/karlicoss/orgparse/commit/30671890e38db0c7becab12dfda6ff7d97496a8b is the culprit. It added a line

path = str(path) # in case of pathlib.Path

which means that it's now trying to open a file named <_io.TextIOWrapper name='tasks.org' mode='r' encoding='UTF-8'>, which obviously fails.

That line of code looks a bit out of place, or at least unrelated to the commit message. Was it intended to be commited?

-Ben

karlicoss commented 3 years ago

Whoops. Thanks for reporting!

I actually intended to commit (although in a separate commit) so it would have broken anyway since since it's not covered by a test (and I'm not using that functionality). I added the test + proper mypy coverage as well, so hopefully this will work now. Can you check master? If it works for you I'll release a new version straightaway.

odahoda commented 3 years ago

Yes, works fine again. Thanks for the quick fix!

karlicoss commented 3 years ago

done!