We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
UnicodeEncodeError is raised if reddit returns localized error message
## Issue Description

Context: [[PRAW] UnicodeEncodeError when submitting non-unicode text : redditdev](https://www.reddit.com/r/redditdev/comments/6xf600/praw_unicodeencodeerror_when_submitting/)

Reddit may return localized error messages depends on the user's preference settings. Since
localized error messages may contain non-ascii characters (and underlying requests library
converts the errror message to unicode type), running this code in Python2 may raise UnicodeEncodeError:

https://github.com/praw-dev/praw/blob/efbe90f8c01a8afcda1fa09a59d1d89ed0da0f6b/praw/exceptions.py#L25

Here is an example of the localized message:

```
  File "/usr/local/lib/python2.7/site-packages/praw/exceptions.py", line 25, in __init__
    error_str = '{}: \'{}\''.format(error_type, message)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/local/lib/python2.7/site-packages/praw/exceptions.py(25)__init__()
-> error_str = '{}: \'{}\''.format(error_type, message)
(Pdb) p error_type
u'RATELIMIT'
(Pdb) print message
実行回数が多すぎます。9分経ってから再試行してください。
```

I think this issue is only affect to Python2 users because Python3's str type is unicode string. 

## System Information

    PRAW Version: 5.0.0
    Python Version: Python 2.7.13
    Operating System: OS X El Capitan 10.11.6

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `praw/exceptions.py`
Content:
```
1 """PRAW exception classes.
2 
3 Includes two main exceptions: :class:`.APIException` for when something goes
4 wrong on the server side, and :class:`.ClientException` when something goes
5 wrong on the client side. Both of these classes extend :class:`.PRAWException`.
6 
7 """
8 
9 
10 class PRAWException(Exception):
11     """The base PRAW Exception that all other exception classes extend."""
12 
13 
14 class APIException(PRAWException):
15     """Indicate exception that involve responses from Reddit's API."""
16 
17     def __init__(self, error_type, message, field):
18         """Initialize an instance of APIException.
19 
20         :param error_type: The error type set on Reddit's end.
21         :param message: The associated message for the error.
22         :param field: The input field associated with the error if available.
23 
24         """
25         error_str = '{}: \'{}\''.format(error_type, message)
26         if field:
27             error_str += ' on field \'{}\''.format(field)
28         super(APIException, self).__init__(error_str)
29         self.error_type = error_type
30         self.message = message
31         self.field = field
32 
33 
34 class ClientException(PRAWException):
35     """Indicate exceptions that don't involve interaction with Reddit's API."""
36
```
--- 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/praw/exceptions.py b/praw/exceptions.py
--- a/praw/exceptions.py
+++ b/praw/exceptions.py
@@ -21,10 +21,17 @@
         :param message: The associated message for the error.
         :param field: The input field associated with the error if available.
 
+        .. note: Calling `str()` on the instance returns `unicode_escape`d
+            ASCII string because the message may be localized and may contain
+            UNICODE characters. If you want a non-escaped message, access
+            the `message` atribute on the instance.
+
         """
-        error_str = '{}: \'{}\''.format(error_type, message)
+        error_str = u'{}: \'{}\''.format(error_type, message)
         if field:
-            error_str += ' on field \'{}\''.format(field)
+            error_str += u' on field \'{}\''.format(field)
+        error_str = error_str.encode('unicode_escape').decode('ascii')
+
         super(APIException, self).__init__(error_str)
         self.error_type = error_type
         self.message = message

{"golden_diff": "diff --git a/praw/exceptions.py b/praw/exceptions.py\n--- a/praw/exceptions.py\n+++ b/praw/exceptions.py\n@@ -21,10 +21,17 @@\n         :param message: The associated message for the error.\n         :param field: The input field associated with the error if available.\n \n+        .. note: Calling `str()` on the instance returns `unicode_escape`d\n+            ASCII string because the message may be localized and may contain\n+            UNICODE characters. If you want a non-escaped message, access\n+            the `message` atribute on the instance.\n+\n         \"\"\"\n-        error_str = '{}: \\'{}\\''.format(error_type, message)\n+        error_str = u'{}: \\'{}\\''.format(error_type, message)\n         if field:\n-            error_str += ' on field \\'{}\\''.format(field)\n+            error_str += u' on field \\'{}\\''.format(field)\n+        error_str = error_str.encode('unicode_escape').decode('ascii')\n+\n         super(APIException, self).__init__(error_str)\n         self.error_type = error_type\n         self.message = message\n", "issue": "UnicodeEncodeError is raised if reddit returns localized error message\n## Issue Description\r\n\r\nContext: [[PRAW] UnicodeEncodeError when submitting non-unicode text : redditdev](https://www.reddit.com/r/redditdev/comments/6xf600/praw_unicodeencodeerror_when_submitting/)\r\n\r\nReddit may return localized error messages depends on the user's preference settings. Since\r\nlocalized error messages may contain non-ascii characters (and underlying requests library\r\nconverts the errror message to unicode type), running this code in Python2 may raise UnicodeEncodeError:\r\n\r\nhttps://github.com/praw-dev/praw/blob/efbe90f8c01a8afcda1fa09a59d1d89ed0da0f6b/praw/exceptions.py#L25\r\n\r\nHere is an example of the localized message:\r\n\r\n```\r\n  File \"/usr/local/lib/python2.7/site-packages/praw/exceptions.py\", line 25, in __init__\r\n    error_str = '{}: \\'{}\\''.format(error_type, message)\r\nUnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)\r\nUncaught exception. Entering post mortem debugging\r\nRunning 'cont' or 'step' will restart the program\r\n> /usr/local/lib/python2.7/site-packages/praw/exceptions.py(25)__init__()\r\n-> error_str = '{}: \\'{}\\''.format(error_type, message)\r\n(Pdb) p error_type\r\nu'RATELIMIT'\r\n(Pdb) print message\r\n\u5b9f\u884c\u56de\u6570\u304c\u591a\u3059\u304e\u307e\u3059\u30029\u5206\u7d4c\u3063\u3066\u304b\u3089\u518d\u8a66\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\n```\r\n\r\nI think this issue is only affect to Python2 users because Python3's str type is unicode string. \r\n\r\n## System Information\r\n\r\n    PRAW Version: 5.0.0\r\n    Python Version: Python 2.7.13\r\n    Operating System: OS X El Capitan 10.11.6\n", "before_files": [{"content": "\"\"\"PRAW exception classes.\n\nIncludes two main exceptions: :class:`.APIException` for when something goes\nwrong on the server side, and :class:`.ClientException` when something goes\nwrong on the client side. Both of these classes extend :class:`.PRAWException`.\n\n\"\"\"\n\n\nclass PRAWException(Exception):\n    \"\"\"The base PRAW Exception that all other exception classes extend.\"\"\"\n\n\nclass APIException(PRAWException):\n    \"\"\"Indicate exception that involve responses from Reddit's API.\"\"\"\n\n    def __init__(self, error_type, message, field):\n        \"\"\"Initialize an instance of APIException.\n\n        :param error_type: The error type set on Reddit's end.\n        :param message: The associated message for the error.\n        :param field: The input field associated with the error if available.\n\n        \"\"\"\n        error_str = '{}: \\'{}\\''.format(error_type, message)\n        if field:\n            error_str += ' on field \\'{}\\''.format(field)\n        super(APIException, self).__init__(error_str)\n        self.error_type = error_type\n        self.message = message\n        self.field = field\n\n\nclass ClientException(PRAWException):\n    \"\"\"Indicate exceptions that don't involve interaction with Reddit's API.\"\"\"\n", "path": "praw/exceptions.py"}], "after_files": [{"content": "\"\"\"PRAW exception classes.\n\nIncludes two main exceptions: :class:`.APIException` for when something goes\nwrong on the server side, and :class:`.ClientException` when something goes\nwrong on the client side. Both of these classes extend :class:`.PRAWException`.\n\n\"\"\"\n\n\nclass PRAWException(Exception):\n    \"\"\"The base PRAW Exception that all other exception classes extend.\"\"\"\n\n\nclass APIException(PRAWException):\n    \"\"\"Indicate exception that involve responses from Reddit's API.\"\"\"\n\n    def __init__(self, error_type, message, field):\n        \"\"\"Initialize an instance of APIException.\n\n        :param error_type: The error type set on Reddit's end.\n        :param message: The associated message for the error.\n        :param field: The input field associated with the error if available.\n\n        .. note: Calling `str()` on the instance returns `unicode_escape`d\n            ASCII string because the message may be localized and may contain\n            UNICODE characters. If you want a non-escaped message, access\n            the `message` atribute on the instance.\n\n        \"\"\"\n        error_str = u'{}: \\'{}\\''.format(error_type, message)\n        if field:\n            error_str += u' on field \\'{}\\''.format(field)\n        error_str = error_str.encode('unicode_escape').decode('ascii')\n\n        super(APIException, self).__init__(error_str)\n        self.error_type = error_type\n        self.message = message\n        self.field = field\n\n\nclass ClientException(PRAWException):\n    \"\"\"Indicate exceptions that don't involve interaction with Reddit's API.\"\"\"\n", "path": "praw/exceptions.py"}]}