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

Issue:
When joining a chan, [chan] [chan] is added
This is a minor issue, but...

Then I join a chan, it's name is added to the identities as "[chan] channame". But when it's added to the addressbook, it has label "[chan] [chan] channame". The label can be changed manually, but it's annoying :)



Discussion:

Resolving patch:
diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -1090,7 +1090,7 @@ def click_actionJoinChan(self):
                         "MainWindow", "Could not add chan because it appears to already be one of your identities."))
                     return
                 createdAddress = addressGeneratorReturnValue[0]
-                self.addEntryToAddressBook(createdAddress, self.str_chan + ' ' + self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameJoin.text()))
+                self.addEntryToAddressBook(createdAddress, self.str_chan + ' ' + str(self.newChanDialogInstance.ui.lineEditChanNameJoin.text()))
                 QMessageBox.about(self, _translate("MainWindow", "Success"), _translate(
                     "MainWindow", "Successfully joined chan. "))
                 self.ui.tabWidget.setCurrentIndex(3)


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Small bug in tr.py
In tr.py is line 24 an os.exit() command.

But os is not imported in this file!



Discussion:

Resolving patch:
diff --git a/src/tr.py b/src/tr.py
--- a/src/tr.py
+++ b/src/tr.py
@@ -1,4 +1,5 @@
 import shared
+import os
 
 # This is used so that the translateText function can be used when we are in daemon mode and not using any QT functions.
 class translateClass:


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
duplicate lines
in defaultKnownNodes.py lines 16 and 21



Discussion:
Actually I realized that out of all the nodes listed only 176.31.246.114 is the active one.
If you comment out the two lines with 176.31.246.114, then BM falls back to DNS bootstrap.


Resolving patch:
diff --git a/src/defaultKnownNodes.py b/src/defaultKnownNodes.py
--- a/src/defaultKnownNodes.py
+++ b/src/defaultKnownNodes.py
@@ -11,19 +11,16 @@ def createDefaultKnownNodes(appdata):
     ############## Stream 1 ################
     stream1 = {}
 
-    stream1[shared.Peer('98.233.84.134', 8444)] = int(time.time())
-    stream1[shared.Peer('76.24.18.44', 8444)] = int(time.time())
     stream1[shared.Peer('176.31.246.114', 8444)] = int(time.time())
-    stream1[shared.Peer('66.108.210.240', 8080)] = int(time.time())
-    stream1[shared.Peer('76.22.240.163', 8445)] = int(time.time())
-    stream1[shared.Peer('46.21.99.29', 20982)] = int(time.time())
-    stream1[shared.Peer('109.227.72.36', 8444)] = int(time.time())
-    stream1[shared.Peer('176.31.246.114', 8444)] = int(time.time())
-    stream1[shared.Peer('188.110.3.133', 8444)] = int(time.time())
-    stream1[shared.Peer('174.0.45.163', 8444)] = int(time.time())
-    stream1[shared.Peer('134.2.182.92', 8444)] = int(time.time())
-    stream1[shared.Peer('24.143.60.183', 8444)] = int(time.time())
-
+    stream1[shared.Peer('109.229.197.133', 8444)] = int(time.time())
+    stream1[shared.Peer('174.3.101.111', 8444)] = int(time.time())
+    stream1[shared.Peer('90.188.238.79', 7829)] = int(time.time())
+    stream1[shared.Peer('184.75.69.2', 8444)] = int(time.time())
+    stream1[shared.Peer('60.225.209.243', 8444)] = int(time.time())
+    stream1[shared.Peer('5.145.140.218', 8444)] = int(time.time())
+    stream1[shared.Peer('5.19.255.216', 8444)] = int(time.time())
+    stream1[shared.Peer('193.159.162.189', 8444)] = int(time.time())
+    stream1[shared.Peer('86.26.15.171', 8444)] = int(time.time())
 
     ############# Stream 2 #################
     stream2 = {}


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
"View HTML code as formated text", problem with non-Latin symbols
I got this message, full of Cyrillic characters:

> Тост тест туст

After clicking "View HTML code as formated text" it became unreadable:

> Ð¢Ð¾ÑÑ ÑÐµÑÑ ÑÑÑÑ

It looks to me like raw and formated views use different encodings to show the text.



Discussion:
+1

Sounds like a Qt bug or misconfiguration.

It looks like QtWebKit (or other Qt component - dunno) interprets text as encoded in ISO 8859-1, rather than UTF-8. Probably it's some default inside Qt that needs to be changed/configured - note the issue is not Russian specific. Most likely any text with non-latin characters will be interpreted in wrong way.


Resolving patch:
diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -2583,19 +2583,22 @@ def on_action_InboxMessageForceHtml(self):
             '''select message from inbox where msgid=?''', msgid)
         if queryreturn != []:
             for row in queryreturn:
-                messageAtCurrentInboxRow, = row 
+                messageText, = row
 
-        lines = messageAtCurrentInboxRow.split('\n')
-        for i in xrange(len(lines)):
+        lines = messageText.split('\n')
+        totalLines = len(lines)
+        for i in xrange(totalLines):
             if 'Message ostensibly from ' in lines[i]:
                 lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
                     lines[i])
             elif lines[i] == '------------------------------------------------------':
                 lines[i] = '<hr>'
-        content = ''
-        for i in xrange(len(lines)):
-            content += lines[i]
-        content = content.replace('\n\n', '<br><br>')
+            elif lines[i] == '' and (i+1) < totalLines and \
+                 lines[i+1] != '------------------------------------------------------':
+                lines[i] = '<br><br>'
+        content = ' '.join(lines) # To keep the whitespace between lines
+        content = shared.fixPotentiallyInvalidUTF8Data(content)
+        content = unicode(content, 'utf-8)')
         self.ui.textEditInboxMessage.setHtml(QtCore.QString(content))
 
     def on_action_InboxMarkUnread(self):


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Trouble sending on multicor machines on 0.4.4
I've seen this on both an OSX box (8 cores) and a linux box (4 cores). I was only able to do the full reproducible on linux, as my `keys.dat` file prevented me from going back to 0.4.3 on the OSX box.
1. Check out v0.4.3.
2. Open top
3. Open bitmessage.
4. Send a message.
5. Processes will start up for each core in top to calculate the PoW more quickly. Message will send.
6. Close bitmessage.
7. Check out `ProtoV3`
8. Send a message.
9. Processes will fire up in top.  They'll consume 100% cpu for a few minutes. One by one, the CPU usage on each process will drop to zero.
10. The bitmessage app will still say that we're doing work to calculate the PoW. The message never sends.



Discussion:

Resolving patch:
diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py
--- a/src/bitmessagemain.py
+++ b/src/bitmessagemain.py
@@ -172,7 +172,6 @@ def start(self, daemon=False):
             curses = True
 
         signal.signal(signal.SIGINT, helper_generic.signal_handler)
-        signal.signal(signal.SIGTERM, helper_generic.signal_handler)
         # signal.signal(signal.SIGINT, signal.SIG_DFL)
 
         helper_bootstrap.knownNodes()


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
We don't always find translations because of relative path lookup
This fails:

```
grant@johnicicleboy:~/src/PyBitmessage$ LANG=fr_BE.UTF-8 python bitmessagemain.py
```

This works:

```
grant@johnicicleboy:~/src/PyBitmessage/src$ LANG=fr_BE.UTF-8 python bitmessagemain.py
```

Because we use a relative path to lookup the translation files in `bitmessageqt/__init__.py` instead of determining the absolute path of the application and going from there.

Same root problem as #379



Discussion:

