internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: plone/Products.CMFPlone

Issue:
Broken alias for getAllowedSizes
PR #3615 introduced some broken aliases after some helpers were moved:
```console
ale@avo:~/Code/plone/projects/coredev/6.0$ ./bin/zopepy 
>>> from Products.CMFPlone.utils import getAllowedSizes
<console>:1: DeprecationWarning: getAllowedSizes is deprecated. Import from plone.namedfile.utils instead (will be removed in Plone 7)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ale/.buildout/eggs/cp310/zope.deferredimport-4.4-py3.10.egg/zope/deferredimport/deferredmodule.py", line 71, in __getattr__
    v = get.get()
  File "/home/ale/.buildout/eggs/cp310/zope.deferredimport-4.4-py3.10.egg/zope/deferredimport/deferredmodule.py", line 55, in get
    return super(DeferredAndDeprecated, self).get()
  File "/home/ale/.buildout/eggs/cp310/zope.deferredimport-4.4-py3.10.egg/zope/deferredimport/deferredmodule.py", line 37, in get
    v = __import__(module, *self._import_chicken)
ModuleNotFoundError: No module named 'plone.namedfile.utils.getAllowedSizes'
```



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/utils.py b/Products/CMFPlone/utils.py
--- a/Products/CMFPlone/utils.py
+++ b/Products/CMFPlone/utils.py
@@ -79,9 +79,9 @@
 
 deprecated_import(
     "Import from plone.namedfile.utils instead (will be removed in Plone 7)",
-    getHighPixelDensityScales="plone.namedfile.utils.getHighPixelDensityScales",
-    getAllowedSizes="plone.namedfile.utils.getAllowedSizes",
-    getQuality="plone.namedfile.utils.getQuality",
+    getHighPixelDensityScales="plone.namedfile.utils:getHighPixelDensityScales",
+    getAllowedSizes="plone.namedfile.utils:getAllowedSizes",
+    getQuality="plone.namedfile.utils:getQuality",
 )
 
 @deprecate("Use plone.base.utils.safe_bytes instead (will be removed in Plone 7)")


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Update package metadata in PyPi



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -32,6 +32,19 @@
     author_email='releasemanager@plone.org',
     url='https://plone.org',
     license='GPL version 2',
+    project_urls={
+        "Homepage": "https://plone.org",
+        "Documentation": "https://docs.plone.org",
+        "PyPI": "https://pypi.python.org/pypi/Products.CMFPlone",
+        "Source": "https://github.com/plone/Products.CMFPlone",
+        "Issues": "https://github.com/plone/plone.org/Products.CMFPlone",
+        "Forum": "https://community.plone.org/",
+        "Chat": "https://discord.gg/zFY3EBbjaj",
+        "Mastodon": "https://plone.social/@plone",
+        "Twitter": "https://twitter.com/plone",
+        "Videos": "https://youtube.com/@plonecms",
+        "Sponsor": "https://github.com/sponsors/plone",
+    },
     packages=find_packages(),
     namespace_packages=['Products'],
     include_package_data=True,


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Assigning group members: memberlist batch navigation is broken.
## groupmembers listing batch and `showAll` link is broken

### What I did:

Assign members to a group:

- click on "show all" in the user filter.
- if you have lots of users the list is batched
- click on the next batch page

### What I expect to happen:

the next user batch list is shown

### What actually happened:

the user list is empty

### What version of Plone/ Addons I am using:

Plone 6.0.2


### Additional

The "toggle all" checkboxes do not work. This can be solved with `pat-checklist` ...


Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py b/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
--- a/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
+++ b/Products/CMFPlone/controlpanel/browser/usergroups_groupmembership.py
@@ -57,14 +57,21 @@ def update(self):
             search = form.get('form.button.Search', None) is not None
             edit = form.get('form.button.Edit', None) is not None and toDelete
             add = form.get('form.button.Add', None) is not None and toAdd
-            findAll = form.get('form.button.FindAll', None) is not None and \
-                not self.many_users
+            isBatched = form.get("b_start", None) is not None
+            findAll = (
+                form.get('form.button.FindAll', None) is not None
+                and not self.many_users
+            )
+            unbatchedAll = (
+                form.get("showAll", "") == "y"
+                and not self.many_users
+            )
             # The search string should be cleared when one of the
             # non-search buttons has been clicked.
-            if findAll or edit or add:
+            if findAll or unbatchedAll or edit or add:
                 form['searchstring'] = ''
             self.searchString = form.get('searchstring', '')
