internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rucio/rucio

Issue:
Increase Clarity of Listing Subscriptions for Users Without Any
### Description

Currently when you try to ask Rucio if a user has Subscriptions and they have none, a `SubscriptionNotFound` exception is intentionally raised.

This has been very confusing for myself and other users as we learn to use Subscriptions. It would be much clearer if this just indicated that there were no subscriptions for this user, without the scary looking traceback.

```
(rucio-clients) [bjwhite@GALACTICA:~/rucio-clients]$ rucio-admin subscription list --account root
Subscription not found.
Details: Subscription for account 'root' named 'None' not found
Rucio exited with an unexpected/unknown error, please provide the traceback below to the developers.
Traceback (most recent call last):
  File "/home/bjwhite/rucio-clients/bin/rucio-admin", line 97, in new_funct
    return function(*args, **kwargs)
  File "/home/bjwhite/rucio-clients/bin/rucio-admin", line 924, in list_subscriptions
    subs = client.list_subscriptions(name=args.name, account=account)
  File "/home/bjwhite/rucio-clients/lib64/python3.9/site-packages/rucio/client/subscriptionclient.py", line 99, in list_subscriptions
    raise exc_cls(exc_msg)
rucio.common.exception.SubscriptionNotFound: Subscription not found.
Details: Subscription for account 'root' named 'None' not found
```

### Motivation

_No response_

### Change

_No response_


Discussion:
This needs to be adressed in the [subscription](https://github.com/rucio/rucio/blob/3c693f0a2d48e45e0e0775a96fac28671335574b/lib/rucio/core/subscription.py#L207) core itself.

Resolving patch:
diff --git a/lib/rucio/client/subscriptionclient.py b/lib/rucio/client/subscriptionclient.py
--- a/lib/rucio/client/subscriptionclient.py
+++ b/lib/rucio/client/subscriptionclient.py
@@ -95,9 +95,10 @@ def list_subscriptions(self, name=None, account=None):
         result = self._send_request(url, type_='GET')
         if result.status_code == codes.ok:   # pylint: disable=no-member
             return self._load_json_data(result)
-        else:
-            exc_cls, exc_msg = self._get_exception(headers=result.headers, status_code=result.status_code, data=result.content)
-            raise exc_cls(exc_msg)
+        if result.status_code == codes.not_found:
+            return []
+        exc_cls, exc_msg = self._get_exception(headers=result.headers, status_code=result.status_code, data=result.content)
+        raise exc_cls(exc_msg)
 
     def update_subscription(self, name, account=None, filter_=None, replication_rules=None, comments=None, lifetime=None, retroactive=None, dry_run=None, priority=None):
         """


Test patch:
Repository: rucio/rucio

Issue:
Regression from #6516
### Description

The SQLAlchemy 2.0 syntax migration done as part of that PR changes the return value of `get_evaluation_backlog()`.

https://github.com/rucio/rucio/blob/cdd847fecb3041bc0007ba42735669fefeac6ffd/lib/rucio/core/rule.py#L2417-L2432

There is a misuse of `scalars()`.

### Steps to reproduce

Running the Reaper or the Necromancer causes an unhandled exception.

### Rucio Version

34.0.0rc1

### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/rule.py b/lib/rucio/core/rule.py
--- a/lib/rucio/core/rule.py
+++ b/lib/rucio/core/rule.py
@@ -22,9 +22,9 @@
 from os import path
 from re import match
 from string import Template
-from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Type, TypeVar
+from typing import TYPE_CHECKING, Any, Callable, Literal, Optional, Type, TypeVar, Union
 
-from dogpile.cache.api import NO_VALUE
+from dogpile.cache.api import NoValue
 from sqlalchemy import select, update
 from sqlalchemy.exc import IntegrityError, StatementError
 from sqlalchemy.exc import NoResultFound  # https://pydoc.dev/sqlalchemy/latest/sqlalchemy.exc.NoResultFound.html
@@ -2422,14 +2422,16 @@ def get_evaluation_backlog(expiration_time: int = 600, *, session: "Session") ->
     :returns:     Tuple (Count, Datetime of oldest entry)
     """
 
-    cached_backlog = REGION.get('rule_evaluation_backlog', expiration_time=expiration_time)
-    if cached_backlog is NO_VALUE:
-        stmt = select(func.count(models.UpdatedDID.created_at), func.min(models.UpdatedDID.created_at))
-        result = session.execute(stmt).scalars().one()
+    cached_backlog: Union[NoValue, tuple[int, datetime]] = REGION.get('rule_evaluation_backlog', expiration_time=expiration_time)
+    if isinstance(cached_backlog, NoValue):
+        stmt = select(
+            func.count(models.UpdatedDID.created_at),
+            func.min(models.UpdatedDID.created_at)
+        )
+        result = session.execute(stmt).one()._tuple()
         REGION.set('rule_evaluation_backlog', result)
         return result
-    else:
-        return cached_backlog  # type: ignore
+    return cached_backlog
 
 
 @transactional_session


Test patch:
Repository: rucio/rucio

Issue:
Hermes: username not assigned when use_ssl: True causes an error
### Description

When configuring Hermes Daemon to `use_ssl: True`, Hermes has an error saying, `local variable 'username' referenced before assignment`

### Steps to reproduce

1. Set `messaging-hermes.use_ssl` to True
2. Start the Daemon

### Rucio Version

Daemons: 32.4.0

### Additional Information

- Operating System: OKD Cluster/Kubernetes
- Bug is server side (in hermes daemon)
- ActiveMQ/RabbitMQ is the broker with STOMP plugin

After looking through the hermes daemon code, it looks like in the function `setup_activemq`, the `username` variable is only assigned when `use_ssl` is `False`:
https://github.com/rucio/rucio/blob/d1c0faef08de89825950d4c8194e5a4535ffd6fe/lib/rucio/daemons/hermes/hermes.py#L190

The only instance of `username` being assigned is here:
https://github.com/rucio/rucio/blob/d1c0faef08de89825950d4c8194e5a4535ffd6fe/lib/rucio/daemons/hermes/hermes.py#L152-L155

This doesn't happen when `use_ssl` is `True`


Discussion:
One additional item: I think the same thing might happen with the `password` variable, since it is only assigned in the `if not use_ssl` statement.

Resolving patch:
diff --git a/lib/rucio/daemons/hermes/hermes.py b/lib/rucio/daemons/hermes/hermes.py
--- a/lib/rucio/daemons/hermes/hermes.py
+++ b/lib/rucio/daemons/hermes/hermes.py
@@ -149,6 +149,8 @@ def setup_activemq(logger: "Callable"):
 
     port = config_get_int("messaging-hermes", "port")
     vhost = config_get("messaging-hermes", "broker_virtual_host", raise_exception=False)
+    username = None
+    password = None
     if not use_ssl:
         username = config_get("messaging-hermes", "username")
         password = config_get("messaging-hermes", "password")


Test patch:
Repository: rucio/rucio

Issue:
Unclosed file in authentication
### Description

We are running tests by default with `-Werror`  and had failing tests due to what seems to be a resource leak in rucio authentication:

```
    File "/home/rucio_user/.local/lib/python3.9/site-packages/rucio/client/baseclient.py", line 948, in __authenticate
      if not self.__read_token():
  ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/rucio_user/.rucio_rucio_user/auth_token_for_account_root' mode='r' encoding='UTF-8'>
```

### Steps to reproduce

Run tests using a rucio client with warnings turned into errors

### Rucio Version

_No response_

### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py
--- a/lib/rucio/client/baseclient.py
+++ b/lib/rucio/client/baseclient.py
@@ -879,8 +879,8 @@ def __read_token(self) -> bool:
             return False
 
         try:
-            token_file_handler = open(self.token_file, 'r')
-            self.auth_token = token_file_handler.readline()
+            with open(self.token_file, 'r') as token_file_handler:
+                self.auth_token = token_file_handler.readline()
             self.headers['X-Rucio-Auth-Token'] = self.auth_token
         except OSError as error:
             print("I/O error({0}): {1}".format(error.errno, error.strerror))


Test patch:
Repository: rucio/rucio

Issue:
Unclosed socket  in utils
### Description

Follow up to #6787, a similar resource leak due to not using context managers for resource objects. In this case, a socket.


### Steps to reproduce


The two sockets here:

```
❯ rg -F 'socket(socket.AF_INET'
lib/rucio/common/utils.py
1233:        s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
1241:            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
```

are opened but never closed.

### Rucio Version

Current master and older

### Additional Information

_No response_


Discussion:

Resolving patch:
diff --git a/lib/rucio/common/utils.py b/lib/rucio/common/utils.py
--- a/lib/rucio/common/utils.py
+++ b/lib/rucio/common/utils.py
@@ -1230,17 +1230,17 @@ def detect_client_location():
     ip = None
 
     try:
-        s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
-        s.connect(("2001:4860:4860:0:0:0:0:8888", 80))
-        ip = s.getsockname()[0]
+        with socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) as s:
+            s.connect(("2001:4860:4860:0:0:0:0:8888", 80))
+            ip = s.getsockname()[0]
     except Exception:
         pass
 
     if not ip:
         try:
-            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-            s.connect(("8.8.8.8", 80))
-            ip = s.getsockname()[0]
+            with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
+                s.connect(("8.8.8.8", 80))
+                ip = s.getsockname()[0]
         except Exception:
             pass
 


Test patch:
Repository: biopython/biopython

Issue:
Added methods to remove children of disordered Entities
- [x] I hereby agree to dual licence this and any previous contributions under both
the _Biopython License Agreement_ **AND** the _BSD 3-Clause License_.

- [x] I have read the ``CONTRIBUTING.rst`` file, have run ``pre-commit`` locally,
and understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
tests and style checks pass with these changes.

- [x] I have added my name to the alphabetical contributors listings in the files
``NEWS.rst`` and ``CONTRIB.rst`` as part of this pull request, am listed
already, or do not wish to be listed. (*This acknowledgement is optional.*)

Disordered entities like DisorderedAtom and DisorderedResidues allow adding children to them but not removing. Removing is useful when editing structures. This PR adds methods to allow that to happen and simplifies, for instance, removing altlocs from a structure:

```python
s = ...  # structure
for atom in s.get_atoms():
    if atom.is_disordered():
        altlocs = list(atom.child_dict)
        altlocs.remove(atom.selected_child)
        for a in altlocs:
            atom.disordered_remove(a)
```

The methods do not remove the disordered entity completely even if it is empty. I thought that would be better left to the user to do it explicitly from the parent. They do change the `__repr__` of the disordered entity to signal that they are empty.


Discussion:

Resolving patch:
diff --git a/Bio/PDB/PDBParser.py b/Bio/PDB/PDBParser.py
--- a/Bio/PDB/PDBParser.py
+++ b/Bio/PDB/PDBParser.py
@@ -108,6 +108,7 @@ def _parse(self, header_coords_trailer):
     def _get_header(self, header_coords_trailer):
         "Get the header of the PDB file, return the rest."
         structure_builder=self.structure_builder
+        i = 0
         for i in range(0, len(header_coords_trailer)):
             structure_builder.set_line_counter(i+1)
             line=header_coords_trailer[i]


Test patch:
Repository: biopython/biopython

Issue:
greytrack_font_rotation in GenomDiagram circular format doesn't work.
If you generate a circular diagram and specify greytrack_font_rotation for your tracks nothing changes, labels are still radial (I wanted to locate them along the tracks with greytrack_font_rotation=90 or 270).



Discussion:
None of the label orientations on circular diagrams are intended to be user specifiable - those options should all say they are for linear diagrams only. If the documentation is unclear please re-open this.

Documentation says the following:

> _greytrack_font_rotation_ is an integer specifying the angle in degrees through
> which to rotate the foreground labels, which are, by default, radial in circu-
> lar diagrams and collinear with the track for linear diagrams (deafult=0).

I am sorry, I don't see how I can re-open an issue here...

@widdowquinn Leighton, does this just need a documentation clarification that this is not supported?

I would say so. I think that the option may have worked in a very early version, but was then discarded due to fugliness. 


Resolving patch:
diff --git a/Bio/Graphics/GenomeDiagram/_Track.py b/Bio/Graphics/GenomeDiagram/_Track.py
--- a/Bio/Graphics/GenomeDiagram/_Track.py
+++ b/Bio/Graphics/GenomeDiagram/_Track.py
@@ -90,7 +90,7 @@ class Track(object):
                                 labels on the grey track
 
         o greytrack_font_rotation   Int describing the angle through which to
-                                    rotate the grey track labels
+                                    rotate the grey track labels (Linear only)
 
         o greytrack_font_color     colors.Color describing the color to draw
                                     the grey track labels
@@ -168,7 +168,7 @@ def __init__(self, name=None, height=1, hide=0, greytrack=0,
                                     labels on the grey track
 
             o greytrack_font_rotation   Int describing the angle through which to
-                                        rotate the grey track labels
+                                        rotate the grey track labels (Linear only)
 
             o greytrack_font_color     colors.Color describing the color to draw
                                        the grey track labels (overridden by


Test patch:
Repository: biopython/biopython

Issue:
Genepop parsing error
Currently, when using the example stated in the [wiki](http://biopython.org/wiki/PopGen_Genepop) for controlling Genpop, at least one of the example fails:

`loci_map = ctrl.test_hw_pop(1, "excess")`

The error is the following:

``` python
Traceback (most recent call last):
  File "BioGenepop.py", line 50, in <module>
    get_exp_obs_het(filehandle, argv[2])
  File "BioGenepop.py", line 34, in get_exp_obs_het
    loci_map = filehandle.test_hw_pop(pop, "excess")
  File "/usr/lib/python3.4/site-packages/Bio/PopGen/GenePop/EasyController.py", line 45, in test_hw_pop
    return next(hw_res)
  File "/usr/lib/python3.4/site-packages/Bio/PopGen/GenePop/Controller.py", line 164, in __next__
    return self.func(self)
  File "/usr/lib/python3.4/site-packages/Bio/PopGen/GenePop/Controller.py", line 266, in hw_func
    return _hw_func(self.stream, False)
  File "/usr/lib/python3.4/site-packages/Bio/PopGen/GenePop/Controller.py", line 130, in _hw_func
    locus, p, se, fis_wc, fis_rh, steps = entry[:-1]
ValueError: need more than 2 values to unpack
```

This is due to a problem in the table parsing, which has a wrong value.
I have patched the issue and will submit a pull request shortly.



Discussion:

Resolving patch:
diff --git a/Bio/PopGen/GenePop/Controller.py b/Bio/PopGen/GenePop/Controller.py
--- a/Bio/PopGen/GenePop/Controller.py
+++ b/Bio/PopGen/GenePop/Controller.py
@@ -122,7 +122,7 @@ def _hw_func(stream, is_locus, has_fisher=False):
             # loci might mean pop if hook="Locus "
             loci = {}
             for entry in table:
-                if len(entry) < 3:
+                if len(entry) < 4:
                     loci[entry[0]] = None
                 else:
                     locus, p, se, fis_wc, fis_rh, steps = entry[:-1]


Test patch:
diff --git a/Tests/test_PopGen_GenePop_EasyController.py b/Tests/test_PopGen_GenePop_EasyController.py
--- a/Tests/test_PopGen_GenePop_EasyController.py
+++ b/Tests/test_PopGen_GenePop_EasyController.py
@@ -90,6 +90,12 @@ def test_estimate_nm(self):
         nms = self.ctrl.estimate_nm()
         self.assertEqual(nms[0], 28.0)
 
+    def test_hwe_excess(self):
+        """Test Hardy-Weinberg Equilibrium.
+        """
+        hwe_excess = self.ctrl.test_hw_pop(0, "excess")
+        self.assertEqual(hwe_excess["Locus1"], (0.4955, None, -0.16, -0.1623, 5))
+
 # These tests are frequently failing, possibly due to a Genepop problem.
 #    def test_get_avg_fst_pair_locus(self):
 #        """Test get average Fst for pairwise pops on a locus.
Repository: biopython/biopython

Issue:
SeqIO docstring lists "abif" as possible format
Biopython v1.71.dev0

The docstring for SeqIO.parse lists `abif` as a possible format, but it really means to say `abi` and `abi-trim`.



Discussion:
Well spotted. Would you like to submit a pull request? CC @bow 
Sure, on the way...

Resolving patch:
diff --git a/Bio/SeqIO/__init__.py b/Bio/SeqIO/__init__.py
--- a/Bio/SeqIO/__init__.py
+++ b/Bio/SeqIO/__init__.py
@@ -269,7 +269,8 @@
 When specifying the file format, use lowercase strings.  The same format
 names are also used in Bio.AlignIO and include the following:
 
-    - abif    - Applied Biosystem's sequencing trace format
+    - abi     - Applied Biosystem's sequencing trace format
+    - abi-trim - Same as "abi" but with quality trimming with Mott's algorithm
     - ace     - Reads the contig sequences from an ACE assembly file.
     - embl    - The EMBL flat file format. Uses Bio.GenBank internally.
     - fasta   - The generic sequence file format where each record starts with


Test patch:
Repository: biopython/biopython

Issue:
key err in DNA_TMM1 of Bio.SeqUtils for two NN pairs
### Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

```python
3.7.4 (default, Aug 13 2019, 15:17:50) 
[Clang 4.0.1 (tags/RELEASE_401/final)]
CPython
Darwin-18.6.0-x86_64-i386-64bit
1.74
```

### Expected behavior

All terminal mismatch pairs in the terminal mismatch table `DNA_TMM1` are included in nearest neighbor tm calculation

### Actual behaviour

I saw two keys with spaces in the terminal mismatch table `DNA_TMM1`: ` GG/CA` and ` CC/GC`. I don't see a trim or anything in `Bio.SeqUtils.Tm_NN` at this step, so I believe these two pairs are being missed during tm calculation and the tm's are a tad low.

`' GG/CA'`
`' CC/GC'`

and the code to calculate the tm with neighbors:

```python
    # Now for terminal mismatches
    left_tmm = tmp_cseq[:2][::-1] + '/' + tmp_seq[:2][::-1]
    if left_tmm in tmm_table:
        delta_h += tmm_table[left_tmm][d_h]
        delta_s += tmm_table[left_tmm][d_s]
        tmp_seq = tmp_seq[1:]
        tmp_cseq = tmp_cseq[1:]
    right_tmm = tmp_seq[-2:] + '/' + tmp_cseq[-2:]
    if right_tmm in tmm_table:
        delta_h += tmm_table[right_tmm][d_h]
        delta_s += tmm_table[right_tmm][d_s]
        tmp_seq = tmp_seq[:-1]
        tmp_cseq = tmp_cseq[:-1]
```

I can do a PR for this -- it's just a two character change. Please let me know.

### Steps to reproduce

```
from Bio.SeqUtils.MeltingTemp import Tm_NN
Tm_NN("AAAAAAGG", c_seq="TTTTTTCA")
```



Discussion:
Thank you @JJTimmons, I'll have a look. 
@JJTimmons Again, thank you for spotting this. The bug is there from the beginning of the updated module...
So if you like to do a PR, please go on!

Resolving patch:
diff --git a/Bio/SeqUtils/MeltingTemp.py b/Bio/SeqUtils/MeltingTemp.py
--- a/Bio/SeqUtils/MeltingTemp.py
+++ b/Bio/SeqUtils/MeltingTemp.py
@@ -318,7 +318,7 @@
 DNA_TMM1 = {
     "AA/TA": (-3.1, -7.8), "TA/AA": (-2.5, -6.3), "CA/GA": (-4.3, -10.7),
     "GA/CA": (-8.0, -22.5),
-    "AC/TC": (-0.1, 0.5), "TC/AC": (-0.7, -1.3), " CC/GC": (-2.1, -5.1),
+    "AC/TC": (-0.1, 0.5), "TC/AC": (-0.7, -1.3), "CC/GC": (-2.1, -5.1),
     "GC/CC": (-3.9, -10.6),
     "AG/TG": (-1.1, -2.1), "TG/AG": (-1.1, -2.7), "CG/GG": (-3.8, -9.5),
     "GG/CG": (-0.7, -19.2),
@@ -331,7 +331,7 @@
     "CT/GC": (-3.9, -10.6), "GC/CT": (-4.9, -13.5), "GT/CC": (-3.0, -7.8),
     "TC/AT": (-2.5, -6.3), "TT/AC": (-0.7, -1.2),
     "AA/TG": (-1.9, -4.4), "AG/TA": (-2.5, -5.9), "CA/GG": (-3.9, -9.6),
-    "CG/GA": (-6.0, -15.5), "GA/CG": (-4.3, -11.1), " GG/CA": (-4.6, -11.4),
+    "CG/GA": (-6.0, -15.5), "GA/CG": (-4.3, -11.1), "GG/CA": (-4.6, -11.4),
     "TA/AG": (-2.0, -4.7), "TG/AA": (-2.4, -5.8),
     "AG/TT": (-3.2, -8.7), "AT/TG": (-3.5, -9.4), "CG/GT": (-3.8, -9.0),
     "CT/GG": (-6.6, -18.7), "GG/CT": (-5.7, -15.9), "GT/CG": (-5.9, -16.1),


Test patch:
Repository: biopython/biopython

Issue:
Python 3.8 now throws an exception when modifying a dictionary while iterating
Python 3.8 now throws an exception when modifying a dictionary while iterating

```
--- a/Bio/SubsMat/__init__.py
+++ b/Bio/SubsMat/__init__.py
@@ -207,7 +207,7 @@ class SeqMat(dict):
 
     def _correct_matrix(self):
         """Sort key tuples (PRIVATE)."""
-        for key in self:
+        for key in dict(self):
             if key[0] > key[1]:
                 self[(key[1], key[0])] = self[key]
                 del self[key]
```



Discussion:
Rather than doing ``dict(self)`` probably ``list(self)`` would be enough. Do you have a test case triggering this? Our existing unit tests evidently don't cover it...
https://launchpad.net/ubuntu/+source/python-biopython/1.73+dfsg-1ubuntu3
please see the debian/rules file or at the build logs how the tests are invoked. I looks to me like the upstream testsuite, however that's still 1.73.
I don't understand why with our master branch (where nothing has changed in this regard) the same tests pass on Python 3.8, but the issue itself seems clear.

We ere using a pre-release, but here it is Python 3.8.0 (final):
https://travis-ci.org/biopython/biopython/jobs/608217669

Anyway, @mdehoon do you want to take this one?
See this now on the Biopython 1.75 wheel tests (still puzzled why our main TravisCI setup missed it), Linux:

https://travis-ci.org/biopython/biopython-wheels/jobs/608308357
https://travis-ci.org/biopython/biopython-wheels/jobs/608308358

macOS probably too (waiting for that to run).




Resolving patch:
diff --git a/Bio/SubsMat/__init__.py b/Bio/SubsMat/__init__.py
--- a/Bio/SubsMat/__init__.py
+++ b/Bio/SubsMat/__init__.py
@@ -207,7 +207,7 @@ def __init__(self, data=None, alphabet=None, mat_name="", build_later=0):
 
     def _correct_matrix(self):
         """Sort key tuples (PRIVATE)."""
-        for key in self:
+        for key in list(self):  # iterate over a copy
             if key[0] > key[1]:
                 self[(key[1], key[0])] = self[key]
                 del self[key]


Test patch: