Package: release.debian.org
Severity: normal
Tags: bookworm
User: release.debian....@packages.debian.org
Usertags: pu
X-Debbugs-Cc: bepa...@packages.debian.org
Control: affects -1 + src:bepasty

[ Reason ]
The upload is necessary to fix bug #1038452 (
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1038452 ) in bepasty,
a pastebin with support for multiple media types: because of an
incompatibility with Pygments-2.12.0 that I didn't spot during the
testing cycle (my fault) bepasty in bookworm is no longer able to
display the rendered version of text uploads.

[ Impact ]
If the update isn't approved the version of bepasty in Debian won't work
for one of the most common use cases (text uploads)

[ Tests ]
Automated tests of the package have been disabled because I wasn't able
to make them work in the package building infrastructure. I plan to work
on this during the trixie cycle.
I'm currently testing this manually by installing locally and trying to
use it.
The package I'm proposing for bookworm-updates has also been installed
on my main instance and being in use for a day (as I write this), and
giving it a bit of heavier than usual use.

[ Risks ]
I believe that the fix is a pretty small change in a part of code with
no special complexities.
However the alternative could be to remove bepasty from stable, and
users could install the updated version that I plan to maintain in
backports.

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
The backported upstream patch changes the class CustomHtmlFormatter from
bepasty to work with the changed HtmlFormatter from pygments.
The only other packaging change is to add a versioned dependency to
python3-pygments (>= 2.12.0) (bookworm has 2.14.0+dfsg-1), as that's the
release that introduced the breaking change.

[ Other info ]
The issue is fixed in unstable by uploading the new upstream release
from which this patch comes from.

I will work to improve my testing to avoid something like this from
happening again, sorry.
diff -Nru bepasty-1.0.0/debian/changelog bepasty-1.0.0/debian/changelog
--- bepasty-1.0.0/debian/changelog      2021-12-17 09:35:28.000000000 +0100
+++ bepasty-1.0.0/debian/changelog      2023-06-28 13:57:40.000000000 +0200
@@ -1,3 +1,9 @@
+bepasty (1.0.0-1+deb12u1) bookworm; urgency=medium
+
+  * Backport upstream fix for Pygments-2.12.0. (Closes: #1038452)
+
+ -- Elena Grandi <valha...@debian.org>  Wed, 28 Jun 2023 13:57:40 +0200
+
 bepasty (1.0.0-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru bepasty-1.0.0/debian/control bepasty-1.0.0/debian/control
--- bepasty-1.0.0/debian/control        2021-12-17 09:35:28.000000000 +0100
+++ bepasty-1.0.0/debian/control        2023-06-28 13:57:40.000000000 +0200
@@ -9,7 +9,7 @@
  python3-setuptools,
  python3-setuptools-scm,
  python3-flask,
- python3-pygments,
+ python3-pygments (>= 2.12.0),
  python3-pytest,
  python3-selenium,
  python3-sphinx,
@@ -33,7 +33,7 @@
  libjs-jquery-ui,
  libjs-jquery-file-upload,
  python3-flask,
- python3-pygments,
+ python3-pygments (>= 2.12.0),
 Recommends: ${python3:Recommends}
 Suggests: ${python3:Suggests}
 Description: binary pastebin / file upload service
diff -Nru 
bepasty-1.0.0/debian/patches/0004-adapt-to-Pygments-2.12.0-and-also-require-it-fixes-2.patch
 
bepasty-1.0.0/debian/patches/0004-adapt-to-Pygments-2.12.0-and-also-require-it-fixes-2.patch
--- 
bepasty-1.0.0/debian/patches/0004-adapt-to-Pygments-2.12.0-and-also-require-it-fixes-2.patch
        1970-01-01 01:00:00.000000000 +0100
+++ 
bepasty-1.0.0/debian/patches/0004-adapt-to-Pygments-2.12.0-and-also-require-it-fixes-2.patch
        2023-06-28 13:57:40.000000000 +0200
@@ -0,0 +1,67 @@
+From: Thomas Waldmann <t...@waldmann-edv.de>
+Date: Sat, 21 Jan 2023 18:48:50 +0100
+Bug: #1038452
+Subject: [PATCH] adapt to Pygments>=2.12.0 (and also require it), fixes #281
+Origin: backport, 
https://github.com/bepasty/bepasty-server/commit/6ab4201e28133476aeac9d80be2e703ca4a4b203
+
+pygments made some incompatible change in 2.12 and bepasty
+was affected by that because we subclassed pygment's
+HtmlFormatter.
+
+i updated our copy of format_unencoded from the HtmlFormatter
+base class and added our customization back to that (calling
+_wrap_lineparagraphs() when needed).
+---
+
+diff --git a/src/bepasty/utils/formatters.py b/src/bepasty/utils/formatters.py
+index d3a8931..6992336 100644
+--- a/src/bepasty/utils/formatters.py
++++ b/src/bepasty/utils/formatters.py
+@@ -23,26 +23,42 @@ class CustomHtmlFormatter(HtmlFormatter):
+                 yield 0, line
+ 
+     def format_unencoded(self, tokensource, outfile):
+-        """Format by wrapping pieces of text according to the user's options
++        """
++        The formatting process uses several nested generators; which of
++        them are used is determined by the user's options.
++
++        Each generator should take at least one argument, ``inner``,
++        and wrap the pieces of text generated by this.
+ 
+-        :param tokensource: iterator of tuples of format (code, text)
+-        :param outfile: output file handler
++        Always yield 2-tuples: (code, text). If "code" is 1, the text
++        is part of the original tokensource being highlighted, if it's
++        0, the text is some piece of wrapping. This makes it possible to
++        use several different wrappers that process the original source
++        linewise, e.g. line number generators.
+         """
+         source = self._format_lines(tokensource)
++
++        # As a special case, we wrap line numbers before line highlighting
++        # so the line numbers get wrapped in the highlighting tag.
++        if not self.nowrap and self.linenos == 2:
++            source = self._wrap_inlinelinenos(source)
++
+         if self.hl_lines:
+             source = self._highlight_lines(source)
++
+         if not self.nowrap:
+-            if self.linenos == 2:
+-                source = self._wrap_inlinelinenos(source)
+             if self.lineanchors:
+                 source = self._wrap_lineanchors(source)
+             if self.linespans:
+                 source = self._wrap_linespans(source)
++            # vvv customization of bepasty start:
+             if self.lineparagraphs:
+                 source = self._wrap_lineparagraphs(source)
+-            source = self.wrap(source, outfile)
++            # ^^^ customization of bepasty end.
++            source = self.wrap(source)
+             if self.linenos == 1:
+                 source = self._wrap_tablelinenos(source)
++            source = self._wrap_div(source)
+             if self.full:
+                 source = self._wrap_full(source, outfile)
diff -Nru bepasty-1.0.0/debian/patches/series 
bepasty-1.0.0/debian/patches/series
--- bepasty-1.0.0/debian/patches/series 2021-12-17 09:35:28.000000000 +0100
+++ bepasty-1.0.0/debian/patches/series 2023-06-28 13:57:40.000000000 +0200
@@ -1,3 +1,4 @@
 0001-Use-packaged-js-and-css-instead-of-xstatic-ones.patch
 0002-Use-locally-installed-font-awesome.patch
 0003-Correct-for-different-file-paths-in-the-debian-insta.patch
+0004-adapt-to-Pygments-2.12.0-and-also-require-it-fixes-2.patch

Reply via email to