Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pikepdf for openSUSE:Factory checked in at 2023-01-03 15:05:23 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pikepdf (Old) and /work/SRC/openSUSE:Factory/.python-pikepdf.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pikepdf" Tue Jan 3 15:05:23 2023 rev:16 rq:1046279 version:6.2.7 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pikepdf/python-pikepdf.changes 2022-10-20 11:11:59.780054288 +0200 +++ /work/SRC/openSUSE:Factory/.python-pikepdf.new.1563/python-pikepdf.changes 2023-01-03 15:05:41.274622815 +0100 @@ -1,0 +2,11 @@ +Mon Jan 2 19:06:21 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 6.2.7: + * Removed a debug message during mmap. + * Fixed errors when using AccessMode.mmap + * Fixed noisy log message. + * Made some flakey tests less flakey. + * Fixed deprecated information in setup.cfg. Thanks @mgorny. + * Rebuild binary wheels using zlib 1.2.13. Source build unchanged. + +------------------------------------------------------------------- Old: ---- pikepdf-6.2.0.tar.gz New: ---- pikepdf-6.2.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pikepdf.spec ++++++ --- /var/tmp/diff_new_pack.GlYifx/_old 2023-01-03 15:05:41.962626831 +0100 +++ /var/tmp/diff_new_pack.GlYifx/_new 2023-01-03 15:05:41.966626854 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-pikepdf # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # Copyright (c) 2020-2021, Martin Hauke <mar...@gmx.de> # # All modifications and additions to the file contributed by third parties @@ -20,7 +20,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-pikepdf -Version: 6.2.0 +Version: 6.2.7 Release: 0 Summary: Read and write PDFs with Python, powered by qpdf License: MPL-2.0 ++++++ pikepdf-6.2.0.tar.gz -> pikepdf-6.2.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/.github/workflows/build.yml new/pikepdf-6.2.7/.github/workflows/build.yml --- old/pikepdf-6.2.0/.github/workflows/build.yml 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/.github/workflows/build.yml 2022-12-31 10:35:00.000000000 +0100 @@ -35,11 +35,11 @@ platforms: all - name: Build wheels - uses: joerick/cibuildwheel@v2.10.2 + uses: joerick/cibuildwheel@v2.11.4 if: matrix.platform != 'manylinux_aarch64' - name: Build wheels (emulated) - uses: joerick/cibuildwheel@v2.10.2 + uses: joerick/cibuildwheel@v2.11.4 if: matrix.platform == 'manylinux_aarch64' env: CIBW_ARCHS_LINUX: aarch64 @@ -78,7 +78,7 @@ run: > pipx run --python /usr/bin/python3 - --spec cibuildwheel==2.10.2 + --spec cibuildwheel==2.11.4 cibuildwheel . --output-dir wheelhouse @@ -114,7 +114,7 @@ python-version: "3.8" - name: Build wheels - uses: joerick/cibuildwheel@v2.10.2 + uses: joerick/cibuildwheel@v2.11.4 #env: # CIBW_ARCHS_MACOS: x86_64 universal2 # for Apple Silicon @@ -135,7 +135,7 @@ strategy: matrix: os: [windows-2019] - platform: [win_amd64, win32] + platform: [win_amd64] steps: - uses: actions/checkout@v3 @@ -158,7 +158,7 @@ build-scripts/win-download-qpdf.ps1 $env:QPDF_VERSION ${{ matrix.platform }} - name: Build wheels - uses: joerick/cibuildwheel@v2.10.2 + uses: joerick/cibuildwheel@v2.11.4 - uses: actions/upload-artifact@v3 with: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/.pre-commit-config.yaml new/pikepdf-6.2.7/.pre-commit-config.yaml --- old/pikepdf-6.2.0/.pre-commit-config.yaml 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/.pre-commit-config.yaml 2022-12-31 10:35:00.000000000 +0100 @@ -23,21 +23,21 @@ - id: isort args: ["--profile", "black", "-a", "from __future__ import annotations"] - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.10.0 hooks: - id: black language_version: python3 - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.0.0 + rev: v2.1.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/asottile/pyupgrade - rev: v2.37.3 + rev: v3.1.0 hooks: - id: pyupgrade args: ["--py37-plus"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v0.982 hooks: - id: mypy additional_dependencies: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/PKG-INFO new/pikepdf-6.2.7/PKG-INFO --- old/pikepdf-6.2.0/PKG-INFO 2022-10-05 00:16:11.198186600 +0200 +++ new/pikepdf-6.2.7/PKG-INFO 2022-12-31 10:37:17.617502500 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pikepdf -Version: 6.2.0 +Version: 6.2.7 Summary: Read and write PDFs with Python, powered by qpdf Home-page: https://github.com/pikepdf/pikepdf Author: James R. Barlow diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/docs/binary-wheels.csv new/pikepdf-6.2.7/docs/binary-wheels.csv --- old/pikepdf-6.2.0/docs/binary-wheels.csv 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/docs/binary-wheels.csv 2022-12-31 10:35:00.000000000 +0100 @@ -1,10 +1,10 @@ ,3.7,3.8,3.9,3.10,3.11,PyPy 3.7,PyPy 3.8, PyPy 3.9 -:fa:`apple` macOS Intel,â ,â ,â ,â ,â ,â ,â ,â³ -:fa:`apple` macOS Apple Silicon,â,â,ð,ð,â³,â,â³,â³ -:fa:`windows` Windows x64,â ,â ,â ,â ,â³,â³,â³,â³ -:fa:`windows` Windows 32-bit,â ,â ,â ,â ,â³,â³,â³,â³ -:fa:`linux` manylinux2014 x64,â ,â ,â ,â ,â ,â ,â ,â³ -:fa:`linux` manylinux2014 32-bit,â ,â ,â ,â ,â ,â ,â ,â³ +:fa:`apple` macOS Intel,â ,â ,â ,â ,â ,â ,â ,â +:fa:`apple` macOS Apple Silicon,â,â,ð,ð,ð,â,â³,â³ +:fa:`windows` Windows x64,â ,â ,â ,â ,â ,â,â ,â³ +:fa:`windows` Windows 32-bit,â ,â ,â ,â ,â,â,â,â +:fa:`linux` manylinux2014 x64,â ,â ,â ,â ,â ,â ,â ,â +:fa:`linux` manylinux2014 32-bit,â ,â ,â ,â ,â ,â ,â ,â :fa:`linux` manylinux2014 aarch64 (ARM64),â ,â ,â ,â ,â³,â³,â³,â³ :fa:`linux` musllinux x64,â³,â³,â³,â³,â³,â³,â³,â³ :fa:`linux` musllinux 32-bit,â³,â³,â³,â³,â³,â³,â³,â³ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/docs/references/debugging.rst new/pikepdf-6.2.7/docs/references/debugging.rst --- old/pikepdf-6.2.0/docs/references/debugging.rst 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/docs/references/debugging.rst 2022-12-31 10:35:00.000000000 +0100 @@ -6,37 +6,25 @@ documents some methods that may help should it be necessary to debug the Python C++ extension (``pikepdf._qpdf``). -Enabling QPDF tracing ---------------------- - -Setting the environment variables ``TC_SCOPE=qpdf`` and -``TC_FILENAME=your_log_file.txt`` will cause libqpdf to log debug messages to the -designated file. For example: - -.. code-block:: bash - - env TC_SCOPE=qpdf TC_FILENAME=libqpdf_log.txt python my_pikepdf_script.py - Using gdb to debug C++ and Python --------------------------------- Current versions of gdb can debug Python and C++ code simultaneously. See -the Python developer's guide on `gdb Support`_. +the Python developer's guide on `gdb Support`_. To use this effectively, a debug +build of pikepdf and QPDF should be created. .. _gdb Support: https://devguide.python.org/gdb/ Compiling a debug build of QPDF ------------------------------- -It may be helpful to create a debug build of QPDF. - -Download QPDF and compile a debug build: +To download QPDF and compile a debug build: .. code-block:: bash # in QPDF source tree cd $QPDF_SOURCE_TREE - cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug + cmake -S . -B build -DENABLE_QTC=ON -DCMAKE_BUILD_TYPE=Debug cmake --build build -j Compile and link against QPDF source tree @@ -79,6 +67,17 @@ You can also run Python through a debugger (``gdb`` or ``lldb``) in this manner, and you will have access to the source code for both pikepdf's C++ and QPDF. +Enabling QPDF tracing +--------------------- + +For builds of QPDF having ENABLE_QTC=ON, setting the environment variables +``TC_SCOPE=qpdf`` and ``TC_FILENAME=your_log_file.txt`` will cause libqpdf to +log debug messages to the designated file. For example: + +.. code-block:: bash + + env TC_SCOPE=qpdf TC_FILENAME=libqpdf_log.txt python my_pikepdf_script.py + Valgrind -------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/docs/releasenotes/version6.rst new/pikepdf-6.2.7/docs/releasenotes/version6.rst --- old/pikepdf-6.2.0/docs/releasenotes/version6.rst 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/docs/releasenotes/version6.rst 2022-12-31 10:35:00.000000000 +0100 @@ -1,3 +1,41 @@ +v6.2.7 +====== + +- Rebuild binary wheels to improve support for Windows 32-bit. + +v6.2.6 +====== + +- Rebuild binary wheels for certain platforms they were blocked from release by lxml not releasing compatible wheels. +Mainly to take advantage of Windows 64-bit. + +v6.2.5 +====== + +- Rebuild binary wheels using qpdf 11.2.0. + +v6.2.4 +====== + +- Removed a debug message during mmap. + +v6.2.3 +====== + +- Fixed errors when using AccessMode.mmap. Thanks @zachgoulet. + +v6.2.2 +====== + +- Fixed noisy log message. +- Made some flakey tests less flakey. +- Fixed deprecated information in setup.cfg. Thanks @mgorny. + +v6.2.1 +====== + +- Rebuild binary wheels using zlib 1.2.13. Source build unchanged. + v6.2.0 ====== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/docs/topics/pages.rst new/pikepdf-6.2.7/docs/topics/pages.rst --- old/pikepdf-6.2.0/docs/topics/pages.rst 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/docs/topics/pages.rst 2022-12-31 10:35:00.000000000 +0100 @@ -170,7 +170,7 @@ Emplacing pages ~~~~~~~~~~~~~~~ -Perhaps the PDF you are working has a table of contents or internal hyperlinks, +Perhaps the PDF you are working with has a table of contents or internal hyperlinks, meaning that there are indirect references to a specific page object. If you want change the content of a page object while preserving references to it, use :meth:`pikepdf.Object.emplace`, which will delete all of the content of diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/pyproject.toml new/pikepdf-6.2.7/pyproject.toml --- old/pikepdf-6.2.0/pyproject.toml 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/pyproject.toml 2022-12-31 10:35:00.000000000 +0100 @@ -41,19 +41,18 @@ test-extras = "test" # cp36: ancient # pp39: no Pillow pp39 wheels yet - https://pypi.org/project/Pillow/#files -# cp311-manylinux*aarch64 - lxml wheels not released yet # Reminder: # build.yml sets CIBW_BUILD to select what can be built # this file sets skip to deselect what cannot be built -skip = ["cp36-*", "pp39-*", "*musllinux*", "pp*-manylinux*_aarch64", "cp311-manylinux*_aarch64"] +skip = ["cp36-*", "pp39-*", "*musllinux*", "pp*-manylinux*_aarch64"] test-skip = "*_arm64 *_universal2:arm64" [tool.cibuildwheel.environment] QPDF_MIN_VERSION = "11.1.0" -QPDF_VERSION = "11.1.1" +QPDF_VERSION = "11.2.0" QPDF_PATTERN = "https://github.com/qpdf/qpdf/releases/download/vVERSION/qpdf-VERSION.tar.gz" JPEG_RELEASE = "https://www.ijg.org/files/jpegsrc.v9e.tar.gz" -ZLIB_RELEASE = "https://www.zlib.net/zlib-1.2.12.tar.gz" +ZLIB_RELEASE = "https://www.zlib.net/zlib-1.2.13.tar.gz" [tool.cibuildwheel.linux] before-all = [ @@ -63,6 +62,7 @@ "bash build-scripts/linux-download-qpdf.bash $QPDF_VERSION", "bash build-scripts/linux-build-wheel-deps.bash" ] +environment-pass = ["CI"] manylinux-x86_64-image = "manylinux2014" manylinux-i686-image = "manylinux2014" manylinux-pypy_x86_64-image = "manylinux2014" @@ -86,13 +86,12 @@ before-all = ["brew update", "brew install qpdf little-cms2"] [tool.cibuildwheel.windows] -# pp3*-win32 fails because there is no wheel for lxml -# pp3*-win_amd64 does not execute because cibuildwheel does not implement it -# or PyPy3 doesn't work on Windows 64-bit, one or the other -# Check https://pypi.org/project/lxml/#files to see if lxml is providing pp-*win -# PyPy+Win32 seems like a very low priority combination -# cp311- is not ready because lxml does not provide cp311 yet -skip = ["cp36-*", "cp311-*", "pp3*"] +# pp*-win32: lxml does not build win32 for pp, so we can't support it +# pp37-*: lxml does not provide pp37-win_amd64, so we can't support it +# pp39-*: Pillow does not provide pp38-win_amd64, so we can't support it +# (For Windows only pp38 makes it through the gauntlet.) +# In the past lxml has been slow to release cp*-win32 +skip = ["cp36-*", "pp*-win32", "pp37-*", "pp39-*"] [tool.mypy] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/setup.cfg new/pikepdf-6.2.7/setup.cfg --- old/pikepdf-6.2.0/setup.cfg 2022-10-05 00:16:11.198186600 +0200 +++ new/pikepdf-6.2.7/setup.cfg 2022-12-31 10:37:17.617502500 +0100 @@ -7,7 +7,6 @@ author = James R. Barlow author_email = ja...@purplerock.ca license = MPL-2.0 -license_file = LICENSE.txt license_files = LICENSE.txt licenses-for-wheels.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/pikepdf/_qpdf.pyi new/pikepdf-6.2.7/src/pikepdf/_qpdf.pyi --- old/pikepdf-6.2.0/src/pikepdf/_qpdf.pyi 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/src/pikepdf/_qpdf.pyi 2022-12-31 10:35:00.000000000 +0100 @@ -744,8 +744,6 @@ def _new_real(arg0: str) -> Object: ... @overload def _new_real(value: float, places: int = ...) -> Object: ... -@overload -def _new_real(*args, **kwargs) -> Any: ... def _new_stream(arg0: Pdf, arg1: bytes) -> Stream: ... def _new_string(s: str | bytes) -> String: ... def _new_string_utf8(s: str) -> String: ... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/pikepdf/models/image.py new/pikepdf-6.2.7/src/pikepdf/models/image.py --- old/pikepdf-6.2.0/src/pikepdf/models/image.py 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/src/pikepdf/models/image.py 2022-12-31 10:35:00.000000000 +0100 @@ -482,14 +482,22 @@ # be saved as JPEGs, and are probably bugs. Some software in the # wild actually produces RGB JPEGs in PDFs (probably a bug). DEFAULT_CT_RGB = 1 - ct = self.filter_decodeparms[0][1].get('/ColorTransform', DEFAULT_CT_RGB) + ct = DEFAULT_CT_RGB + if self.filter_decodeparms[0][1] is not None: + ct = self.filter_decodeparms[0][1].get( + '/ColorTransform', DEFAULT_CT_RGB + ) return self.mode == 'RGB' and ct == DEFAULT_CT_RGB def normal_dct_cmyk() -> bool: # Normal DCTDecode CMYKs have /ColorTransform 0 and can be saved. # There is a YUVK colorspace but CMYK JPEGs don't generally use it DEFAULT_CT_CMYK = 0 - ct = self.filter_decodeparms[0][1].get('/ColorTransform', DEFAULT_CT_CMYK) + ct = DEFAULT_CT_CMYK + if self.filter_decodeparms[0][1] is not None: + ct = self.filter_decodeparms[0][1].get( + '/ColorTransform', DEFAULT_CT_CMYK + ) return self.mode == 'CMYK' and ct == DEFAULT_CT_CMYK data, filters = self._remove_simple_filters(self.obj, self.filters) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/pikepdf.egg-info/PKG-INFO new/pikepdf-6.2.7/src/pikepdf.egg-info/PKG-INFO --- old/pikepdf-6.2.0/src/pikepdf.egg-info/PKG-INFO 2022-10-05 00:16:11.000000000 +0200 +++ new/pikepdf-6.2.7/src/pikepdf.egg-info/PKG-INFO 2022-12-31 10:37:17.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pikepdf -Version: 6.2.0 +Version: 6.2.7 Summary: Read and write PDFs with Python, powered by qpdf Home-page: https://github.com/pikepdf/pikepdf Author: James R. Barlow diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/qpdf/mmap_inputsource-inl.h new/pikepdf-6.2.7/src/qpdf/mmap_inputsource-inl.h --- old/pikepdf-6.2.0/src/qpdf/mmap_inputsource-inl.h 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/src/qpdf/mmap_inputsource-inl.h 2022-12-31 10:35:00.000000000 +0100 @@ -17,13 +17,19 @@ #include <pybind11/pybind11.h> #include <pybind11/stl.h> +#include <signal.h> #include "pikepdf.h" #include "utils.h" // We could almost subclass BufferInputSource here, except that it expects Buffer // as an initialization parameter, we don't know what the buffer location is until // the mmap is set up. Instead, this class is an InputSource that has a -// BufferInputSource. +// BufferInputSource, which in turn wraps the memory mapped area. +// +// Since we delegate most work to the BufferInputSource, we need to preserve the state +// of InputSource::last_offset by copying it whenever may change. If the design of +// InputSource changes to introduce other state variables, we need to replicate the +// BufferInputSource's state. // GIL usage: // The GIL must be held while this class is constructed, by the constructor's caller, @@ -99,11 +105,17 @@ std::string const &getName() const override { return this->bis->getName(); } - qpdf_offset_t tell() override { return this->bis->tell(); } + qpdf_offset_t tell() override + { + auto result = this->bis->tell(); + this->last_offset = this->bis->getLastOffset(); + return result; + } void seek(qpdf_offset_t offset, int whence) override { this->bis->seek(offset, whence); + this->last_offset = this->bis->getLastOffset(); } // LCOV_EXCL_START @@ -111,19 +123,28 @@ { // qpdf never seems to use this but still requires this->bis->rewind(); + this->last_offset = this->bis->getLastOffset(); } // LCOV_EXCL_STOP size_t read(char *buffer, size_t length) override { - return this->bis->read(buffer, length); + auto result = this->bis->read(buffer, length); + this->last_offset = this->bis->getLastOffset(); + return result; } - void unreadCh(char ch) override { this->bis->unreadCh(ch); } + void unreadCh(char ch) override + { + this->bis->unreadCh(ch); + this->last_offset = this->bis->getLastOffset(); + } qpdf_offset_t findAndSkipNextEOL() override { - return this->bis->findAndSkipNextEOL(); + auto result = this->bis->findAndSkipNextEOL(); + this->last_offset = this->bis->getLastOffset(); + return result; } private: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/qpdf/pikepdf.cpp new/pikepdf-6.2.7/src/qpdf/pikepdf.cpp --- old/pikepdf-6.2.0/src/qpdf/pikepdf.cpp 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/src/qpdf/pikepdf.cpp 2022-12-31 10:35:00.000000000 +0100 @@ -16,6 +16,7 @@ #include <qpdf/QPDFSystemError.hh> #include <qpdf/QPDFUsage.hh> #include <qpdf/QUtil.hh> +#include <qpdf/QPDFLogger.hh> #include <qpdf/Pl_Flate.hh> #include <pybind11/stl.h> @@ -140,8 +141,14 @@ "_test_file_not_found", []() -> void { (void)QUtil::safe_fopen("does_not_exist__42", "rb"); }, "Used to test that C++ system error -> Python exception propagation works.") - .def("_translate_qpdf_logic_error", - [](std::string s) { return translate_qpdf_logic_error(s).first; }) + .def( + "_translate_qpdf_logic_error", + [](std::string s) { return translate_qpdf_logic_error(s).first; }, + "Used to test interpretation of QPDF errors.") + .def( + "_log_info", + [](std::string s) { return get_pikepdf_logger()->info(s); }, + "Used to test routing of QPDF's logger to Python logging.") .def( "set_decimal_precision", [](uint prec) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/src/qpdf/qpdf.cpp new/pikepdf-6.2.7/src/qpdf/qpdf.cpp --- old/pikepdf-6.2.0/src/qpdf/qpdf.cpp 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/src/qpdf/qpdf.cpp 2022-12-31 10:35:00.000000000 +0100 @@ -142,7 +142,6 @@ python_warning( "A password was provided, but no password was needed to open this PDF."); } - q->getLogger()->info("Opened a file"); return q; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/tests/test_codec.py new/pikepdf-6.2.7/tests/test_codec.py --- old/pikepdf-6.2.0/tests/test_codec.py 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/tests/test_codec.py 2022-12-31 10:35:00.000000000 +0100 @@ -95,30 +95,35 @@ @given(pdfdoc_text) +@example('\r\n') +@example('\r') +@example('\n') @settings(deadline=timedelta(seconds=4)) # CI workers can be flakey def test_open_encoding_pdfdoc_write(tmp_path_factory, s): folder = tmp_path_factory.mktemp('pdfdoc') txt = folder / 'pdfdoc.txt' - with open(txt, 'w', encoding='pdfdoc') as f: + with open(txt, 'w', encoding='pdfdoc', newline='') as f: try: f.write(s) except UnicodeEncodeError: return - assert txt.read_bytes().replace(b'\r\n', b'\n') == s.encode('pdfdoc') + assert txt.read_bytes() == s.encode('pdfdoc') @given(pdfdoc_text) @settings(deadline=timedelta(seconds=4)) # CI workers can be flakey +@example('\r\n') +@example('\r') +@example('\n') def test_open_encoding_pdfdoc_read(tmp_path_factory, s: str): - s = s.replace('\r', '\n') folder = tmp_path_factory.mktemp('pdfdoc') txt: Path = folder / 'pdfdoc.txt' - try: - txt.write_text(s, encoding='pdfdoc') - except UnicodeEncodeError: - return - - with open(txt, encoding='pdfdoc') as f: + with open(txt, 'w', encoding='pdfdoc', newline='') as f: + try: + f.write(s) + except UnicodeEncodeError: + return + with open(txt, encoding='pdfdoc', newline='') as f: result: str = f.read() assert result == s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/tests/test_io.py new/pikepdf-6.2.7/tests/test_io.py --- old/pikepdf-6.2.0/tests/test_io.py 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/tests/test_io.py 2022-12-31 10:35:00.000000000 +0100 @@ -4,10 +4,12 @@ from __future__ import annotations import logging +import os import os.path import sys from io import BytesIO, FileIO from shutil import copy +from time import sleep import psutil import pytest @@ -100,51 +102,79 @@ sandwich.save(bio, static_id=True) -@pytest.fixture -def file_descriptor_is_open_for(): +def _file_descriptor_is_open( + path, retry_until: bool, retries: int = 3, delay: float = 1.0 +): + process = psutil.Process() + for _ in range(retries): + is_open = any((f.path == str(path.resolve())) for f in process.open_files()) + if is_open == retry_until: + return is_open + sleep(delay) + + return is_open + + +def _skip_file_descriptor_checks_if_not_supported(): if sys.platform == 'win32' or sys.platform.startswith('freebsd'): pytest.skip( "psutil documentation warns that .open_files() has problems on these" ) - elif sys.implementation.name == 'pypy': - pytest.skip("randomly fails on pypy") + elif sys.implementation.name == 'pypy' or os.environ.get('CI', 'false') == 'true': + pytest.skip("fails randomly on CI, not worth it") + + +@pytest.fixture +def file_descriptor_is_open(): + _skip_file_descriptor_checks_if_not_supported() - def _file_descriptor_is_open_for(path): - process = psutil.Process() - return any((f.path == str(path.resolve())) for f in process.open_files()) + def _wait_till_open(path): + return _file_descriptor_is_open(path, retry_until=True) - return _file_descriptor_is_open_for + return _wait_till_open -def test_open_named_file_closed(resources, file_descriptor_is_open_for): +@pytest.fixture +def file_descriptor_is_closed(): + _skip_file_descriptor_checks_if_not_supported() + + def _wait_till_closed(path): + return not _file_descriptor_is_open(path, retry_until=False) + + return _wait_till_closed + + +def test_open_named_file_closed( + resources, file_descriptor_is_open, file_descriptor_is_closed +): path = resources / 'pal.pdf' pdf = Pdf.open(path) # no with clause - assert file_descriptor_is_open_for(path) + assert file_descriptor_is_open(path) pdf.close() - assert not file_descriptor_is_open_for( - path - ), "pikepdf did not close a stream it opened" + assert file_descriptor_is_closed(path), "pikepdf did not close a stream it opened" -def test_streamed_file_not_closed(resources, file_descriptor_is_open_for): +def test_streamed_file_not_closed(resources, file_descriptor_is_open): path = resources / 'pal.pdf' stream = path.open('rb') pdf = Pdf.open(stream) # no with clause - assert file_descriptor_is_open_for(path) + assert file_descriptor_is_open(path) pdf.close() - assert file_descriptor_is_open_for(path), "pikepdf closed a stream it did not open" + assert file_descriptor_is_open(path), "pikepdf closed a stream it did not open" @pytest.mark.parametrize('branch', ['success', 'failure']) -def test_save_named_file_closed(resources, outdir, file_descriptor_is_open_for, branch): +def test_save_named_file_closed( + resources, outdir, file_descriptor_is_open, file_descriptor_is_closed, branch +): with Pdf.open(resources / 'pal.pdf') as pdf: path = outdir / "pal.pdf" def confirm_opened(progress_percent): if progress_percent == 0: - assert file_descriptor_is_open_for(path) + assert file_descriptor_is_open(path) if progress_percent > 0 and branch == 'failure': raise ValueError('failure branch') @@ -152,24 +182,22 @@ pdf.save(path, progress=confirm_opened) except ValueError: pass - assert not file_descriptor_is_open_for( + assert file_descriptor_is_closed( path ), "pikepdf did not close a stream it opened" -def test_save_streamed_file_not_closed(resources, outdir, file_descriptor_is_open_for): +def test_save_streamed_file_not_closed(resources, outdir, file_descriptor_is_open): with Pdf.open(resources / 'pal.pdf') as pdf: path = outdir / "pal.pdf" stream = path.open('wb') def confirm_opened(progress_percent): if progress_percent == 0: - assert file_descriptor_is_open_for(path) + assert file_descriptor_is_open(path) pdf.save(stream, progress=confirm_opened) - assert file_descriptor_is_open_for( - path - ), "pikepdf closed a stream it did not open" + assert file_descriptor_is_open(path), "pikepdf closed a stream it did not open" class ExpectedError(Exception): @@ -266,10 +294,9 @@ contents.read_raw_bytes() -def test_logging(caplog, resources): +def test_logging(caplog): caplog.set_level(logging.INFO) - with Pdf.open(resources / 'pal.pdf'): - pass + pikepdf._qpdf._log_info("test log message") assert [("pikepdf._qpdf", logging.INFO)] == [ (rec[0], rec[1]) for rec in caplog.record_tuples ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pikepdf-6.2.0/tests/test_pdf.py new/pikepdf-6.2.7/tests/test_pdf.py --- old/pikepdf-6.2.0/tests/test_pdf.py 2022-10-05 00:13:09.000000000 +0200 +++ new/pikepdf-6.2.7/tests/test_pdf.py 2022-12-31 10:35:00.000000000 +0100 @@ -30,7 +30,7 @@ @pytest.fixture def trivial(resources): with Pdf.open( - resources / 'pal-1bit-trivial.pdf' # , access_mode=pikepdf.AccessMode.mmap + resources / 'pal-1bit-trivial.pdf', access_mode=pikepdf.AccessMode.mmap ) as pdf: yield pdf