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

Issue:
[config] FilenameAttribute throws exceptions when configuring
https://github.com/sopel-irc/sopel/blob/master/sopel/config/types.py#L314-L340

Serialize and parse require extra arguments that they are not passed during `sopel --configure-modules`



Discussion:

Resolving patch:
diff --git a/sopel/config/types.py b/sopel/config/types.py
--- a/sopel/config/types.py
+++ b/sopel/config/types.py
@@ -92,7 +92,7 @@ def configure_setting(self, name, prompt, default=NO_DEFAULT):
                     default = clazz.default
         while True:
             try:
-                value = clazz.configure(prompt, default)
+                value = clazz.configure(prompt, default, self._parent, self._section_name)
             except ValueError as exc:
                 print(exc)
             else:
@@ -111,7 +111,7 @@ def __init__(self, name, default=None):
         self.name = name
         self.default = default
 
-    def configure(self, prompt, default):
+    def configure(self, prompt, default, parent, section_name):
         """With the prompt and default, parse and return a value from terminal.
         """
         if default is not NO_DEFAULT and default is not None:
@@ -202,7 +202,7 @@ def serialize(self, value):
     def parse(self, value):
         return value
 
-    def configure(self, prompt, default):
+    def configure(self, prompt, default, parent, section_name):
         if self.parse == _parse_boolean:
             prompt += ' (y/n)'
             default = 'y' if default else 'n'
@@ -233,7 +233,7 @@ def serialize(self, value):
             raise ValueError('ListAttribute value must be a list.')
         return ','.join(value)
 
-    def configure(self, prompt, default):
+    def configure(self, prompt, default, parent, section_name):
         each_prompt = '?'
         if isinstance(prompt, tuple):
             each_prompt = prompt[1]
@@ -311,6 +311,17 @@ def __set__(self, instance, value):
         value = self.serialize(main_config, this_section, value)
         instance._parser.set(instance._section_name, self.name, value)
 
+    def configure(self, prompt, default, parent, section_name):
+        """With the prompt and default, parse and return a value from terminal.
+        """
+        if default is not NO_DEFAULT and default is not None:
+            prompt = '{} [{}]'.format(prompt, default)
+        value = get_input(prompt + ' ')
+        if not value and default is NO_DEFAULT:
+            raise ValueError("You must provide a value for this option.")
+        value = value or default
+        return self.parse(parent, section_name, value)
+
     def parse(self, main_config, this_section, value):
         if value is None:
             return


Test patch:
Repository: sopel-irc/sopel

