PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: Azure/WALinuxAgent (python)
Issue: Exception retrieving artifacts profile: TypeError: decoding str is not supported
I am tracking a annoying issue in the BVTs with the following signature.

```text
Exception retrieving artifacts profile: TypeError: decoding str is not supported
```

I increased debugging, and found this call stack.

```text
2018/04/18 06:03:51.919139 WARNING Exception retrieving artifacts profile: Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/azurelinuxagent/common/protocol/wire.py", line 1135, in get_artifacts_profile
    profile = self.decode_config(config)
  File "/usr/local/lib/python3.5/dist-packages/azurelinuxagent/common/protocol/wire.py", line 563, in decode_config
    xml_text = ustr(data, encoding='utf-8')
TypeError: decoding str is not supported
```

When I read the code for `get_artifacts_profile`, I noticed that decode_config is called twice.  The method `fetch` calls decode_config, and then `get_artifacts_profile` calls decode_config.  It appears that you cannot call decode_config twice with the same data.

The method decode_config is confusing because it has variables like xml_text, but the data passed in this case is actually JSON.  Azure does not do us any favors because some systems return XML and other returns JSON.  The agent could or should be smarter about this.

The bug was introduced with d0b583cc.
Pull request description: do not call decode_config twice
Closes #1119 

Patch:
diff --git a/azurelinuxagent/common/protocol/wire.py b/azurelinuxagent/common/protocol/wire.py
index 67a55203..5df35a98 100644
--- a/azurelinuxagent/common/protocol/wire.py
+++ b/azurelinuxagent/common/protocol/wire.py
@@ -1129,8 +1129,7 @@ class WireClient(object):
 
                         host = self.get_host_plugin()
                         uri, headers = host.get_artifact_request(blob)
-                        config = self.fetch(uri, headers, use_proxy=False)
-                        profile = self.decode_config(config)
+                        profile = self.fetch(uri, headers, use_proxy=False)
 
                     if not textutil.is_str_none_or_whitespace(profile):
                         logger.verbose("Artifacts profile downloaded")


Test patch:
diff --git a/tests/protocol/test_wire.py b/tests/protocol/test_wire.py
index 34b82862..ffe72edf 100644
--- a/tests/protocol/test_wire.py
+++ b/tests/protocol/test_wire.py
@@ -342,7 +342,7 @@ class TestWireProtocol(AgentTestCase):
         wire_protocol_client.ext_conf.artifacts_profile_blob = testurl
         goal_state = GoalState(WireProtocolData(DATA_FILE).goal_state)
         wire_protocol_client.get_goal_state = Mock(return_value=goal_state)
-        wire_protocol_client.fetch = Mock(side_effect=[None, '{"onHold": "true"}'.encode('utf-8')])
+        wire_protocol_client.fetch = Mock(side_effect=[None, '{"onHold": "true"}'])
         with patch.object(HostPluginProtocol,
                           "get_artifact_request",
                           return_value=['dummy_url', {}]) as artifact_request:
Repository: rust-lang/rustfmt (rust)
Issue: comment in const generic default causes line duplication
```rust
type Foo = impl Send;
struct Struct<
    const C: usize = {
        let _: Foo = ();
        //~^ ERROR: mismatched types
        0
    },
>;
```

gets formatted to

```rust
type Foo = impl Send;
struct Struct<
    const C: usize = {
        let _: Foo = ();
        //~^ ERROR: mismatched types
        0
    },
>
;
//~^ ERROR: mismatched types
0
},
>;
```

Without the comment, the formatting doesn't change.
Pull request description: correct span for structs with const generics
Fixes #5668 

r? @ytmimi 

Working on doing a sync today but wanted to get this trivial fix in as part of it. Should be able to start cranking through the backlog of PRs afterwards

Patch:
diff --git a/src/items.rs b/src/items.rs
index 755a41f6..063a6428 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -1245,7 +1245,7 @@ fn format_unit_struct(
 ) -> Option<String> {
     let header_str = format_header(context, p.prefix, p.ident, p.vis, offset);
     let generics_str = if let Some(generics) = p.generics {
-        let hi = context.snippet_provider.span_before(p.span, ";");
+        let hi = context.snippet_provider.span_before_last(p.span, ";");
         format_generics(
             context,
             generics,


Test patch:
diff --git a/tests/target/issue_5668.rs b/tests/target/issue_5668.rs
new file mode 100644
index 00000000..bbd9a530
--- /dev/null
+++ b/tests/target/issue_5668.rs
@@ -0,0 +1,8 @@
+type Foo = impl Send;
+struct Struct<
+    const C: usize = {
+        let _: Foo = ();
+        //~^ ERROR: mismatched types
+        0
+    },
+>;