Resolving patch:
diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -3852,7 +3852,7 @@ def run():
     translator = QtCore.QTranslator()
     
     translationpath = os.path.join(
-        getattr(sys, '_MEIPASS', ''),
+        getattr(sys, '_MEIPASS', sys.path[0]),
         'translations',
         'bitmessage_' + l10n.getTranslationLanguage()
     )


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
GUI in both french and english
The GUI is in both in french and english but for the same message, it's not like the message isn't in the french translation files. The behavior of switching from a language to another is random!
![capture](https://f.cloud.github.com/assets/367844/1649926/c4094920-5a43-11e3-85d1-c1855fe84c89.png)



Discussion:
Translation occurs when the string is used by the app. But strings, previously displayed in tables, aren't translated when the language changes.

I think the fix would be to also refresh all tables when the language changes. State of the tables (selections,sort column and order) should  be preserved.

It still occurs with new messages I guess. Is there a weanup to cleanup the old tables and refresh it ?

Changing the language requires a restart. I assumed that that would be obvious when nothing changes immediately after changing the language.


Resolving patch:
diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -154,6 +154,17 @@ def avatarize(address):
             return idcon
     # If no avatar is found
     return identiconize(address)
+    
+def change_translation(locale):
+    global qtranslator
+    qtranslator = QtCore.QTranslator()
+    translationpath = os.path.join(
+        getattr(sys, '_MEIPASS', sys.path[0]),
+        'translations',
+        'bitmessage_' + locale
+    )
+    qtranslator.load(translationpath)
+    QtGui.QApplication.installTranslator(qtranslator)
 
 
 class MyForm(QtGui.QMainWindow):
@@ -1431,6 +1442,8 @@ def openKeysFile(self):
             os.startfile(shared.appdata + 'keys.dat')
 
     def changeEvent(self, event):
+        if event.type() == QtCore.QEvent.LanguageChange:
+            self.ui.retranslateUi(self)
         if event.type() == QtCore.QEvent.WindowStateChange:
             if self.windowState() & QtCore.Qt.WindowMinimized:
                 self.actionShow.setChecked(False)
@@ -2287,6 +2300,7 @@ def click_actionSettings(self):
             lang_ind = int(self.settingsDialogInstance.ui.languageComboBox.currentIndex())
             if not languages[lang_ind] == 'other':
                 shared.config.set('bitmessagesettings', 'userlocale', languages[lang_ind])
+                change_translation(languages[lang_ind])
             
             if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
                 if not shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
@@ -3849,16 +3863,7 @@ def run(self):
 
 def run():
     app = QtGui.QApplication(sys.argv)
-    translator = QtCore.QTranslator()
-    
-    translationpath = os.path.join(
-        getattr(sys, '_MEIPASS', sys.path[0]),
-        'translations',
-        'bitmessage_' + l10n.getTranslationLanguage()
-    )
-    translator.load(translationpath)
-
-    QtGui.QApplication.installTranslator(translator)
+    change_translation(l10n.getTranslationLanguage())
     app.setStyleSheet("QStatusBar::item { border: 0px solid black }")
     myapp = MyForm()
 


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
French time format is wrong: 12-hours without AM/PM instead of 24-hours
I have something like (with the af0dfdc version on fedora 23 and the french language) :
- _jeu., 03 juin 2016 **01:45**_, instead of 
- _jeu., 03 juin 2016 **13:45**_.

Apparently I have the 12-hours format without the AM/PM indication, so morning and afternoon cannot even be discriminated…



Discussion:
Hello, you can configure the time format manually in the config file keys.dat, the variable name is "timeformat". Just watch out because you have to escape % with %, so it's slightly different than strftime. In your case, just replace

```
%%I
```

with

```
%%H
```

Unfortunately, as far as I know, there is no way to configure it in the GUI.

Thanks @PeterSurda, it works.

For the french locale (and others) %p in strftime is empty or a single space. The absence of AM/PM for some locales is correct as 24 hour time is usually the norm and sometimes there is no one-to-one equivalent for "am" or "pm".
The default setting for timeformat during creation of keys.dat should be changed to simply %c for the better supported locale-specific datetime representation. The current default setting is unusual in some locales.


Resolving patch:
diff --git a/src/helper_startup.py b/src/helper_startup.py
--- a/src/helper_startup.py
+++ b/src/helper_startup.py
@@ -60,7 +60,7 @@ def loadConfig():
         shared.config.set('bitmessagesettings', 'settingsversion', '10')
         shared.config.set('bitmessagesettings', 'port', '8444')
         shared.config.set(
-            'bitmessagesettings', 'timeformat', '%%a, %%d %%b %%Y  %%I:%%M %%p')
+            'bitmessagesettings', 'timeformat', '%%c')
         shared.config.set('bitmessagesettings', 'blackwhitelist', 'black')
         shared.config.set('bitmessagesettings', 'startonlogon', 'false')
         if 'linux' in sys.platform:


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Label unicode bug
Arrived in bitmessage chan.

> Got to Messages tab, double click address, enter name/label/alias:
> 
> Traceback (most recent call last):
>   File
> "/usr/local/lib/python2.7/dist-packages/pybitmessage/bitmessageqt/foldertree.py",
> line 237, in setData
>     if isinstance(value, QtCore.QVariant) else str(value)
> AttributeError: 'str' object has no attribute 'toString'
> 
> 
> diff --git a/src/bitmessageqt/foldertree.py
> b/src/bitmessageqt/foldertree.py
> index f3ac38d..48c32eb 100644
> --- a/src/bitmessageqt/foldertree.py
> +++ b/src/bitmessageqt/foldertree.py
> @@ -233,7 +233,7 @@ class Ui_AddressWidget(BMTreeWidgetItem,
> SettingsMixin):
>                  and self.type != AccountMixin.SUBSCRIPTION:
>              BMConfigParser().set(
>                  str(self.address), 'label',
> -                str(value).toString().toUtf8()
> +                str(value.toString().toUtf8())
>                  if isinstance(value, QtCore.QVariant) else
> str(value)
>              )
>              BMConfigParser().save()
> 
> 
> ------------------------------------------------------
> Not sure what you mean by aliases.
> 
> Peter Surda
> Bitmessage core developer
> 
> > Hello, I can't seem to give aliases to any address of mine anymore.
> > 
> > Using latest Pybitmessage from v0.6 branch.
> 




Discussion:

Resolving patch:
diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py
--- a/src/bitmessageqt/foldertree.py
+++ b/src/bitmessageqt/foldertree.py
@@ -233,8 +233,9 @@ def setData(self, column, role, value):
                 and self.type != AccountMixin.SUBSCRIPTION:
             BMConfigParser().set(
                 str(self.address), 'label',
-                str(value).toString().toUtf8()
-                if isinstance(value, QtCore.QVariant) else str(value)
+                str(value.toString().toUtf8())
+                if isinstance(value, QtCore.QVariant)
+                else value.encode('utf-8')
             )
             BMConfigParser().save()
         return super(Ui_AddressWidget, self).setData(column, role, value)


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
checkdeps.py broken
```
Traceback (most recent call last):
  File "checkdeps.py", line 142, in <module>
    if x in EXTRAS_REQUIRE_DEPS
KeyError: None
```


Discussion:

Resolving patch:
diff --git a/src/depends.py b/src/depends.py
--- a/src/depends.py
+++ b/src/depends.py
@@ -137,7 +137,7 @@ def detectOSRelease():
         for line in osRelease:
             if line.startswith("NAME="):
                 detectOS.result = OS_RELEASE.get(
-                    line.split("=")[-1].strip().lower())
+                    line.replace('"', '').split("=")[-1].strip().lower())
             elif line.startswith("VERSION_ID="):
                 try:
                     version = float(line.split("=")[1].replace("\"", ""))


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Crashing on Boot
$ python src/bitmessagemain.py 
Loading existing config files from /home/.config/PyBitmessage/
2018-08-05 13:19:02,170 - WARNING - Using default logger configuration
2018-08-05 13:19:02,592 - CRITICAL - Unhandled exception
Traceback (most recent call last):
  File "src/bitmessagemain.py", line 507, in <module>
  File "src/bitmessagemain.py", line 503, in main
  File "src/bitmessagemain.py", line 276, in start
  File "PyBitmessage/src/knownnodes.py", line 100, in readKnownNodes
    pickle_deserialize_old_knownnodes(source)
  File "PyBitmessage/src/knownnodes.py", line 63, in pickle_deserialize_old_knownnodes
    knownNodes = pickle.load(source)
  File "/usr/lib/python2.7/pickle.py", line 1384, in load
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 864, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 886, in load_eof
    raise EOFError
EOFError
Cleaning up lockfile



Discussion:

Resolving patch:
diff --git a/src/knownnodes.py b/src/knownnodes.py
--- a/src/knownnodes.py
+++ b/src/knownnodes.py
@@ -98,7 +98,7 @@ def readKnownNodes():
                 except ValueError:
                     source.seek(0)
                     pickle_deserialize_old_knownnodes(source)
-    except (IOError, OSError, KeyError):
+    except (IOError, OSError, KeyError, EOFError):
         logger.debug(
             'Failed to read nodes from knownnodes.dat', exc_info=True)
         createDefaultKnownNodes()


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
daemon = true in keys.dat doesn't work
Probably some of the recent changes broke it. I don't have time to debug, but the symptom is that with `daemon = true` and pyqt absent in the system, upon launch it will complain that pyqt is missing and refuse to start. When run with `-d`, it's fine. Latest `v0.6`. It worked correctly in the past.

I saw reports about this in the chan, but I thought they don't know how to use it because it wasn't described very well. I had to run a daemon on one of my systems, and turned out that after doing a pull, it broke. Now I think that they were describing the problems I encountered.


Discussion:
I cannot reproduce it with 58bc170 ):
Is pyqt installed?
Oh, it was a problem with my portage. I had actually `PyQt4` installed (:
[problem source](../blob/v0.6/src/bitmessagemain.py#L184) - it should be below, under `if daemon:`
It's probably very old issue
It worked in May

Resolving patch:
diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py
--- a/src/bitmessagemain.py
+++ b/src/bitmessagemain.py
@@ -181,7 +181,6 @@ def start(self):
                 sys.exit()
             elif opt in ("-d", "--daemon"):
                 daemon = True
-                state.enableGUI = False  # run without a UI
             elif opt in ("-c", "--curses"):
                 state.curses = True
             elif opt in ("-t", "--test"):
@@ -205,7 +204,9 @@ def start(self):
                     os.path.join(app_dir, 'tests', 'apinotify_handler.py')
                 )
 
-        # is the application already running?  If yes then exit.
+        if daemon:
+            state.enableGUI = False  # run without a UI
+
         if state.enableGUI and not state.curses and not depends.check_pyqt():
             sys.exit(
                 'PyBitmessage requires PyQt unless you want'
@@ -219,6 +220,7 @@ def start(self):
                 ' the new curses interface by providing'
                 ' \'-c\' as a commandline argument.'
             )
+        # is the application already running?  If yes then exit.
         shared.thisapp = singleinstance("", daemon)
 
         if daemon:


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Better logging
Using the built-in python logging module I've made various log levels possible and made the creation of a log file a matter of changing the configuration in debug.py. The python logging module is thread-safe so we can safely replace all `print` calls with calls to `logger`. I only replaced some of them mainly to test the configuration (and there are a lot of `print` calls)

There are some commits in my merge that mention translation files, I'm working on that but didn't mean to include them in this merge. I deleted them but the commit history is already there.



Discussion:
Whoa, cool. I literally just sat down to start doing this when I saw your pull request! Thanks for getting this started. LGTM, with inline comments.

This doesn't merge anymore. It would be better to include `debug.py` and incrementally replace `print` with calls to `logger` over time along with other changes rather than in one big commit.


Resolving patch:
diff --git a/checkdeps.py b/checkdeps.py
--- a/checkdeps.py
+++ b/checkdeps.py
@@ -22,7 +22,7 @@
     from setup import EXTRAS_REQUIRE
 except ImportError:
     HAVE_SETUPTOOLS = False
-    EXTRAS_REQUIRE = []
+    EXTRAS_REQUIRE = {}
 
 from importlib import import_module
 


Test patch:
Repository: Bitmessage/PyBitmessage

Issue:
Tooltip sanitisation
Posted in bitmessage chan, easily reproducible.

A tooltip is displayed when mouse cursor is moved over the subject field on the message list.
That tooltip is affected by HTML tags included in the message subject. It should not be intended behavior.
Try on this message's subject that has `<h1>` tag. The subject tooltip will be displayed in large bold font.
It was tested on PyBitmessage 0.6.3.2.


Discussion:

Resolving patch:
diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py
--- a/src/bitmessageqt/foldertree.py
+++ b/src/bitmessageqt/foldertree.py
@@ -4,6 +4,8 @@
 """
 # pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init
 
+from cgi import escape
+
 from PyQt4 import QtCore, QtGui
 
 from bmconfigparser import BMConfigParser
@@ -456,6 +458,8 @@ def data(self, role):
         """Return object data (QT UI)"""
         if role == QtCore.Qt.UserRole:
             return self.subject
+        if role == QtCore.Qt.ToolTipRole:
+            return escape(self.subject)
         return super(MessageList_SubjectWidget, self).data(role)
 
     # label (or address) alphabetically, disabled at the end


Test patch: