We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Multistring doesnt work as a python2 string
Previously you were able to so ~~`str(multistring("foo"))`~~ but it seems this no longer works.

EDIT: apologies that was a bad example it should have read something like `str(multistring("é"))`

Im wondering if we should add py2 compat similar to the one in django (https://docs.djangoproject.com/en/1.9/_modules/django/utils/six/#python_2_unicode_compatible)

@claudep any thoughts on this?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `translate/misc/multistring.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright 2006 Zuza Software Foundation
4 #
5 # This file is part of translate.
6 #
7 # translate is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # translate is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
19 
20 """Supports a hybrid Unicode string that can also have a list of alternate
21 strings in the strings attribute
22 """
23 
24 import six
25 
26 
27 class multistring(six.text_type):
28 
29     def __new__(newtype, string=u"", *args, **kwargs):
30         if isinstance(string, list):
31             if not string:
32                 raise ValueError("multistring must contain at least one string")
33             mainstring = string[0]
34             newstring = multistring.__new__(newtype, string[0])
35             newstring.strings = [newstring] + [multistring.__new__(newtype, altstring) for altstring in string[1:]]
36         else:
37             newstring = six.text_type.__new__(newtype, string)
38             newstring.strings = [newstring]
39         return newstring
40 
41     def __init__(self, *args, **kwargs):
42         super(multistring, self).__init__()
43         if not hasattr(self, "strings"):
44             self.strings = []
45 
46     def __cmp__(self, otherstring):
47         def cmp_compat(s1, s2):
48             # Python 3 compatible cmp() equivalent
49             return (s1 > s2) - (s1 < s2)
50         if isinstance(otherstring, multistring):
51             parentcompare = cmp_compat(six.text_type(self), otherstring)
52             if parentcompare:
53                 return parentcompare
54             else:
55                 return cmp_compat(self.strings[1:], otherstring.strings[1:])
56         elif isinstance(otherstring, six.text_type):
57             return cmp_compat(six.text_type(self), otherstring)
58         elif isinstance(otherstring, bytes):
59             return cmp_compat(self.encode('utf-8'), otherstring)
60         elif isinstance(otherstring, list) and otherstring:
61             return cmp_compat(self, multistring(otherstring))
62         else:
63             return cmp_compat(str(type(self)), str(type(otherstring)))
64 
65     def __hash__(self):
66         return hash(''.join(self.strings))
67 
68     def __ne__(self, otherstring):
69         return self.__cmp__(otherstring) != 0
70 
71     def __eq__(self, otherstring):
72         return self.__cmp__(otherstring) == 0
73 
74     def __repr__(self):
75         _repr = "multistring([" + u",".join(self.strings) + "])"
76         return _repr.encode('utf-8') if six.PY2 else _repr
77 
78     def replace(self, old, new, count=None):
79         if count is None:
80             newstr = multistring(super(multistring, self).replace(old, new))
81         else:
82             newstr = multistring(super(multistring, self).replace(old, new, count))
83         for s in self.strings[1:]:
84             if count is None:
85                 newstr.strings.append(s.replace(old, new))
86             else:
87                 newstr.strings.append(s.replace(old, new, count))
88         return newstr
89
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/translate/misc/multistring.py b/translate/misc/multistring.py
--- a/translate/misc/multistring.py
+++ b/translate/misc/multistring.py
@@ -75,6 +75,11 @@
         _repr = "multistring([" + u",".join(self.strings) + "])"
         return _repr.encode('utf-8') if six.PY2 else _repr
 
+    def __str__(self):
+        if six.PY2:
+            return self.encode('utf-8')
+        return super(multistring, self).__str__()
+
     def replace(self, old, new, count=None):
         if count is None:
             newstr = multistring(super(multistring, self).replace(old, new))

{"golden_diff": "diff --git a/translate/misc/multistring.py b/translate/misc/multistring.py\n--- a/translate/misc/multistring.py\n+++ b/translate/misc/multistring.py\n@@ -75,6 +75,11 @@\n         _repr = \"multistring([\" + u\",\".join(self.strings) + \"])\"\n         return _repr.encode('utf-8') if six.PY2 else _repr\n \n+    def __str__(self):\n+        if six.PY2:\n+            return self.encode('utf-8')\n+        return super(multistring, self).__str__()\n+\n     def replace(self, old, new, count=None):\n         if count is None:\n             newstr = multistring(super(multistring, self).replace(old, new))\n", "issue": "Multistring doesnt work as a python2 string\nPreviously you were able to so ~~`str(multistring(\"foo\"))`~~ but it seems this no longer works.\n\nEDIT: apologies that was a bad example it should have read something like `str(multistring(\"\u00e9\"))`\n\nIm wondering if we should add py2 compat similar to the one in django (https://docs.djangoproject.com/en/1.9/_modules/django/utils/six/#python_2_unicode_compatible)\n\n@claudep any thoughts on this?\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2006 Zuza Software Foundation\n#\n# This file is part of translate.\n#\n# translate is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# translate is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n\n\"\"\"Supports a hybrid Unicode string that can also have a list of alternate\nstrings in the strings attribute\n\"\"\"\n\nimport six\n\n\nclass multistring(six.text_type):\n\n    def __new__(newtype, string=u\"\", *args, **kwargs):\n        if isinstance(string, list):\n            if not string:\n                raise ValueError(\"multistring must contain at least one string\")\n            mainstring = string[0]\n            newstring = multistring.__new__(newtype, string[0])\n            newstring.strings = [newstring] + [multistring.__new__(newtype, altstring) for altstring in string[1:]]\n        else:\n            newstring = six.text_type.__new__(newtype, string)\n            newstring.strings = [newstring]\n        return newstring\n\n    def __init__(self, *args, **kwargs):\n        super(multistring, self).__init__()\n        if not hasattr(self, \"strings\"):\n            self.strings = []\n\n    def __cmp__(self, otherstring):\n        def cmp_compat(s1, s2):\n            # Python 3 compatible cmp() equivalent\n            return (s1 > s2) - (s1 < s2)\n        if isinstance(otherstring, multistring):\n            parentcompare = cmp_compat(six.text_type(self), otherstring)\n            if parentcompare:\n                return parentcompare\n            else:\n                return cmp_compat(self.strings[1:], otherstring.strings[1:])\n        elif isinstance(otherstring, six.text_type):\n            return cmp_compat(six.text_type(self), otherstring)\n        elif isinstance(otherstring, bytes):\n            return cmp_compat(self.encode('utf-8'), otherstring)\n        elif isinstance(otherstring, list) and otherstring:\n            return cmp_compat(self, multistring(otherstring))\n        else:\n            return cmp_compat(str(type(self)), str(type(otherstring)))\n\n    def __hash__(self):\n        return hash(''.join(self.strings))\n\n    def __ne__(self, otherstring):\n        return self.__cmp__(otherstring) != 0\n\n    def __eq__(self, otherstring):\n        return self.__cmp__(otherstring) == 0\n\n    def __repr__(self):\n        _repr = \"multistring([\" + u\",\".join(self.strings) + \"])\"\n        return _repr.encode('utf-8') if six.PY2 else _repr\n\n    def replace(self, old, new, count=None):\n        if count is None:\n            newstr = multistring(super(multistring, self).replace(old, new))\n        else:\n            newstr = multistring(super(multistring, self).replace(old, new, count))\n        for s in self.strings[1:]:\n            if count is None:\n                newstr.strings.append(s.replace(old, new))\n            else:\n                newstr.strings.append(s.replace(old, new, count))\n        return newstr\n", "path": "translate/misc/multistring.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright 2006 Zuza Software Foundation\n#\n# This file is part of translate.\n#\n# translate is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# translate is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n\n\"\"\"Supports a hybrid Unicode string that can also have a list of alternate\nstrings in the strings attribute\n\"\"\"\n\nimport six\n\n\nclass multistring(six.text_type):\n\n    def __new__(newtype, string=u\"\", *args, **kwargs):\n        if isinstance(string, list):\n            if not string:\n                raise ValueError(\"multistring must contain at least one string\")\n            mainstring = string[0]\n            newstring = multistring.__new__(newtype, string[0])\n            newstring.strings = [newstring] + [multistring.__new__(newtype, altstring) for altstring in string[1:]]\n        else:\n            newstring = six.text_type.__new__(newtype, string)\n            newstring.strings = [newstring]\n        return newstring\n\n    def __init__(self, *args, **kwargs):\n        super(multistring, self).__init__()\n        if not hasattr(self, \"strings\"):\n            self.strings = []\n\n    def __cmp__(self, otherstring):\n        def cmp_compat(s1, s2):\n            # Python 3 compatible cmp() equivalent\n            return (s1 > s2) - (s1 < s2)\n        if isinstance(otherstring, multistring):\n            parentcompare = cmp_compat(six.text_type(self), otherstring)\n            if parentcompare:\n                return parentcompare\n            else:\n                return cmp_compat(self.strings[1:], otherstring.strings[1:])\n        elif isinstance(otherstring, six.text_type):\n            return cmp_compat(six.text_type(self), otherstring)\n        elif isinstance(otherstring, bytes):\n            return cmp_compat(self.encode('utf-8'), otherstring)\n        elif isinstance(otherstring, list) and otherstring:\n            return cmp_compat(self, multistring(otherstring))\n        else:\n            return cmp_compat(str(type(self)), str(type(otherstring)))\n\n    def __hash__(self):\n        return hash(''.join(self.strings))\n\n    def __ne__(self, otherstring):\n        return self.__cmp__(otherstring) != 0\n\n    def __eq__(self, otherstring):\n        return self.__cmp__(otherstring) == 0\n\n    def __repr__(self):\n        _repr = \"multistring([\" + u\",\".join(self.strings) + \"])\"\n        return _repr.encode('utf-8') if six.PY2 else _repr\n\n    def __str__(self):\n        if six.PY2:\n            return self.encode('utf-8')\n        return super(multistring, self).__str__()\n\n    def replace(self, old, new, count=None):\n        if count is None:\n            newstr = multistring(super(multistring, self).replace(old, new))\n        else:\n            newstr = multistring(super(multistring, self).replace(old, new, count))\n        for s in self.strings[1:]:\n            if count is None:\n                newstr.strings.append(s.replace(old, new))\n            else:\n                newstr.strings.append(s.replace(old, new, count))\n        return newstr\n", "path": "translate/misc/multistring.py"}]}