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

Fix convert_file for Python 3.13 #384

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

cjwatson
Copy link
Contributor

@cjwatson cjwatson commented Dec 8, 2024

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
Owner

hey @cjwatson

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

@cjwatson
Copy link
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
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
34 checks passed
@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