nebius/SWE-bench-extra huggingface dataset:
Repository: collective/zpretty

Issue:
problem in combination of "&" and ";" in attributes.
Affects: zpretty 3.1.0a1

## problem 1

Running `zpretty` without any options on this input:
```
<a href="a=b&c=d"></a>
<div tal:define="var view/attr;"></div>
```

Produces this output:
```
<a href="a=b&c=d"></a>
<div tal:define="var view/attr;"></a>
```

Or with even more stripped down input:

```
<a attr="&"></a>
<div attr=";"></div>
```

produces:
```
<a attr="&"></a>
<div attr=";"></a>
```

## problem 2

This input:
```
<a tal:attributes="href python:'&';"></a>
```

Produces this output:
```
<a tal:attributes="
     href python:'&';;
   "></a>
```

There is an extra semicolon which shouldn't be there.




Comments:

Patch:
diff --git a/HISTORY.md b/HISTORY.md
index c475ebf..64da5b9 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,15 +2,15 @@
 
 ## 3.1.0a2 (unreleased)
 
-
-- Nothing changed yet.
-
+- Improve the regular expression that matches the entities
+  (Fixes #130)
+  [ale-rt]
 
 ## 3.1.0a1 (2023-05-04)
 
 - Add command line parameters to include/exclude files and folders
   (Implements #96)
-  [ale-rt]  
+  [ale-rt]
 - Be tolerant with characters forbidden in XML when dealing with tal attributes
   (See #125)
   [ale-rt]
diff --git a/zpretty/prettifier.py b/zpretty/prettifier.py
index e28e7f7..9d0a15e 100644
--- a/zpretty/prettifier.py
+++ b/zpretty/prettifier.py
@@ -81,12 +81,16 @@ class ZPrettifier(object):
         # Get all the entities in the text and replace them with a marker
         # The text might contain undefined entities that BeautifulSoup
         # will strip out.
-        entities = set(re.findall(r"&[^;]+;", text))
-        for entitiy in entities:
+        entities = {
+            _[0]
+            for _ in re.findall(
+                r"(&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});)", text, re.IGNORECASE
+            )
+        }
+        for entity in entities:
             marker = str(uuid4())
-            self._entity_mapping[entitiy] = marker
-            text = text.replace(entitiy, marker)
-
+            self._entity_mapping[entity] = marker
+            text = text.replace(entity, marker)
         return "\n".join(
             line if line.strip() else self._newlines_marker
             for line in text.splitlines()


Test patch:
diff --git a/zpretty/tests/test_zpretty.py b/zpretty/tests/test_zpretty.py
index 016b847..92b6ee2 100644
--- a/zpretty/tests/test_zpretty.py
+++ b/zpretty/tests/test_zpretty.py
@@ -185,6 +185,12 @@ class TestZpretty(TestCase):
         self.assertPrettified('<root a=";&amp;" />', '<root a=";&amp;"></root>\n')
         self.assertPrettified('<root a="&amp;;" />', '<root a="&amp;;"></root>\n')
 
+    def test_ampersand_and_column_in_separate_attrs(self):
+        self.assertPrettified(
+            '<foo a="&" />\n<tal:bar b=";" />',
+            '<foo a="&amp;"></foo>\n<tal:bar b=";" />\n',
+        )
+
     def test_sample_html(self):
         self.prettify("sample_html.html")
Repository: collective/zpretty

Issue:
empty lines in tag lead to invalid attributes
when test.html is
```
<select id="workflow_action"
        name="workflow_action"
        
></select>
```
then ``$ zpretty test.html`` produces this output:
```
<select id="workflow_action"
        =""
        name="workflow_action"
></select>
```

Or general test.html:
```
<tag attr="ok"

></tag>
```

leads to:
```
<tag =""
     attr="ok"
></tag>
```

Comments:

Patch:
diff --git a/HISTORY.md b/HISTORY.md
index b796720..b7935f6 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -3,6 +3,7 @@
 2.1.0 (unreleased)
 ------------------
 
+- Do not render a spurious `=""` when new lines appear inside a tag (Refs. #35) [ale-rt]
 - The attributes renderer knows about the element indentation
   and for indents the attributes consequently [ale-rt]
 - The ZCML element has now its custom tag templates, this simplifies the code [ale-rt]
diff --git a/zpretty/prettifier.py b/zpretty/prettifier.py
index 3e6cf5a..4468653 100644
--- a/zpretty/prettifier.py
+++ b/zpretty/prettifier.py
@@ -33,6 +33,11 @@ class ZPrettifier(object):
             for line in text.splitlines()
         )
         self.soup = self.get_soup(self.text)
+
+        # Cleanup all spurious self._newlines_marker attributes, see #35
+        for el in self.soup.find_all(attrs={self._newlines_marker: ""}):
+            el.attrs.pop(self._newlines_marker, None)
+
         self.root = self.pretty_element(self.soup, -1)
 
     def get_soup(self, text):


Test patch:
diff --git a/zpretty/tests/test_zpretty.py b/zpretty/tests/test_zpretty.py
index 0db7440..17eb548 100644
--- a/zpretty/tests/test_zpretty.py
+++ b/zpretty/tests/test_zpretty.py
@@ -152,6 +152,17 @@ class TestZpretty(TestCase):
             "<root>\n (<a></a>)\n</root>", "<root>\n  (<a></a>)\n</root>\n"
         )
 
+    def test_elements_with_new_lines(self):
+        self.assertPrettified("<root\n></root>", "<root></root>\n")
+        self.assertPrettified(
+            '<root\na="b"\n\n></root>',
+            ('<root a="b"></root>\n'),
+        )
+        self.assertPrettified(
+            '<root\na="b"\n\nc="d"></root>',
+            ('<root a="b"\n      c="d"\n></root>\n'),
+        )
+
     def test_entities(self):
         self.assertPrettified("<root>&nbsp;</root>", "<root>&nbsp;</root>\n")
Repository: conda/conda-pack

Issue:
continue to ignore `info` in `load_files()` or just use `--ignore-missing-files`?
The following error broke our nightlies a few nights ago:

```
$ conda pack --format tar.gz -j -1
Collecting packages...
CondaPackError:
Files managed by conda were found to have been deleted/overwritten in the
following packages:

- python='3.8.5'

This is usually due to `pip` uninstalling or clobbering conda managed files,
resulting in an inconsistent environment. Please check your environment for
conda/pip conflicts using `conda list`, and fix the environment by ensuring
only one version of each package is installed (conda preferred).
```

Debugging `core.py`, I found this following entry in `paths.json` is the root cause:

```
$ pwd
/export/home/ops/conda/pkgs/python-3.8.5-h7579374_1/info
$ diff paths.json.orig paths.json
900,905d899
<       "_path": "info/info_json.d/security.json",
<       "path_type": "hardlink",
<       "sha256": "1eba042cbb28d2403ca77fbdd8fb7ca518d65b0522a13730255ffdef694a826a",
<       "size_in_bytes": 1773
<     },
<     {
```

2 ways to solve the error:
1. Use `--ignore-missing-files`
1. Remove `info` from `load_files`: https://github.com/conda/conda-pack/blob/master/conda_pack/core.py#L585

What do you all recommend?

Comments:

Patch:
diff --git a/conda_pack/core.py b/conda_pack/core.py
index 7dd06d5..b759ee3 100644
--- a/conda_pack/core.py
+++ b/conda_pack/core.py
@@ -649,7 +649,7 @@ def read_has_prefix(path):
 def load_files(prefix):
     from os.path import relpath, join, isfile, islink
 
-    ignore = {'pkgs', 'envs', 'conda-bld', '.conda_lock', 'users', 'info',
+    ignore = {'pkgs', 'envs', 'conda-bld', '.conda_lock', 'users',
               'conda-recipes', '.index', '.unionfs', '.nonadmin', 'python.app',
               'Launcher.app'}
 


Test patch:
diff --git a/testing/env_yamls/has_conda.yml b/testing/env_yamls/has_conda.yml
index 50ad03d..dd33147 100644
--- a/testing/env_yamls/has_conda.yml
+++ b/testing/env_yamls/has_conda.yml
@@ -3,4 +3,3 @@ name: has_conda
 dependencies:
     - conda
     - toolz
-    - python=3.7
Repository: conda/conda-pack

Issue:
Properly handle root environment
The root environment is different than sub-environments in a couple key ways:

- The path contains extra directories like the package cache, `conda-bld` directory, etc...
- The environment contains conda itself, and may contain packages that depend on it (these are forbidden in sub-environments)

A few options for handling the root environment:
- Special case the handling to directories/files that shouldn't be packed, and packages that depend on conda
- Error nicely and tell the user to create a sub-environment

I'm not sure which would be more expected. The second is a lot easier to implement.

Comments:

Patch:
diff --git a/conda_pack/core.py b/conda_pack/core.py
index 12478c2..c2b5655 100644
--- a/conda_pack/core.py
+++ b/conda_pack/core.py
@@ -659,6 +659,10 @@ def load_environment(prefix, unmanaged=True, on_missing_cache='warn'):
     if not os.path.exists(conda_meta):
         raise CondaPackException("Path %r is not a conda environment" % prefix)
 
+    # Check that it's not the root environment
+    if any(os.path.exists(os.path.join(prefix, d)) for d in ['pkgs', 'envs']):
+        raise CondaPackException("Cannot package root environment")
+
     # Find the environment site_packages (if any)
     site_packages = find_site_packages(prefix)
 


Test patch:
diff --git a/conda_pack/tests/test_core.py b/conda_pack/tests/test_core.py
index ccafe44..b2b7306 100644
--- a/conda_pack/tests/test_core.py
+++ b/conda_pack/tests/test_core.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import, print_function, division
 
+import json
 import os
 import subprocess
 import tarfile
@@ -62,6 +63,16 @@ def test_errors_editable_packages():
     assert "Editable packages found" in str(exc.value)
 
 
+def test_errors_root_environment():
+    info = subprocess.check_output("conda info --json", shell=True).decode()
+    root_prefix = json.loads(info)['root_prefix']
+
+    with pytest.raises(CondaPackException) as exc:
+        CondaEnv.from_prefix(root_prefix)
+
+    assert "Cannot package root environment" in str(exc.value)
+
+
 def test_env_properties(py36_env):
     assert py36_env.name == 'py36'
     assert py36_env.prefix == py36_path