Issue:
MeetBot .startmeeting error
When I type .startmeeting I get this error
/usr/local/lib/python2.7/dist-packages/sopel/config/**init**.py", line 168, in **getattr**)
Running on OSX 10.11 

any ideas 
thank you 



Discussion:

Resolving patch:
diff --git a/sopel/modules/meetbot.py b/sopel/modules/meetbot.py
--- a/sopel/modules/meetbot.py
+++ b/sopel/modules/meetbot.py
@@ -156,9 +156,6 @@ def startmeeting(bot, trigger):
     if trigger.is_privmsg:
         bot.say('Can only start meetings in channels')
         return
-    if not bot.config.has_section('meetbot'):
-        bot.say('Meetbot not configured, make sure meeting_log_path and meeting_log_baseurl are defined')
-        return
     #Start the meeting
     meetings_dict[trigger.sender]['start'] = time.time()
     if not trigger.group(2):


Test patch:
Repository: sopel-irc/sopel

Issue:
.ip socket.gaierror on Sopel 6.1.1 on python 3.5.0
OS X 11.10

``` python
WARNING:sopel.modules.ip:Downloading GeoIP database
Traceback (most recent call last):
  File "/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/sopel/bot.py", line 260, in call
    exit_code = func(sopel, trigger)
  File "/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/sopel/modules/ip.py", line 118, in ip
    response += " | Location: %s" % gi_city.country_name_by_name(query)
  File "/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/pygeoip/__init__.py", line 502, in country_name_by_name
    addr = self._gethostbyname(hostname)
  File "/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/pygeoip/__init__.py", line 394, in _gethostbyname
    return socket.gethostbyname(hostname)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/sopel/bot.py:263: ResourceWarning: unclosed file <_io.BufferedReader name='/Users/thill/.sopel/GeoLiteCity.dat'>
  self.error(trigger)
/Users/thill/projects/python/orcabot/venv_orcabot/lib/python3.5/site-packages/sopel/bot.py:263: ResourceWarning: unclosed file <_io.BufferedReader name='/Users/thill/.sopel/GeoIPASNum.dat'>
  self.error(trigger)
```



Discussion:
Can you provide the ip/hostname you tried to use with .ip ?

`19:49 -!- Phrohdoh [~Phrohdoh@pool-71-96-95-47.dllstx.fios.verizon.net]`

Eh? You mean you did `.ip pool-71-96-95-47.dllstx.fios.verizon.net` right?

Hmm nope, so I bet that's the issue.
`.ip Phrohdoh`

Yeah. .ip requires a valid hostname or IP. It doesn't work with arbitrary strings or nicknames. I guess that the error could be masked better though.

Closing as incorrect usage of a command.


Resolving patch:
diff --git a/sopel/modules/ip.py b/sopel/modules/ip.py
--- a/sopel/modules/ip.py
+++ b/sopel/modules/ip.py
@@ -118,6 +118,8 @@ def ip(bot, trigger):
         response += " | Location: %s" % gi_city.country_name_by_name(query)
     except AttributeError:
         response += ' | Location: Unknown'
+    except socket.gaierror:
+        return bot.say('[IP/Host Lookup] Unable to resolve IP/Hostname')
 
     region_data = gi_city.region_by_name(query)
     try:


Test patch:
Repository: sopel-irc/sopel

Issue:
Problem in (at least) Wikipedia module: possibly Unicode related
Hi,
observe the following use case:
    https://en.wikipedia.org/wiki/Hir%C5%8D_Onoda
    @willie_5.4.1 KeyError: u'extract' (file "/usr/local/lib/python2.7/dist-packages/willie-5.4.1-py2.7.egg/willie/modules/wikipedia.py", line 89, in mw_snippet)



Discussion:
I can't reproduce this with the latest master branch, though I do see it in 5.3. I think we've seen this before, though. We really need some functional tests on this… Can you verify if it's still an issue for you?

Related to these old issues?
https://github.com/sopel-irc/sopel/issues/768
https://github.com/sopel-irc/sopel/issues/800
https://github.com/sopel-irc/sopel/issues/856

No. Those issues are only related to chanlogs, and are an entirely different error.

OK and thanks.

This issue is still present with 6.0.0b0.

```
16:39:15 <benpro> .version                                                                                                             
16:39:15 <Ika-chan> benpro: Sopel v. 6.0.0b0                                                                                           
16:39:19 <benpro> https://fr.wikipedia.org/wiki/Wikip%C3%A9dia_en_fran%C3%A7ais                                                        
16:39:19 <Ika-chan> KeyError: u'extract' (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/wikipedia.py", line 91, in        
                    mw_snippet)                                                                                                        
16:39:27 <benpro> https://en.wikipedia.org/wiki/French_Wikipedia                                                                       
16:39:27 <Ika-chan> [WIKIPEDIA] French Wikipedia | "The French Wikipedia (French: Wikipédia francophone, Wikipédia en français) is the 
                    French-language edition of the free online encyclopedia Wikipedia. This edition was started in March 2001, and has 
                    about 1,654,000 articles as of August 2015, making it the fifth-largest Wikipedia overall, after the English..."   
```


Resolving patch:
diff --git a/sopel/modules/wikipedia.py b/sopel/modules/wikipedia.py
--- a/sopel/modules/wikipedia.py
+++ b/sopel/modules/wikipedia.py
@@ -15,7 +15,8 @@
 
 import sys
 if sys.version_info.major < 3:
-    from urlparse import unquote
+    from urlparse import unquote as _unquote
+    unquote = lambda s: _unquote(s.encode('utf-8')).decode('utf-8')
 else:
     from urllib.parse import unquote
 


Test patch:
Repository: sopel-irc/sopel

Issue:
AttributeError: 'NoneType' object has no attribute 'strip' (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/unicode_info.py", line 23, in codepoint)
[01:04am] <Ant> .u
01:04AM <Sopel> AttributeError: 'NoneType' object has no attribute 'strip' (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/unicode_info.py", line 23, in codepoint)
01:04AM <Sopel> Ant: Sopel v. 6.1.1

This is in my Debian oldstable with Python v2.7.3. :(

AttributeError: 'NoneType' object has no attribute 'strip' (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/unicode_info.py", line 23, in codepoint)
[01:04am] <Ant> .u
01:04AM <Sopel> AttributeError: 'NoneType' object has no attribute 'strip' (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/unicode_info.py", line 23, in codepoint)
01:04AM <Sopel> Ant: Sopel v. 6.1.1

This is in my Debian oldstable with Python v2.7.3. :(



Discussion:
Ugh, force-push pollution. But that should keep it from spewing.

Ugh, force-push pollution. But that should keep it from spewing.


Resolving patch:
diff --git a/sopel/modules/unicode_info.py b/sopel/modules/unicode_info.py
--- a/sopel/modules/unicode_info.py
+++ b/sopel/modules/unicode_info.py
@@ -16,11 +16,14 @@
 @example('.u ‽', 'U+203D INTERROBANG (‽)')
 @example('.u 203D', 'U+203D INTERROBANG (‽)')
 def codepoint(bot, trigger):
-    arg = trigger.group(2).strip()
-    if len(arg) == 0:
+    arg = trigger.group(2)
+    if not arg:
         bot.reply('What code point do you want me to look up?')
         return NOLIMIT
-    elif len(arg) > 1:
+    stripped = arg.strip()
+    if len(stripped) > 0:
+        arg = stripped
+    if len(arg) > 1:
         if arg.startswith('U+'):
             arg = arg[2:]
         try:


Test patch:
Repository: sopel-irc/sopel

Issue:
[currency] Currency codes are needlessly case-sensitive
There's no reason that the currency codes should have to be capitalized by the user, is there?

```
[06:03:23] <dgw> ;cur 1 USD in CAD
[06:03:24] <Sopel> 1.0 USD (U.S. dollar) = 1.386001386 CAD (Canadian Dollar)
[06:03:28] <dgw> ;cur 1 usd in CAD
[06:03:29] <Sopel> 1.0 usd (U.S. dollar) = 1.386001386 CAD (Canadian Dollar)
[06:03:33] <dgw> ;cur 1 USD in cad
[06:03:34] <Sopel> dgw: Unknown currency: cad
```

If no reason not to do so arises, I'll PR this one myself in a couple days.



Discussion:
Code changes completed, testing. Probably commit & PR tomorrow if I don't find any problems.


Resolving patch:
diff --git a/sopel/modules/currency.py b/sopel/modules/currency.py
--- a/sopel/modules/currency.py
+++ b/sopel/modules/currency.py
@@ -26,9 +26,10 @@
 
 
 def get_rate(code):
-    if code.upper() == 'CAD':
+    code = code.upper()
+    if code == 'CAD':
         return 1, 'Canadian Dollar'
-    elif code.upper() == 'BTC':
+    elif code == 'BTC':
         rates = json.loads(web.get('https://api.bitcoinaverage.com/ticker/all'))
         return 1 / rates['CAD']['24h_avg'], 'Bitcoin—24hr average'
 
@@ -85,8 +86,8 @@ def display(bot, amount, of, to):
         return NOLIMIT
 
     result = amount / of_rate * to_rate
-    bot.say("{} {} ({}) = {} {} ({})".format(amount, of, of_name,
-                                             result, to, to_name))
+    bot.say("{} {} ({}) = {} {} ({})".format(amount, of.upper(), of_name,
+                                             result, to.upper(), to_name))
 
 
 @commands('btc', 'bitcoin')


Test patch:
Repository: sopel-irc/sopel

Issue:
Error in url setup procedure - Bot no longer posts titles of links
Hello. I've actually had this error for awhile and tried fixing it awhile back to no avail so I'm hoping someone here could help. The bot no longer seems to show titles of links posted in the channels and when starting the bot I get:

```
Error in url setup procedure: nothing to repeat (../../../../../lib/python2.7/sre_parse.py:517)
```

Which looking at that file points to this:

```
            if not item or (_len(item) == 1 and item[0][0] == AT):
                raise error, "nothing to repeat"
```

So I'm not sure what to do here.



Discussion:
Do you have an `exclusion_char` or `exclude` set under `[url]` in your config? My first guess is that it's set to something that's messing up the regex. Can you post the full traceback from `exceptions.log`?

Thanks for responding. Yes, I do have both an exclusion_char and an exclude url. 

```
[url]
exclude = https?://example.net/.*
exclusion_char = !
```

The weird thing is nothing shows up in the exceptions.log only when I start up the bot. Even with logging_level to debug no errors show up while running and nothing in the exceptions log, only the very first error at the beginning when the bot is initially ran.


Resolving patch:
diff --git a/sopel/modules/url.py b/sopel/modules/url.py
--- a/sopel/modules/url.py
+++ b/sopel/modules/url.py
@@ -10,7 +10,7 @@
 import re
 from sopel import web, tools
 from sopel.module import commands, rule, example
-from sopel.config.types import ValidatedAttribute, StaticSection
+from sopel.config.types import ValidatedAttribute, ListAttribute, StaticSection
 
 
 url_finder = None
@@ -29,7 +29,7 @@
 
 class UrlSection(StaticSection):
     # TODO some validation rules maybe?
-    exclude = ValidatedAttribute('exclude')
+    exclude = ListAttribute('exclude')
     exclusion_char = ValidatedAttribute('exclusion_char', default='!')
 
 


Test patch:
Repository: sopel-irc/sopel

Issue:
KeyError trying to reload a system module name
`KeyError: 'time' (file "/opt/rh/python33/root/usr/lib/python3.3/site-packages/sopel/modules/reload.py", line 62, in f_reload)` should be a sane error message



Discussion:

Resolving patch:
diff --git a/sopel/modules/reload.py b/sopel/modules/reload.py
--- a/sopel/modules/reload.py
+++ b/sopel/modules/reload.py
@@ -40,7 +40,7 @@ def f_reload(bot, trigger):
         return bot.reply('done')
 
     if name not in sys.modules:
-        return bot.reply('%s: not loaded, try the `load` command' % name)
+        return bot.reply('"%s" not loaded, try the `load` command' % name)
 
     old_module = sys.modules[name]
 
@@ -59,6 +59,8 @@ def f_reload(bot, trigger):
         delattr(old_module, "setup")
 
     modules = sopel.loader.enumerate_modules(bot.config)
+    if name not in modules:
+        return bot.reply('"%s" not loaded, try the `load` command' % name)
     path, type_ = modules[name]
     load_module(bot, name, path, type_)
 


Test patch:
Repository: sopel-irc/sopel

Issue:
Add time of message to trigger object
The time should be whenever we get the message, unless it included [`server-time`](http://ircv3.net/specs/extensions/server-time-3.2.html). The `server-time` CAP should be enabled by default.



Discussion:

Resolving patch:
diff --git a/sopel/coretasks.py b/sopel/coretasks.py
--- a/sopel/coretasks.py
+++ b/sopel/coretasks.py
@@ -423,7 +423,7 @@ def recieve_cap_ls_reply(bot, trigger):
 
     # If some other module requests it, we don't need to add another request.
     # If some other module prohibits it, we shouldn't request it.
-    core_caps = ['multi-prefix', 'away-notify', 'cap-notify']
+    core_caps = ['multi-prefix', 'away-notify', 'cap-notify', 'server-time']
     for cap in core_caps:
         if cap not in bot._cap_reqs:
             bot._cap_reqs[cap] = [_CapReq('', 'coretasks')]
diff --git a/sopel/trigger.py b/sopel/trigger.py
--- a/sopel/trigger.py
+++ b/sopel/trigger.py
@@ -3,6 +3,7 @@
 
 import re
 import sys
+import datetime
 
 import sopel.tools
 
@@ -34,6 +35,13 @@ def __init__(self, own_nick, line):
                 else:
                     self.tags[tag[0]] = None
 
+        self.time = datetime.datetime.utcnow()
+        if 'time' in self.tags:
+            try:
+                self.time = datetime.datetime.strptime(self.tags['time'], '%Y-%m-%dT%H:%M:%S.%fZ')
+            except ValueError:
+                pass # Server isn't conforming to spec, ignore the server-time
+
         # TODO note what this is doing and why
         if line.startswith(':'):
             self.hostmask, line = line[1:].split(' ', 1)
@@ -87,6 +95,11 @@ class Trigger(unicode):
     """The channel from which the message was sent.
 
     In a private message, this is the nick that sent the message."""
+    time = property(lambda self: self._pretrigger.time)
+    """A datetime object at which the message was received by the IRC server.
+
+    If the server does not support server-time, then `time` will be the time
+    that the message was received by Sopel"""
     raw = property(lambda self: self._pretrigger.line)
     """The entire message, as sent from the server. This includes the CTCP
     \\x01 bytes and command, if they were included."""


Test patch:
Repository: sopel-irc/sopel

Issue:
Python 3 incompatibility bug? TypeError: can't concat bytes to str
Using the admin module quit command running sopel on archlinux with python 3.5:

> ERROR:sopel.modules.sopel.irc:ERROR recieved from server: Closing Link: mechasqueak-test[p200300630A2FCF79AE220BFFFE4D6336.dip0.t-ipconnect.de](Quit: Quitting on command from DukeOfEarl)
> Calling shutdown for 0 modules.
> Closed!
> Traceback (most recent call last):
>   File "/usr/lib64/python3.5/asyncore.py", line 83, in read
>     obj.handle_read_event()
>   File "/usr/lib64/python3.5/asyncore.py", line 423, in handle_read_event
>     self.handle_read()
>   File "/usr/lib64/python3.5/asynchat.py", line 126, in handle_read
>     self.ac_in_buffer = self.ac_in_buffer + data
> TypeError: can't concat bytes to str
> 
> ERROR:sopel.modules.sopel.irc:Fatal error in core, please review exception log

It seems there's a `decode()` missing.



Discussion:
Hm, idk where that could be that it would blow up like that. There doesn't seem to be anything egregious wrong with that command…


Resolving patch:
diff --git a/sopel/irc.py b/sopel/irc.py
--- a/sopel/irc.py
+++ b/sopel/irc.py
@@ -310,7 +310,7 @@ def _ssl_recv(self, buffer_size):
             data = self.socket.read(buffer_size)
             if not data:
                 self.handle_close()
-                return ''
+                return b''
             return data
         except ssl.SSLError as why:
             if why[0] in (asyncore.ECONNRESET, asyncore.ENOTCONN,
@@ -319,7 +319,7 @@ def _ssl_recv(self, buffer_size):
                 return ''
             elif why[0] == errno.ENOENT:
                 # Required in order to keep it non-blocking
-                return ''
+                return b''
             else:
                 raise
 


Test patch:
Repository: sopel-irc/sopel

Issue:
url: UnicodeEncodeError
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 352:    | ordinal not in range(128) (file "/usr/local/lib/python2.7/dist-packages/sopel/modules/url.py", line | 191, in find_title)  

https://github.com/sopel-irc/sopel/blob/master/sopel/modules/url.py#L191



Discussion:
I also encountered this but with \u2019 (right single quotation mark).

I guess I didn't test this enough on python 2.7

People should really be switching to 3 though!


Resolving patch:
diff --git a/sopel/modules/url.py b/sopel/modules/url.py
--- a/sopel/modules/url.py
+++ b/sopel/modules/url.py
@@ -188,7 +188,10 @@ def find_title(url):
     try:
         content = ''
         for byte in response.iter_content(chunk_size=512, decode_unicode=True):
-            content += str(byte)
+            if not isinstance(byte, bytes):
+                content += byte
+            else:
+                break
             if '</title>' in content or len(content) > max_bytes:
                 break
     except UnicodeDecodeError:


Test patch:
Repository: sopel-irc/sopel

Issue:
[announce] Send confirmation to caller after all channels announced
When Sopel is in many channels, announces are likely to be rate-limited. This makes it hard to know, for example, when it's safe to shut down the bot if announce is being used to broadcast an upgrade notice.

It's an easy fix, and I'll open a PR for it tomorrow if there are no objections.

I am as-yet undecided whether it's best to use `bot.reply()` or `bot.notice()` for this (or even `bot.msg()` via PM to the caller), but I'll think about it between now and when I open the PR, and it can always be changed before merging.



Discussion:

Resolving patch:
diff --git a/sopel/modules/announce.py b/sopel/modules/announce.py
--- a/sopel/modules/announce.py
+++ b/sopel/modules/announce.py
@@ -21,3 +21,4 @@ def announce(bot, trigger):
         return
     for channel in bot.channels:
         bot.msg(channel, '[ANNOUNCEMENT] %s' % trigger.group(2))
+    bot.reply('Announce complete.')


Test patch:
Repository: sopel-irc/sopel

Issue:
web: broken header behavior
Yes, I know its deprecated, I'm going to fix it anyways.

headers bleed between web requests because we're using `update` on `default_headers`.

``` python
web.get('http://google.com/')
# Headers: User-Agent: Sopel/6.3.1 (http://sopel.chat)
web.get('http://google.com/', headers={'some-header': 'value'})
# Headers: User-Agent: Sopel/6.3.1 (http://sopel.chat), some-header: value
web.get('http://google.com/')
# Headers: User-Agent: Sopel/6.3.1 (http://sopel.chat), some-header: value
```



Discussion:

Resolving patch:
diff --git a/sopel/web.py b/sopel/web.py
--- a/sopel/web.py
+++ b/sopel/web.py
@@ -86,7 +86,8 @@ def get(uri, timeout=20, headers=None, return_headers=False,
     if headers is None:
         headers = default_headers
     else:
-        headers = default_headers.update(headers)
+        tmp = default_headers.copy()
+        headers = tmp.update(headers)
     u = requests.get(uri, timeout=timeout, headers=headers, verify=verify_ssl)
     bytes = u.content
     u.close()
@@ -115,7 +116,8 @@ def head(uri, timeout=20, headers=None, verify_ssl=True):
     if headers is None:
         headers = default_headers
     else:
-        headers = default_headers.update(headers)
+        tmp = default_headers.copy()
+        headers = tmp.update(headers)
     u = requests.get(uri, timeout=timeout, headers=headers, verify=verify_ssl)
     info = u.headers
     u.close()
@@ -175,7 +177,8 @@ def get_urllib_object(uri, timeout, headers=None, verify_ssl=True, data=None):
     if headers is None:
         headers = default_headers
     else:
-        headers = default_headers.update(headers)
+        tmp = default_headers.copy()
+        headers = tmp.update(headers)
     if data is not None:
         response = requests.post(uri, timeout=timeout, verify=verify_ssl,
                                  data=data, headers=headers)


Test patch:
Repository: sopel-irc/sopel

Issue:
module: require_privilege raises exception function called in privmsg
If privmsg, require_privilege should allow the function to continue rather than raising an exception.



Discussion:

Resolving patch:
diff --git a/sopel/module.py b/sopel/module.py
--- a/sopel/module.py
+++ b/sopel/module.py
@@ -320,6 +320,9 @@ def require_privilege(level, message=None):
     def actual_decorator(function):
         @functools.wraps(function)
         def guarded(bot, trigger, *args, **kwargs):
+            # If this is a privmsg, ignore privilege requirements
+            if trigger.is_privmsg:
+                return function(bot, trigger, *args, **kwargs)
             channel_privs = bot.privileges[trigger.sender]
             allowed = channel_privs.get(trigger.nick, 0) >= level
             if not trigger.is_privmsg and not allowed:


Test patch: