Visitar URL original
Fix convert_file for Python 3.13 by cjwatson · Pull Request #384 · JessicaTegner/pypandoc · GitHub
Skip to content

Fix convert_file for Python 3.13 - #384

Merged
JessicaTegner merged 2 commits into
JessicaTegner:masterfrom
cjwatson:convert-file-py313
Jan 8, 2025
Merged

JessicaTegner merged 2 commits into
JessicaTegner:masterfrom
cjwatson:convert-file-py313

Conversation

@cjwatson

@cjwatson cjwatson commented Dec 8, 2024

Copy link
Copy Markdown
Contributor

As of python/cpython#117589 (at least), Path.glob returns an Iterator rather than Generator (which inherits from Iterator). convert_file doesn't need to care about this distinction; it can reasonably accept both.

This previously caused a test failure along these lines:

______________________________________________________ TestPypandoc.test_basic_conversion_from_file_pattern_pathlib_glob _______________________________________________________

self = <tests.TestPypandoc testMethod=test_basic_conversion_from_file_pattern_pathlib_glob>

    def test_basic_conversion_from_file_pattern_pathlib_glob(self):
        received_from_str_filename_input = pypandoc.convert_file("./*.md", 'html').lower()
>       received_from_path_filename_input = pypandoc.convert_file(Path(".").glob("*.md"), 'html').lower()

tests.py:654:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

source_file = <map object at 0x7f83952c9420>, to = 'html', format = None, extra_args = (), encoding = 'utf-8', outputfile = None, filters = None, verify_format = True
sandbox = False, cworkdir = '/home/cjwatson/src/python/pypandoc', sort_files = True
[...]
        if not _identify_path(discovered_source_files):
>           raise RuntimeError("source_file is not a valid path")
E           RuntimeError: source_file is not a valid path

pypandoc/__init__.py:201: RuntimeError

As of python/cpython#117589 (at least),
`Path.glob` returns an `Iterator` rather than `Generator` (which
inherits from `Iterator`).  `convert_file` doesn't need to care about
this distinction; it can reasonably accept both.

This previously caused a test failure along these lines:

  ______________________________________________________ TestPypandoc.test_basic_conversion_from_file_pattern_pathlib_glob _______________________________________________________

  self = <tests.TestPypandoc testMethod=test_basic_conversion_from_file_pattern_pathlib_glob>

      def test_basic_conversion_from_file_pattern_pathlib_glob(self):
          received_from_str_filename_input = pypandoc.convert_file("./*.md", 'html').lower()
  >       received_from_path_filename_input = pypandoc.convert_file(Path(".").glob("*.md"), 'html').lower()

  tests.py:654:
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

  source_file = <map object at 0x7f83952c9420>, to = 'html', format = None, extra_args = (), encoding = 'utf-8', outputfile = None, filters = None, verify_format = True
  sandbox = False, cworkdir = '/home/cjwatson/src/python/pypandoc', sort_files = True
  [...]
          if not _identify_path(discovered_source_files):
  >           raise RuntimeError("source_file is not a valid path")
  E           RuntimeError: source_file is not a valid path

  pypandoc/__init__.py:201: RuntimeError
@JessicaTegner

Copy link
Copy Markdown
Owner

hey @cjwatson

It seems some CI is failing. Could you take a look at this

@cjwatson

Copy link
Copy Markdown
Contributor Author

One of your indirect dependencies seems to have dropped PyPy 3.8 support. What do you want to do about that? Judging from PyPy's release notes it seems as though they've dropped 3.8 support, so maybe the easiest way out would be to just drop PyPy 3.8 support here, but that's not a decision I feel I can take for you. If you don't want to do that then I guess it would require some version pinning on PyPy 3.8, which would probably be a moving target.

@JessicaTegner

Copy link
Copy Markdown
Owner

there we go @cjwatson
I updated the CI workflow, dropping support for python 3.7, 3.8 and pyp3.8 ( #387 )

If you are all done with the fix, this can be merged

@JessicaTegner
JessicaTegner merged commit 3fd939c into JessicaTegner:master Jan 8, 2025
@cjwatson
cjwatson deleted the convert-file-py313 branch January 9, 2025 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants