internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Cog-Creators/Red-DiscordBot

Issue:
[Audio] Fix attachment suffix reading on playlist upload
### Description of the changes

With Discord's new file attachment expiration, the file suffix for an upload is longer than just "txt", causing playlist upload to fail. This changes it to only read the first 3 characters of the suffix provided.

### Have the changes in this PR been tested?

Yes




Discussion:

Resolving patch:
diff --git a/redbot/cogs/audio/core/commands/playlists.py b/redbot/cogs/audio/core/commands/playlists.py
--- a/redbot/cogs/audio/core/commands/playlists.py
+++ b/redbot/cogs/audio/core/commands/playlists.py
@@ -7,6 +7,7 @@
 
 from io import BytesIO
 from pathlib import Path
+from urllib.parse import urlparse
 from typing import cast
 
 import discord
@@ -1823,7 +1824,7 @@ async def command_playlist_upload(
                 file_url = file_message.attachments[0].url
             except IndexError:
                 return await self.send_embed_msg(ctx, title=_("Upload cancelled."))
-            file_suffix = file_url.rsplit(".", 1)[1]
+            file_suffix = urlparse(file_url).path.rsplit(".", 1)[1]
             if file_suffix != "txt":
                 return await self.send_embed_msg(
                     ctx, title=_("Only Red playlist files can be uploaded.")
@@ -1848,7 +1849,7 @@ async def command_playlist_upload(
             if len(track_list) > 10000:
                 return await self.send_embed_msg(ctx, title=_("This playlist is too large."))
             uploaded_playlist_name = uploaded_playlist.get(
-                "name", (file_url.split("/")[6]).split(".")[0]
+                "name", (urlparse(file_url).path.split("/")[-1]).rsplit(".", 1)[0]
             )
             try:
                 if self.api_interface is not None and (


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
Add a start_dm option to SimpleMenu
In order to support `[p]help` with a button menu in DMs, `SimpleMenu` needs to be able to be sent as a DM to a particular user [[Ref](https://github.com/Cog-Creators/Red-DiscordBot/pull/5375#issuecomment-1874666094)]. The current `SimpleMenu.start` method accepts a `Context` object, which is incompatible with this behavior. `SimpleMenu` should be given a new method `.start_dm(user: discord.User)`, which sends the menu as a direct message to that user.

**Developer note:**
`SimpleMenu` currently stores `self.ctx` in `.start`, however it does not appear to ever be used. The other two attributes set by `.start` (`message` and `author`) will be possible to set in this method.

Unblocks #5375


Discussion:
I would like to take on this issue as my first GitHub contribution. I have experience in python discord bots so I think I could solve this.
@Flame442 any reason we shouldn't consider expanding `.start()` to allow passing `discord.User` instead of creating another method? It's mostly just an alternative design but I feel like it may be a bit more aligned with how we generally do these kinds of APIs in Red wherever it makes sense?
I don't have strong opinions about which option is better, see https://github.com/Cog-Creators/Red-DiscordBot/pull/5375#issuecomment-1874660248 for where I asked Trusty what he thought the best approach was.
Thank you :)

Resolving patch:
diff --git a/redbot/core/utils/views.py b/redbot/core/utils/views.py
--- a/redbot/core/utils/views.py
+++ b/redbot/core/utils/views.py
@@ -242,6 +242,19 @@ async def start(self, ctx: Context, *, ephemeral: bool = False):
         kwargs = await self.get_page(self.current_page)
         self.message = await ctx.send(**kwargs, ephemeral=ephemeral)
 
+    async def start_dm(self, user: discord.User):
+        """
+        Used to start displaying the menu in a direct message.
+
+        Parameters
+        ----------
+            user: `discord.User`
+                The user that will be direct messaged by the bot.
+        """
+        self.author = user
+        kwargs = await self.get_page(self.current_page)
+        self.message = await user.send(**kwargs)
+
     async def get_page(self, page_num: int) -> Dict[str, Optional[Any]]:
         try:
             page = await self.source.get_page(page_num)


Test patch:
Repository: Cog-Creators/Red-DiscordBot

Issue:
`streamalert list` is not updated for new Discord's markdown
### What component of Red (cog, command, API) would you like to see improvements on?

Streams

### Describe the enhancement you're suggesting.

Discord has updated Markdown to support header & lists, whatever else they've added too...

However, this broke the `streamalert list` command in the process, because the output of the command return a list that would not work well with Discord's new Markdown functionalities.

**It would look like that:**
![image](https://github.com/Cog-Creators/Red-DiscordBot/assets/61093863/ac68bc68-b178-4924-b6db-8e7fc63dd72d)

**But now look like this**
![image](https://github.com/Cog-Creators/Red-DiscordBot/assets/61093863/7c924c38-963a-4251-aa3c-68964795f0da)

Feel free to suggest a new output syntax to respect.
Either rewrite the command output, or simply escape the markdown for the "-" character.

### Anything else?

_No response_


Discussion:
I'll attempt to work on this this weekend. It seems like it should be an easy fix

Resolving patch:
diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py
--- a/redbot/cogs/streams/streams.py
+++ b/redbot/cogs/streams/streams.py
@@ -418,10 +418,10 @@ async def streamalert_list(self, ctx: commands.Context):
             return
 
         for channel_id, stream_platform in streams_list.items():
-            msg += f"** - #{ctx.guild.get_channel(channel_id)}**\n"
+            msg += f"- {ctx.guild.get_channel(channel_id).mention}\n"
             for platform, streams in stream_platform.items():
-                msg += f"\t** - {platform}**\n"
-                msg += f"\t\t{humanize_list(streams)}\n"
+                msg += f"  - **{platform}**\n"
+                msg += f"    {humanize_list(streams)}\n"
 
         for page in pagify(msg):
             await ctx.send(page)


Test patch:
Repository: conda-forge/staged-recipes

Issue:
Travis-CI failure on master
@pelson is this related to the latest `conda-smithy`?

See https://travis-ci.org/conda-forge/staged-recipes/jobs/115055485

```
Repository created, please edit conda-forge.yml to configure the upload channels
and afterwards call 'conda smithy register-github'
usage: a tool to help create, administer and manage feedstocks.
       [-h]
       {init,register-github,register-ci,regenerate,recipe-lint,rerender} ...
a tool to help create, administer and manage feedstocks.: error: invalid choice: 'github-create' (choose from 'init', 'register-github', 'register-ci', 'regenerate', 'recipe-lint', 'rerender')
Traceback (most recent call last):
  File ".CI/create_feedstocks.py", line 118, in <module>
    subprocess.check_call(['conda', 'smithy', 'github-create', feedstock_dir] + owner_info)
  File "/Users/travis/miniconda/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['conda', 'smithy', 'github-create', '/var/folders/gw/_2jq29095y7b__wtby9dg_5h0000gn/T/tmp_pPzpc__feedstocks/autoconf-feedstock', '--organization', 'conda-forge']' returned non-zero exit status 2
```



Discussion:
Ah, yes. I'd forgotten about this. @JanSchulz wanted to rename the subcommand.
The change will need to happen in https://github.com/conda-forge/staged-recipes/blob/7e70cff1999503f9ed04e8cbaabe8be60d1d1d1e/.CI/create_feedstocks.py#L118

I can do that if you are not already on it.


Resolving patch:
diff --git a/.CI/create_feedstocks.py b/.CI/create_feedstocks.py
--- a/.CI/create_feedstocks.py
+++ b/.CI/create_feedstocks.py
@@ -115,7 +115,7 @@ def write_token(name, token):
                     # Sometimes, we have a repo, but there are no commits on it! Just catch that case.
                     subprocess.check_call(['git', 'checkout', '-b' 'master'], cwd=feedstock_dir)
             else:
-                subprocess.check_call(['conda', 'smithy', 'github-create', feedstock_dir] + owner_info)
+                subprocess.check_call(['conda', 'smithy', 'register-github', feedstock_dir] + owner_info)
 
         # Break the previous loop to allow the TravisCI registering to take place only once per function call.
         # Without this, intermittent failiures to synch the TravisCI repos ensue.


Test patch:
Repository: conda-forge/staged-recipes

Issue:
Latest conda-smithy is prevent poliastro feedstock creation
```
Repository registered at github, now call 'conda smithy register-ci'
Making feedstock for poliastro
/Users/travis/build/conda-forge/staged-recipes/recipes/poliastro has some lint:
  Selectors are suggested to take a "  # [<selector>]" form.
Traceback (most recent call last):
  File ".CI/create_feedstocks.py", line 93, in <module>
    subprocess.check_call(['conda', 'smithy', 'recipe-lint', recipe_dir])
  File "/Users/travis/miniconda/lib/python3.5/subprocess.py", line 584, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['conda', 'smithy', 'recipe-lint', '/Users/travis/build/conda-forge/staged-recipes/recipes/poliastro']' returned non-zero exit status 1
```

I am working on that.



Discussion:

Resolving patch:
diff --git a/.CI/create_feedstocks.py b/.CI/create_feedstocks.py
--- a/.CI/create_feedstocks.py
+++ b/.CI/create_feedstocks.py
@@ -90,8 +90,6 @@ def write_token(name, token):
             os.mkdir(feedstock_dir)
             print('Making feedstock for {}'.format(name))
 
-            subprocess.check_call(['conda', 'smithy', 'recipe-lint', recipe_dir])
-
             subprocess.check_call(['conda', 'smithy', 'init', recipe_dir,
                                    '--feedstock-directory', feedstock_dir])
             if not is_merged_pr:


Test patch:
Repository: OWASP/owasp-mastg

Issue:
[Bug] 1.5 pdf contains empty Appendix page
### MASTG Chapter

0x07-Appendix

### File Line Number

/

### Context

This file is empty, but still included in v1.5.0


Discussion:

Resolving patch:
diff --git a/tools/scripts/yaml_to_excel.py b/tools/scripts/yaml_to_excel.py
--- a/tools/scripts/yaml_to_excel.py
+++ b/tools/scripts/yaml_to_excel.py
@@ -190,14 +190,14 @@ def create_security_requirements_sheet(wb):
         if req["R"]:
             ws.cell(row=row, column=col_r).style = "orange"
 
-        ws.cell(row=row, column=col_link_common).value = "N/A"
-        ws.cell(row=row, column=col_link_common).style = "gray_header"
+        # ws.cell(row=row, column=col_link_common).value = "N/A"
+        # ws.cell(row=row, column=col_link_common).style = "gray_header"
         
-        ws.cell(row=row, column=col_link_android).value = "N/A"
-        ws.cell(row=row, column=col_link_android).style = "gray_header"
+        # ws.cell(row=row, column=col_link_android).value = "N/A"
+        # ws.cell(row=row, column=col_link_android).style = "gray_header"
 
-        ws.cell(row=row, column=col_link_ios).value = "N/A"
-        ws.cell(row=row, column=col_link_ios).style = "gray_header"
+        # ws.cell(row=row, column=col_link_ios).value = "N/A"
+        # ws.cell(row=row, column=col_link_ios).style = "gray_header"
 
         if req.get("links"):
             link_common = get_link_for(req["links"], "0x04")


Test patch:
Repository: OWASP/owasp-mastg

Issue:
[Bug] Broken links in MASTG Webpage
### MASTG Chapter

0x04g-Testing-Cryptography.md

### File Line Number

90

### Context

The links to "Data Storage on Android"  and "Data Storage on iOS" lead to 404


Discussion:
Hi @AndreMCCarvalho, I assume there will be more similar broken links. We'll fix them as soon as we can. Thank you very much for reporting!

Resolving patch:
diff --git a/tools/scripts/transform_files.py b/tools/scripts/transform_files.py
--- a/tools/scripts/transform_files.py
+++ b/tools/scripts/transform_files.py
@@ -4,10 +4,22 @@
 EMOJIS_regex = r"🥇 |🎁 |📝 |❗ "
 
 def transform_links(file_text):
-    print("[*] Regex Substitutions ../Document to MASTG/")
-    found = re.findall(r'(\((?:../)*Document/.*\.md/*)', file_text)
-    print(f"    Found: {found}")
-    return re.sub(r"\(((?:../)*)Document/(.*)\.md/*", r"(\1MASTG/\2/", file_text)
+    # print("[*] Regex Substitutions ../Document to MASTG/")
+    found = re.findall(r'(\(0x.*\.md/*)', file_text)
+
+    # TODO FIX we must find a better solution to this
+    while len(found) > 0:
+        print(f"    Found: {found}")
+        file_text = re.sub(r"\((0x0[1-3].*\.md)", r"(../Intro/\1", file_text)
+        file_text = re.sub(r"\((0x04.*\.md)", r"(../General/\1", file_text)
+        file_text = re.sub(r"\((0x05.*\.md)", r"(../Android/\1", file_text)
+        file_text = re.sub(r"\((0x06.*\.md)", r"(../iOS/\1", file_text)
+        file_text = re.sub(r"\((0x08.*\.md)", r"(../Tools/\1", file_text)
+        file_text = re.sub(r"\((0x09.*\.md)", r"(../References/\1", file_text)
+
+        found = re.findall(r'(\(0x.*\.md/*)', file_text)
+
+    return file_text
 
 def remove_emojis(file_text):
     print("[*] Regex Substitutions for emojis")
@@ -35,5 +47,5 @@ def transform(folder, functions):
 
                 file_obj.write_text(new_text)
 
-transform("docs", [transform_links])
-transform("Document", [remove_emojis])
\ No newline at end of file
+transform("docs/MASTG", [transform_links])
+# transform("docs/MASTG", [remove_emojis])
\ No newline at end of file


Test patch:
Repository: aeturrell/skimpy

Issue:
Words per row and Word count improper when we have multiple text columns
<img width="400" alt="image" src="https://github.com/aeturrell/skimpy/assets/15026338/f0ba26e7-1921-435f-b5dc-07dea340dfe2">

This is the result I got for titanic dataset and it looks improper.



Discussion:
<img width="947" alt="image" src="https://github.com/aeturrell/skimpy/assets/15026338/799ee6bb-a333-430a-afe3-787fea7d2361">

Oh no! This is not good. Will add to list to fix.

Resolving patch:
diff --git a/src/skimpy/__init__.py b/src/skimpy/__init__.py
--- a/src/skimpy/__init__.py
+++ b/src/skimpy/__init__.py
@@ -406,7 +406,7 @@ def _string_variable_summary_table(xf: pd.DataFrame) -> pd.DataFrame:
                     zip(
                         xf.columns,
                         [
-                            xf[xf.columns[0]].str.count(" ").add(1).sum() / len(xf)
+                            xf[col].str.count(" ").add(1).sum() / len(xf)
                             for col in xf.columns
                         ],
                     )
@@ -417,10 +417,7 @@ def _string_variable_summary_table(xf: pd.DataFrame) -> pd.DataFrame:
             dict(
                 zip(
                     xf.columns,
-                    [
-                        xf[xf.columns[0]].str.count(" ").add(1).sum()
-                        for col in xf.columns
-                    ],
+                    [xf[col].str.count(" ").add(1).sum() for col in xf.columns],
                 )
             ),
             dtype="int",
diff --git a/src/skimpy/__main__.py b/src/skimpy/__main__.py
--- a/src/skimpy/__main__.py
+++ b/src/skimpy/__main__.py
@@ -14,7 +14,7 @@ def main(input) -> None:
     Args:
         input ([csv]): A csv file to produce summary statistics on
     """
-    df = pd.read_csv(input, infer_datetime_format=True, parse_dates=True)
+    df = pd.read_csv(input, parse_dates=True)
     df = df.infer_objects()
     skim(df)
 


Test patch:
Repository: aeturrell/skimpy

Issue:
Skim output is not able to be recorded or exported to html or svg
I have tried to export skim results. I tried to record it using `Console(record=True)` before calling the function; however, I got a NoneType object. The expected result is an object to be exported via html or svg to share the results obtained. 
I also tested the `Console.capture()` method obtaining the same behavior. Did I do something wrong?

```
from skimpy import skim, generate_test_data
console = Console(record=True)
df = generate_test_data()
skim(df)
console.save_html("demo.html")
```
The demo.html is empty. Thanks for your support
Regards




Discussion:
Thanks for flagging this. Note that there is a `return_data` option in `skim` too.

Resolving patch:
diff --git a/src/skimpy/__init__.py b/src/skimpy/__init__.py
--- a/src/skimpy/__init__.py
+++ b/src/skimpy/__init__.py
@@ -6,6 +6,7 @@
 import sys
 from collections import defaultdict
 from itertools import chain
+from pathlib import Path
 from typing import Any
 from typing import Dict
 from typing import List
@@ -56,7 +57,6 @@
     "upper",
 }
 
-console = Console()
 QUANTILES = [0, 0.25, 0.5, 0.75, 1]
 HIST_BINS = 6
 # NB: unicode 1/2 and 8/8 blocks have inconsistent widths depending on font
@@ -614,6 +614,7 @@ def skim_polars(
 def skim(
     df_in: pd.DataFrame,
     return_data: bool = False,
+    record_results_path: Union[str, None] = None,
     header_style: str = "bold cyan",
 ) -> Optional[JSON]:
     """Skim a pandas data frame and return statistics.
@@ -633,6 +634,7 @@ def skim(
     Args:
         df_in (pl.DataFrame): Dataframe to skim.
         return_data (bool): Whether to return dictionary of results.
+        record_results_path (str): name to save svg to, eg "results.svg"
         header_style (str): A style to use for headers. See Rich API Styles.
 
     Returns:
@@ -739,7 +741,10 @@ def skim(
         grid.add_row(sum_tab)
     # Weirdly, iteration over list of tabs misses last entry
     grid.add_row(list_of_tabs[-1])
+    console = Console(record=True)
     console.print(Panel(grid, title="skimpy summary", subtitle="End"))
+    if record_results_path is not None:
+        console.save_svg(record_results_path)
     if return_data:
         return json_data
     else:


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -624,3 +624,9 @@ def test_30_running_with_polars():
     pandas_tbl_out = skim(df1.to_pandas(), return_data=True)
     polars_tbl_out = skim_polars(df1, return_data=True)
     assert pandas_tbl_out == polars_tbl_out
+
+
+def text_31_exporting_to_svg(tmp_path):
+    """Export results to a file."""
+    df = generate_test_data()
+    skim(df, record_results_path=tmp_path / "blah.svg")
Repository: pwndbg/pwndbg

Issue:
source code section unavailable if current line is in the first chunk of the list command
when debugging through code and the current function is indeed one that it at the top of a .c file (that does not use tons of includes) the section is lost because of a too aggressive check:

https://github.com/pwndbg/pwndbg/blob/master/pwndbg/commands/context.py#L160

Which edge-case does that try to solve? As I'm hitting that in several cases, I think it does harm more then it maybe solves something? Would be cool to know which case it does try to fix so we could adjust that check to be less aggressive and preserve the section of the mentioned scenario.



Discussion:
It solves the issue where the current `$PC` is known to be in a file, but does not correspond to any line in the file -- so GDB sets it to the top of the file.

@zachriggle I see, not sure how this could be solved without breaking the above mentioned scenario. Does that happen that often?

I'm not sure, since it hides it when it happens ^_^.

I wouldn't have gone out of my way to add the check if it wasn't affecting me in some way.

What files are you debugging where the first line of source in a file is important (i.e. not a function declaration)?

its nut just about the very first line. the check looks if the first line of the source listing is the first line of the file. that also applies if you break on the first function in a file not having many includes so that the first line of the file is actually included in the listing.
It happens quite often in some of my projects, I noticed it because i tried to break on one of them to debug and did see nothing :sweat_smile: 

It seems the best way to fix this is to check the current line, rather than whether or not the first line appears in the listing.

Would you agree that if the _current_ line is claimed to be Line 1, something is wrong?

This way you can get listings which happen to include Line 1.

@zachriggle yes, i guess that sounds safe to assume and should not happen under normal conditions

PS: should i make a PR?


Resolving patch:
diff --git a/pwndbg/commands/context.py b/pwndbg/commands/context.py
--- a/pwndbg/commands/context.py
+++ b/pwndbg/commands/context.py
@@ -157,7 +157,7 @@ def context_source():
 
         # If it starts on line 1, it's not really using the
         # correct source code.
-        if not source or source.startswith('1\t'):
+        if not source or closest_line <= 1:
             return []
 
         banner = [pwndbg.color.blue(pwndbg.ui.banner("code"))]


Test patch:
Repository: pwndbg/pwndbg

Issue:
Error in the `search` command
The `search` command appears to have some issues while searching signed integer data  
For example while debugging a x86 program:

```
pwndbg> search -4 0xf7eebf83
Traceback (most recent call last):
  File "/home/bruce30262/pwndbg/pwndbg/commands/__init__.py", line 57, in __call__
    return self.function(*args, **kwargs)
  File "/home/bruce30262/pwndbg/pwndbg/commands/__init__.py", line 162, in _ArgparsedCommand
    return function(**vars(args))
  File "/home/bruce30262/pwndbg/pwndbg/commands/__init__.py", line 115, in _OnlyWhenRunning
    return function(*a, **kw)
  File "/home/bruce30262/pwndbg/pwndbg/commands/search.py", line 112, in search
    value = struct.pack(fmt, value)
struct.error: argument out of range
```

This is because `pwndbg.commands.fix_int(value)` returns `-135348349` instead of an unsigned integer, and the packing format in [search.py](https://github.com/pwndbg/pwndbg/blob/b1892b27741a478cd5361061b0b4dda9ef46d02e/pwndbg/commands/search.py#L106) only support the unsigned data type, causing the error.  
Commands like  `search -4 -- -100` will also cause the same error.  
Kind of curious why it only support the unsigned data type though. It might need some additional check for the appropriate packing format.



Discussion:
The unsigned data type is a result of the `inthook` code.  The `command` module takes the `gdb.Value()` that you provide and turns it into an unsigned integer via `.cast()`.

In any case, it looks like the correct course is to mask it against `arch.ptrmask`, e.g.

```
>>> hex(-512 & 0xffffffff)
'0xfffffe00'
```


Resolving patch:
diff --git a/pwndbg/commands/search.py b/pwndbg/commands/search.py
--- a/pwndbg/commands/search.py
+++ b/pwndbg/commands/search.py
@@ -12,6 +12,7 @@
 
 import gdb
 
+import pwndbg.arch
 import pwndbg.color.memory as M
 import pwndbg.commands
 import pwndbg.config
@@ -99,6 +100,7 @@ def search(type, hex, string, executable, writable, value, mapping, save, next):
     # Convert to an integer if needed, and pack to bytes
     if type not in ('string', 'bytes'):
         value = pwndbg.commands.fix_int(value)
+        value &= pwndbg.arch.ptrmask
         fmt = {
             'little': '<',
             'big': '>'


Test patch: