Skip to content

Commit

Permalink
fix: polyfill nullcontext for py3.6. Document compatibility with Pyth…
Browse files Browse the repository at this point in the history
…on versions.
  • Loading branch information
bgeron committed Mar 14, 2021
1 parent 3342f11 commit 9515561
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,10 @@ The code is dual-licenced under both
- `Apache License, Version 2.0 <https://choosealicense.com/licenses/apache-2.0>`_

at your option.

Supported Python versions
-------------------------

The versions that are regularly tested can be found `here <https://github.com/bgeron/diff-pdf-visually/blob/main/tox.ini>`_, that's probably Python 3.8 and Python 3.9.

For your convenience we declare more Python versions acceptable in ``pyproject.toml``, but the non-tested versions could potentially break from time to time. My goal is to support basically Python 3.x; please let me know if something doesn't work on an older version.
2 changes: 1 addition & 1 deletion diff_pdf_visually/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
'Quickly check whether there is a visible difference between two PDFs, using ImageMagick and pdftocairo.
Quickly check whether there is a visible difference between two PDFs, using ImageMagick and pdftocairo.
"""

__version__ = '1.6.1'
Expand Down
2 changes: 1 addition & 1 deletion diff_pdf_visually/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import os.path, pathlib, subprocess, sys, tempfile, time
from concurrent.futures import ThreadPoolExecutor
from contextlib import nullcontext
from .polyfill import nullcontext
from .constants import DEFAULT_THRESHOLD, DEFAULT_VERBOSITY, DEFAULT_DPI
from .constants import VERB_PRINT_REASON, VERB_PRINT_TMPDIR
from .constants import VERB_PERPAGE, VERB_PRINT_CMD, VERB_ROUGH_PROGRESS
Expand Down
14 changes: 14 additions & 0 deletions diff_pdf_visually/polyfill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Reimplementations of standard functionality to get better compatibility with older
Python versions.
"""

class nullcontext:
def __init__(self, enter_result):
self._enter_result = enter_result

def __enter__(self):
return self._enter_result

def __exit__(self, exc_type, exc_value, traceback):
pass

0 comments on commit 9515561

Please sign in to comment.