nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: psd-tools/psd-tools
Pull request #161 (2019-11-28 07:53:27)

v1.8.32


Patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index b2b571c..ffd6674 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,3 +1,8 @@
+1.8.32 (2019-11-28)
+-------------------
+
+- [psd] fix 16/32 bit file parsing bug introduced in 1.8.17.
+
 1.8.31 (2019-11-27)
 -------------------
 
diff --git a/src/psd_tools/psd/__init__.py b/src/psd_tools/psd/__init__.py
index 52b77af..bdbdda1 100644
--- a/src/psd_tools/psd/__init__.py
+++ b/src/psd_tools/psd/__init__.py
@@ -97,9 +97,10 @@ class PSD(BaseElement):
                     yield record, channels
 
     def _get_layer_info(self):
+        from psd_tools.constants import Tag
         tagged_blocks = self.layer_and_mask_information.tagged_blocks
         if tagged_blocks is not None:
-            for key in ('LAYER_16', 'LAYER_32'):
+            for key in (Tag.LAYER_16, Tag.LAYER_32):
                 if key in tagged_blocks:
                     return tagged_blocks.get_data(key)
         return self.layer_and_mask_information.layer_info
diff --git a/src/psd_tools/version.py b/src/psd_tools/version.py
index 662671a..8913e8a 100644
--- a/src/psd_tools/version.py
+++ b/src/psd_tools/version.py
@@ -1,1 +1,1 @@
-__version__ = '1.8.31'
+__version__ = '1.8.32'


Test patch:
diff --git a/tests/psd_tools/psd/test_psd.py b/tests/psd_tools/psd/test_psd.py
index 861fe89..ad5b042 100644
--- a/tests/psd_tools/psd/test_psd.py
+++ b/tests/psd_tools/psd/test_psd.py
@@ -5,7 +5,7 @@ import io
 import os
 from psd_tools.psd import PSD
 
-from ..utils import full_name, all_files, check_write_read, check_read_write
+from ..utils import full_name, all_files, check_write_read, check_read_write, TEST_ROOT
 
 try:
     from IPython.lib.pretty import pprint
@@ -61,3 +61,14 @@ def test_psd_write_read(filename):
 def test_psd_from_error():
     with pytest.raises(AssertionError):
         PSD.frombytes(b'\x00\x00\x00\x00')
+
+
+@pytest.mark.parametrize(['filename', 'length'], [
+    ('colormodes/4x4_8bit_rgb.psd', 2),
+    ('colormodes/4x4_16bit_rgb.psd', 2),
+    ('colormodes/4x4_32bit_rgb.psd', 2),
+])
+def test_psd__iter_layers(filename, length):
+    with open(os.path.join(TEST_ROOT, 'psd_files', filename), 'rb') as f:
+        psd = PSD.read(f)
+    assert len(list(psd._iter_layers())) == length
Repository: psd-tools/psd-tools
Pull request #438 (2024-10-08 23:45:42)

Artboard lacking the bounding record/channels fix.
Fix for issue https://github.com/psd-tools/psd-tools/issues/437.

The artboard _move function will set the _bounding_records, _bounding_channels.


Patch:
diff --git a/src/psd_tools/api/layers.py b/src/psd_tools/api/layers.py
index 72fdff8..c7e92bd 100644
--- a/src/psd_tools/api/layers.py
+++ b/src/psd_tools/api/layers.py
@@ -1041,6 +1041,7 @@ class Artboard(Group):
     def _move(kls, group):
         self = kls(group._psd, group._record, group._channels, group._parent)
         self._layers = group._layers
+        self._set_bounding_records(group._bounding_record, group._bounding_channels)
         for layer in self._layers:
             layer._parent = self
         for index in range(len(self.parent)):


Test patch:
diff --git a/tests/psd_tools/api/test_layers.py b/tests/psd_tools/api/test_layers.py
index 7ac2b18..b4bd49f 100644
--- a/tests/psd_tools/api/test_layers.py
+++ b/tests/psd_tools/api/test_layers.py
@@ -4,7 +4,7 @@ import logging
 
 import pytest
 
-from psd_tools.api.layers import Group, PixelLayer, ShapeLayer
+from psd_tools.api.layers import Group, PixelLayer, ShapeLayer, Artboard
 from psd_tools.api.psd_image import PSDImage
 from psd_tools.constants import BlendMode, Tag, SectionDivider
 
@@ -527,4 +527,13 @@ def test_count(group, pixel_layer, type_layer, smartobject_layer, fill_layer):
     group.append(pixel_layer)
     group.append(pixel_layer)
 
-    assert group.count(pixel_layer) == 3
\ No newline at end of file
+    assert group.count(pixel_layer) == 3
+
+def test_artboard_move(group):
+
+    artboard = Artboard._move(group)
+
+    assert artboard._channels is group._channels
+    assert artboard._record is group._record
+    assert artboard._bounding_channels is group._bounding_channels
+    assert artboard._bounding_record is group._bounding_record
\ No newline at end of file