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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pypandoc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, with_statement
from typing import Iterable
from typing import Iterator
from typing import Union
from typing import Generator

import os
import re
Expand Down Expand Up @@ -97,7 +97,7 @@ def convert_text(source:str, to:str, format:str, extra_args:Iterable=(), encodin
cworkdir=cworkdir)


def convert_file(source_file:Union[list, str, Path, Generator], to:str, format:Union[str, None]=None,
def convert_file(source_file:Union[list, str, Path, Iterator], to:str, format:Union[str, None]=None,
extra_args:Iterable=(), encoding:str='utf-8', outputfile:Union[None, str, Path]=None,
filters:Union[Iterable, None]=None, verify_format:bool=True, sandbox:bool=False,
cworkdir:Union[str, None]=None, sort_files=True) -> str:
Expand Down Expand Up @@ -165,7 +165,7 @@ def convert_file(source_file:Union[list, str, Path, Generator], to:str, format:U
source_file = Path(source_file)
elif isinstance(source_file, list):
source_file = [Path(x) for x in source_file]
elif isinstance(source_file, Generator):
elif isinstance(source_file, Iterator):
source_file = [Path(x) for x in source_file]


Expand All @@ -175,7 +175,7 @@ def convert_file(source_file:Union[list, str, Path, Generator], to:str, format:U
# if it is, just use the absolute path
if isinstance(source_file, list):
source_file = [x if x.is_absolute() else Path(cworkdir, x) for x in source_file]
elif isinstance(source_file, Generator):
elif isinstance(source_file, Iterator):
source_file = (x if x.is_absolute() else Path(cworkdir, x) for x in source_file)
# check ifjust a single path was given
elif isinstance(source_file, Path):
Expand Down