-            if findAll or bool(self.searchString):
+            if findAll or isBatched or unbatchedAll or bool(self.searchString):
                 self.searchResults = self.getPotentialMembers(
                     self.searchString)
 


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Plone site id is a reserved id and can't be used any where in Zope as an short name 
## BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

### What I did:

Add a Plone site with the id example.
Add another Plone side with any other name.
In the second Plone side, try to create a Document with the title example.

You'll get a trace:

```
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 390, in publish_module
  Module ZPublisher.WSGIPublisher, line 285, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module plone.z3cform.layout, line 61, in __call__
  Module plone.z3cform.layout, line 45, in update
  Module plone.dexterity.browser.add, line 136, in update
  Module plone.z3cform.fieldsets.extensible, line 62, in update
  Module plone.z3cform.patch, line 31, in GroupForm_update
  Module z3c.form.group, line 145, in update
  Module plone.app.z3cform.csrf, line 21, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 301, in __call__
  Module z3c.form.button, line 159, in __call__
  Module plone.dexterity.browser.add, line 114, in handleAdd
  Module z3c.form.form, line 265, in createAndAdd
  Module plone.dexterity.browser.add, line 89, in add
  Module plone.dexterity.utils, line 174, in addContentToContainer
  Module Products.BTreeFolder2.BTreeFolder2, line 434, in _setObject
  Module plone.folder.ordered, line 253, in _checkId
  Module Products.CMFCore.PortalFolder, line 318, in _checkId
  Module OFS.ObjectManager, line 130, in checkValidId
zExceptions.BadRequest: The id "example" is reserved.
```

### What I expect to happen:

Having a page with the id example.

### What actually happened:

Got the trace above.
A Plone site id should not be blocked to be used in other places for object id's.

### What version of Plone/ Addons I am using:

Plone 6.0.6


Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/Portal.py b/Products/CMFPlone/Portal.py
--- a/Products/CMFPlone/Portal.py
+++ b/Products/CMFPlone/Portal.py
@@ -29,7 +29,6 @@
 from Products.CMFCore.Skinnable import SkinnableObjectManager
 from Products.CMFCore.utils import _checkPermission
 from Products.CMFCore.utils import getToolByName
-from Products.CMFCore.utils import UniqueObject
 from Products.CMFPlone import bbb
 from Products.Five.component.interfaces import IObjectManagerSite
 from zope.event import notify
@@ -45,7 +44,7 @@
 
 
 @implementer(IPloneSiteRoot, ISiteRoot, ISyndicatable, IObjectManagerSite)
-class PloneSite(Container, SkinnableObjectManager, UniqueObject):
+class PloneSite(Container, SkinnableObjectManager):
     """The Plone site object."""
 
     security = ClassSecurityInfo()


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Un-remove IContentish from site root class
On https://github.com/plone/Products.CMFPlone/blob/016459fd9d023017e9dc0a0b635bd66099826db1/Products/CMFPlone/Portal.py#L214 I remove IContentish, because having it broke tests and setup code in places that I didn't feel like touching.

Nowadays we have some test failures because of the removal. See https://github.com/plone/plone.restapi/pull/1674#issuecomment-1664193927 for additional details, but suffice to say that `conversation_view` is expected to exist on the site root, but isn't because it's bound to `IContentish`.


Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/Portal.py b/Products/CMFPlone/Portal.py
--- a/Products/CMFPlone/Portal.py
+++ b/Products/CMFPlone/Portal.py
@@ -15,7 +15,6 @@
 from plone.base.permissions import View
 from plone.dexterity.content import Container
 from Products.CMFCore import permissions
-from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.interfaces import ISiteRoot
 from Products.CMFCore.permissions import AccessContentsInformation
 from Products.CMFCore.permissions import AddPortalMember
@@ -32,8 +31,6 @@
 from Products.CMFPlone import bbb
 from Products.Five.component.interfaces import IObjectManagerSite
 from zope.event import notify
-from zope.interface import classImplementsOnly
-from zope.interface import implementedBy
 from zope.interface import implementer
 from zope.interface.interfaces import ComponentLookupError
 from zope.traversing.interfaces import BeforeTraverseEvent
@@ -222,8 +219,4 @@ def isEffective(self, date):
         return 1
 
 
-# Remove the IContentish interface so we don't listen to events that won't
-# apply to the site root, ie handleUidAnnotationEvent
-classImplementsOnly(PloneSite, implementedBy(PloneSite) - IContentish)
-
 InitializeClass(PloneSite)


Test patch:
Repository: plone/Products.CMFPlone

