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

clean_pdf_file throws SystemError on MacOS with mmap: resizing not available #103

Open
Hu1buerger opened this issue May 10, 2023 · 1 comment

Comments

@Hu1buerger
Copy link

When running extract extract_references_from_file(path) on this file
Kotti et al. - 2023 - Machine Learning for Software Engineering A Terti.pdf
on MacOS Ventura 13.3.1 the following exception gets thrown.


    def clean_pdf_file(filename):
        """
        strip leading and/or trailing junk from a PDF file
        """
        with open(filename, 'r+b') as file, mmap.mmap(file.fileno(), 0, access=mmap.ACCESS_WRITE) as mmfile:
            start = mmfile.find(b'%PDF-')
            if start == -1:
                # no PDF marker found
                LOGGER.debug('not a PDF file')
                return
            end = mmfile.rfind(b'%%EOF')
            offset = len(b'%%EOF')
            if start > 0:
                LOGGER.debug('moving and truncating')
                mmfile.move(0, start, end + offset - start)
                #mmfile.resize(end + offset - start)
                mmfile.flush()
            elif end > 0 and end + offset != mmfile.size():
                LOGGER.debug('truncating only')
>               mmfile.resize(end + offset - start)
E               SystemError: mmap: resizing not available--no mremap()

../venv/lib/python3.10/site-packages/refextract/references/engine.py:1412: SystemError
@Hu1buerger Hu1buerger changed the title clean_pdf_file throws SystemError: mmap: resizing not available clean_pdf_file throws SystemError on MacOS with mmap: resizing not available May 10, 2023
@StevenZhang0116
Copy link

same problem here; do you have any idea on how to solve this?

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

No branches or pull requests

3 participants
@Hu1buerger @StevenZhang0116 and others