Summary
With --original, a pre-existing error on one slide suppresses an identical newly introduced error on another slide. The command exits successfully and prints "All validations PASSED!" for the edited presentation.
Tested at dbd4588f9e1033efb41dad4bef2f7947c8993d44 on Python 3.12.14, python-pptx 1.0.2, lxml 6.1.3 and defusedxml 0.7.1.
Reproduction
Run from the repository root:
from pptx import Presentation
from pptx.util import Inches
from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
from pathlib import Path
import zipfile, tempfile, subprocess, sys
repo = Path.cwd()
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
deck = Presentation()
for _ in range(2):
slide = deck.slides.add_slide(deck.slide_layouts[6])
shape = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE,
Inches(1), Inches(1), Inches(2), Inches(1))
shape.fill.solid()
shape.fill.fore_color.rgb = RGBColor(0x12, 0x34, 0x56)
good = root / "good.pptx"
deck.save(good)
with zipfile.ZipFile(good) as z:
parts = {n: z.read(n) for n in z.namelist()}
for filename, bad_slides in [("original.pptx", {1}), ("edited.pptx", {1, 2})]:
with zipfile.ZipFile(root / filename, "w") as z:
for n, data in parts.items():
if n in {f"ppt/slides/slide{i}.xml" for i in bad_slides}:
data = data.replace(b'<a:srgbClr val="123456"/>',
b'<a:srgbClr val="NOTHEX"/>')
z.writestr(n, data)
result = subprocess.run([sys.executable, "-X", "utf8",
str(repo / "skills/pptx/scripts/office/validate.py"),
str(root / "edited.pptx"), "--original", str(root / "original.pptx")])
print("exit:", result.returncode)Actual / expected
Actual: exit 0, "All validations PASSED!". The slide validator without the original reports invalid colors; with the original it returns True. The full validator also returns True.
Expected: allow the inherited slide1 defect, but fail the newly introduced slide2 defect.
Cause and suggested correction
_original_slide_defects and validate_slides aggregate fatal error messages into a presentation-wide set, then skip matching messages on any edited slide. This loses part identity and occurrence counts.
Compare baseline defects by part and stable element/error identity, preserving counts so new occurrences fail. Add a regression covering an inherited slide1 error plus the same new slide2 error. Identical validator copies exist under the docx/xlsx office directories.
Scope
This demonstrates a validator false negative in the documented template-editing workflow. Native PowerPoint rendering was not tested; no crash or code-execution claim is made. Targeted public issue/PR review found no matching report; the chart-axis changes in #1918 do not address this baseline comparison.
Activity
0No activity yet.