Issue:
Catalog search does not handle correctly parenthesis inside quotes
## BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

### What I did:

- Add a page with parenthesis enclosed text as a title
- Try to search that page using quoted query

### What I expect to happen:

- The search searches the page

### What actually happened:

- The search does not find the page
- When accessing through REST API (because plone.app.querystring uses the `munge_search_term` function here), we get an error because the query is transformed to an unknown string for ZCatalog

### What version of Plone/ Addons I am using:

- Plone 6



Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/browser/search.py b/Products/CMFPlone/browser/search.py
--- a/Products/CMFPlone/browser/search.py
+++ b/Products/CMFPlone/browser/search.py
@@ -45,10 +45,11 @@ def quote(term):
     # being parsed as logical query atoms.
     if term.lower() in ("and", "or", "not"):
         term = '"%s"' % term
-    return term
+    return quote_chars(term)
 
 
 def munge_search_term(query):
+    original_query = query
     for char in BAD_CHARS:
         query = query.replace(char, " ")
 
@@ -67,7 +68,7 @@ def munge_search_term(query):
 
     r += map(quote, query.strip().split())
     r = " AND ".join(r)
-    r = quote_chars(r) + ("*" if r and not r.endswith('"') else "")
+    r = r + ("*" if r and not original_query.endswith('"') else "")
     return r
 
 


Test patch:
diff --git a/Products/CMFPlone/tests/testSearch.py b/Products/CMFPlone/tests/testSearch.py
--- a/Products/CMFPlone/tests/testSearch.py
+++ b/Products/CMFPlone/tests/testSearch.py
@@ -364,6 +364,21 @@ def test_munge_search_term(self):
                 '" spam ham   "',
                 '"spam ham"',
             ),
