From 70183887d29faa8a1033797ae13fc757920ca899 Mon Sep 17 00:00:00 2001 From: Kesara Rathnayake Date: Mon, 11 Mar 2024 16:31:57 +1300 Subject: [PATCH] test: Fix recursion issue in walkpdf This fixes the recursion issue in walkpdf introduced by PyPDF==4.1.0. This fix is based @pubpub-zz's suggestion in https://github.com/py-pdf/pypdf/issues/2508#issuecomment-1986371461 Fixes #1111 --- .github/workflows/checks.yml | 6 +++--- tox.ini | 2 +- xml2rfc/walkpdf.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4e21cc25..73b2637c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -90,7 +90,7 @@ jobs: echo "Installing pip + wheel..." python -m pip install --upgrade pip wheel echo "Installing requirements.txt + test dependencies..." - python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=3.2.1" "weasyprint>=53.0,!=57.0,!=60.0" + python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=4.1.0" "weasyprint>=53.0,!=57.0,!=60.0" - name: Generate Valid Tests run: | @@ -151,7 +151,7 @@ jobs: echo "Installing pip + wheel..." python -m pip install --upgrade pip wheel echo "Installing requirements.txt + test dependencies..." - python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=3.2.1" "weasyprint>=53.0,!=57.0,!=60.0" + python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=4.1.0" "weasyprint>=53.0,!=57.0,!=60.0" - name: Generate Valid Tests run: | @@ -201,7 +201,7 @@ jobs: # echo "Installing pip + wheel..." # python -m pip install --upgrade pip wheel # echo "Installing requirements.txt + test dependencies..." -# python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=3.2.1" "weasyprint>=53.0,!=57.0,!=60.0" +# python -m pip install -r requirements.txt tox tox-gh-actions certifi decorator dict2xml pyflakes "pypdf>=4.1.0" "weasyprint>=53.0,!=57.0,!=60.0" # - name: Generate Valid Tests # run: | # make yestests || true diff --git a/tox.ini b/tox.ini index 1d62294a..016901e0 100644 --- a/tox.ini +++ b/tox.ini @@ -33,5 +33,5 @@ deps = pyflakes decorator dict2xml - pypdf>=3.2.1 + pypdf>=4.1.0 weasyprint>=53.0,!=57.0,!=60.0 diff --git a/xml2rfc/walkpdf.py b/xml2rfc/walkpdf.py index a74a5485..665e363d 100644 --- a/xml2rfc/walkpdf.py +++ b/xml2rfc/walkpdf.py @@ -15,7 +15,7 @@ def walk(obj, seen): dobj = {} # Direct objects iobj = [] # Indirect objects - if hasattr(obj, 'keys'): + if isinstance(obj, pypdf.generic.DictionaryObject): for key in obj.keys(): k = key[1:] if key.startswith('/') else key d, i = walk(obj[key], seen)