+            (
+                # quoted term with inner parenthesis
+                '"spam (ham)"',
+                '"spam (ham)"',
+            ),
+            (
+                # quoted term with inner parenthesis
+                '"spam" (ham)',
+                '"spam" AND "("ham")"*',
+            ),
+            (
+                # quoted term with inner parenthesis
+                '"(spam ham)"',
+                '"(spam ham)"',
+            ),
             (
                 # mixed cases
                 "Spam hAm",
Repository: plone/Products.CMFPlone

Issue:
CMFPlone must not depend on plone.api
Dependency in setup.py, used in 

https://github.com/plone/Products.CMFPlone/blob/5f866f56d979ca0879181823a1a802035f727079/Products/CMFPlone/controlpanel/browser/error_log_form.py#L6

plone.api depends on CMFPlone, not vice versa!


Discussion:

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/error_log_form.py b/Products/CMFPlone/controlpanel/browser/error_log_form.py
--- a/Products/CMFPlone/controlpanel/browser/error_log_form.py
+++ b/Products/CMFPlone/controlpanel/browser/error_log_form.py
@@ -1,14 +1,14 @@
 from DateTime import DateTime
 from plone.base import PloneMessageFactory as _
+from Products.CMFCore.utils import getToolByName
 from Products.CMFPlone.utils import safe_nativestring
 from Products.Five import BrowserView
 
-import plone.api as api
-
 
 class ErrorLogUpdate(BrowserView):
     def __call__(self):
-        member = api.user.get_current()
+        portal_membership = getToolByName(self.context, "portal_membership")
+        member = portal_membership.getAuthenticatedMember()
 
         if getattr(self.request, "form.button.search", None) is not None:
             search = self.request.form.get("search_entry")
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -53,7 +53,6 @@
         "borg.localrole",
         "five.customerize",
         "lxml",
-        "plone.api >= 1.4.4",
         "plone.app.content",
         "plone.app.contentlisting",
         "plone.app.contentmenu >= 2.0.1",


Test patch:
Repository: plone/Products.CMFPlone

Issue:
TypeError thrown when during groups lookup
The offending code is [here](https://github.com/plone/Products.CMFPlone/blob/308aa4d03ee6c0ce9d8119ce4c37955153f0bc6f/Products/CMFPlone/controlpanel/browser/usergroups_usermembership.py#L66). The traceback looks like this:
```
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 176, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 385, in publish_module
  Module ZPublisher.WSGIPublisher, line 280, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 57, in __call__
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 54, in update
  Module Products.CMFPlone.controlpanel.browser.usergroups_usermembership, line 63, in getGroups
TypeError: '<' not supported between instances of 'bool' and 'str'
```

The issue is that when there's a `None` value in the `groupResults` (which is anticipated in the sort code) the lambda returns `False` which fails to compare against the group title/name strings under Python 3. The list comprehension that defines `groupResults` should probably just filter out `None` values to avoid this issue. I'm not entirely sure what circumstances result in a `None` group value, but I am seeing it occur in a real world use case.


Discussion:
FWIW we fixed a similar bug in plone.restapi recently: https://github.com/plone/plone.restapi/pull/1775

I think it can happen if a group is enumerated by a PAS plugin but it can't actually be fetched by id for some reason.

In your case maybe there is something wrong with what the dexterity.membrane PAS plugins are returning?

Resolving patch:
diff --git a/Products/CMFPlone/controlpanel/browser/usergroups_usermembership.py b/Products/CMFPlone/controlpanel/browser/usergroups_usermembership.py
--- a/Products/CMFPlone/controlpanel/browser/usergroups_usermembership.py
+++ b/Products/CMFPlone/controlpanel/browser/usergroups_usermembership.py
@@ -63,7 +63,7 @@ def getGroups(self):
             for m in self.gtool.getGroupsForPrincipal(self.member)
         ]
         groupResults.sort(
-            key=lambda x: x is not None and normalizeString(x.getGroupTitleOrName())
+            key=lambda x: normalizeString(x.getGroupTitleOrName()) if x else ''
         )
         return [i for i in groupResults if i]
 


Test patch:
Repository: pystiche/pystiche

Issue:
propagate_guide() of Encoder raises a TypeError
When running the replication of [Gatys et al. 2017](https://github.com/pmeier/pystiche/blob/3260b68ea8dd88de433777ad3750d7abe3894743/replication/gatys_et_al_2017.py#L254), the following error is raised:

```
TypeError: Unions cannot be used with isinstance().
```

This points towards the [Encoder](https://github.com/pmeier/pystiche/blob/3260b68ea8dd88de433777ad3750d7abe3894743/pystiche/encoding/encoder.py#L12), specifically these `if` statements in the `propagate_guide()` method:

https://github.com/pmeier/pystiche/blob/3260b68ea8dd88de433777ad3750d7abe3894743/pystiche/encoding/encoder.py#L50-L53

`PoolModule` and `ConvModule` are defined in `pystiche.typing`:

https://github.com/pmeier/pystiche/blob/3260b68ea8dd88de433777ad3750d7abe3894743/pystiche/typing.py#L18-L23



Discussion:

Resolving patch:
diff --git a/pystiche/typing.py b/pystiche/typing.py
--- a/pystiche/typing.py
+++ b/pystiche/typing.py
@@ -1,4 +1,4 @@
-from typing import Union, Sequence
+from typing import Union, Any, Sequence
 import torch
 from torch import nn
 
@@ -6,8 +6,10 @@
     "Numeric",
     "TensorMeta",
     "ConvModule",
+    "is_conv_module",
     "ConvModuleMeta",
     "PoolModule",
+    "is_pool_module",
     "PoolModuleMeta",
 ]
 
@@ -15,10 +17,32 @@
 
 TensorMeta = Union[torch.device, torch.dtype]
 
-ConvModule = Union[nn.Conv1d, nn.Conv2d, nn.Conv2d]
+ConvModule = Union[nn.Conv1d, nn.Conv2d, nn.Conv3d]
+
+
+def is_conv_module(x: Any) -> bool:
+    return isinstance(x, (nn.Conv1d, nn.Conv2d, nn.Conv3d))
+
+
 ConvModuleMeta = Union[int, Sequence[int]]
 
 PoolModule = Union[
     nn.AvgPool1d, nn.AvgPool2d, nn.AvgPool3d, nn.MaxPool1d, nn.MaxPool2d, nn.MaxPool3d
 ]
+
+
+def is_pool_module(x: Any) -> bool:
+    return isinstance(
+        x,
+        (
+            nn.AvgPool1d,
+            nn.AvgPool2d,
+            nn.AvgPool3d,
+            nn.MaxPool1d,
+            nn.MaxPool2d,
+            nn.MaxPool3d,
+        ),
+    )
+
+
 PoolModuleMeta = Union[int, Sequence[int]]


Test patch:
Repository: pystiche/pystiche

Issue:
Pyramid fails with GuidedPixelRegularization operators
Right now the pyramid only extract the initial states from `Comparison` operators:

https://github.com/pmeier/pystiche/blob/d962951471d32124c9f164f1ba74dcdf50ecb938/pystiche/nst/image_optimizer/pyramid.py#L116-L117

If used with a `GuidedPixelRegularization` operator, this would fail to extract the input guide.


Discussion:

Resolving patch:
diff --git a/pystiche/nst/image_optimizer/pyramid.py b/pystiche/nst/image_optimizer/pyramid.py
--- a/pystiche/nst/image_optimizer/pyramid.py
+++ b/pystiche/nst/image_optimizer/pyramid.py
@@ -107,26 +107,31 @@ def max_level_guide_transform(self) -> Callable:
     def __call__(self, input_image: torch.Tensor, quiet: bool = False, **kwargs):
         self.assert_has_levels()
 
-        init_states = self._extract_comparison_initial_states()
+        init_states = self._extract_operator_initial_states()
 
         output_images = self._iterate(input_image, init_states, quiet, **kwargs)
 
         return pystiche.tuple(output_images).detach()
 
-    def _extract_comparison_initial_states(self) -> Dict[Operator, InitialState]:
-        operators = tuple(self.image_optimizer.operators(Comparison))
+    def _extract_operator_initial_states(self) -> Dict[Operator, InitialState]:
+        operators = tuple(self.image_optimizer.operators())
         init_states = []
         for operator in operators:
-            target_image = operator.target_image
-
             has_input_guide = (
                 isinstance(operator, Guidance) and operator.has_input_guide
             )
             input_guide = operator.input_guide if has_input_guide else None
 
-            has_target_guide = isinstance(operator, ComparisonGuidance)
+            has_target_guide = (
+                isinstance(operator, ComparisonGuidance) and operator.has_target_guide
+            )
             target_guide = operator.target_guide if has_target_guide else None
 
+            has_target_image = (
+                isinstance(operator, Comparison) and operator.has_target_image
+            )
+            target_image = operator.target_image if has_target_image else None
+
             init_states.append(
                 self.InitialState(target_image, input_guide, target_guide)
             )


Test patch:
Repository: pystiche/pystiche

Issue:
ZeroDivisionError with default_epoch_optim_loop
I get an `ZeroDivisionError: integer division or modulo by zero` when using the `default_transformer_epoch_optim_loop`. This is probably because the `num_batches` of the `batch_sampler` is much smaller than in the `default_transformer_optim_loop` which results in `log_freq=0` in `default_transformer_optim_log_fn.` 

Below is a minimal example to reproduce the error: 
```python
from pystiche.optim.log import default_transformer_optim_log_fn, OptimLogger

logger = OptimLogger()
num_batches = 300
log_fn = default_transformer_optim_log_fn(logger, num_batches)
image_loading_velocity = 1
image_processing_velocity = 1
batch = 1
loss = 1
log_fn(batch, loss, image_loading_velocity, image_processing_velocity)
```


Discussion:
You are right, 

https://github.com/pmeier/pystiche/blob/20816a6c5693cb30a0551d37c127d56bdccfd6d1/pystiche/optim/log.py#L133-L134

does not anticipate `num_batches < 500`.

Resolving patch:
diff --git a/pystiche/optim/log.py b/pystiche/optim/log.py
--- a/pystiche/optim/log.py
+++ b/pystiche/optim/log.py
@@ -131,7 +131,7 @@ def default_transformer_optim_log_fn(
     show_running_means: bool = True,
 ):
     if log_freq is None:
-        log_freq = min(round(1e-3 * num_batches) * 10, 50)
+        log_freq = max(min(round(1e-3 * num_batches) * 10, 50), 1)
 
     window_size = min(10 * log_freq, 1000)
 


Test patch:
Repository: pystiche/pystiche

Issue:
Create encoding preprocessors not until runtime
Right now the preprocessors are created at import

https://github.com/pmeier/pystiche/blob/cad5ab6e9485680f2543cf4397d0d21e72a88b9e/pystiche/enc/preprocessing.py#L1-L4

We should only create them if they are needed to speed up the import.


Discussion:

Resolving patch:
diff --git a/pystiche/enc/preprocessing.py b/pystiche/enc/preprocessing.py
--- a/pystiche/enc/preprocessing.py
+++ b/pystiche/enc/preprocessing.py
@@ -1,10 +1,10 @@
 from torch import nn
 from pystiche.image import TorchPreprocessing, CaffePreprocessing
 
-PREPROCESSORS = {"torch": TorchPreprocessing(), "caffe": CaffePreprocessing()}
+PREPROCESSORS = {"torch": TorchPreprocessing, "caffe": CaffePreprocessing}
 
 __all__ = ["get_preprocessor"]
 
 
 def get_preprocessor(framework: str) -> nn.Module:
-    return PREPROCESSORS[framework]
+    return PREPROCESSORS[framework]()


Test patch: