We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: 'list' object has no attribute 'rstrip'
Hi all, previously torchtext works for me when I'm running anaconda python. However, now, when i uninstalled my anaconda python. It stops working.

It gives me the following error:  

```
File "/Library/Python/2.7/site-packages/torchtext/data/example.py", line 59, in fromlist
    setattr(ex, name, field.preprocess(val.rstrip('\n')))
AttributeError: 'list' object has no attribute 'rstrip'

```

Thanks!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchtext/data/example.py`
Content:
```
1 import csv
2 import json
3 
4 import six
5 
6 
7 class Example(object):
8     """Defines a single training or test example.
9 
10     Stores each column of the example as an attribute.
11     """
12 
13     @classmethod
14     def fromJSON(cls, data, fields):
15         return cls.fromdict(json.loads(data), fields)
16 
17     @classmethod
18     def fromdict(cls, data, fields):
19         ex = cls()
20         for key, vals in fields.items():
21             if key not in data:
22                 raise ValueError("Specified key {} was not found in "
23                                  "the input data".format(key))
24             if vals is not None:
25                 if not isinstance(vals, list):
26                     vals = [vals]
27                 for val in vals:
28                     name, field = val
29                     setattr(ex, name, field.preprocess(data[key]))
30         return ex
31 
32     @classmethod
33     def fromTSV(cls, data, fields):
34         return cls.fromlist(data.split('\t'), fields)
35 
36     @classmethod
37     def fromCSV(cls, data, fields):
38         data = data.rstrip("\n")
39         # If Python 2, encode to utf-8 since CSV doesn't take unicode input
40         if six.PY2:
41             data = data.encode('utf-8')
42         # Use Python CSV module to parse the CSV line
43         parsed_csv_lines = csv.reader([data])
44 
45         # If Python 2, decode back to unicode (the original input format).
46         if six.PY2:
47             for line in parsed_csv_lines:
48                 parsed_csv_line = [six.text_type(col, 'utf-8') for col in line]
49                 break
50         else:
51             parsed_csv_line = list(parsed_csv_lines)[0]
52         return cls.fromlist(parsed_csv_line, fields)
53 
54     @classmethod
55     def fromlist(cls, data, fields):
56         ex = cls()
57         for (name, field), val in zip(fields, data):
58             if field is not None:
59                 setattr(ex, name, field.preprocess(val.rstrip('\n')))
60         return ex
61 
62     @classmethod
63     def fromtree(cls, data, fields, subtrees=False):
64         try:
65             from nltk.tree import Tree
66         except ImportError:
67             print("Please install NLTK. "
68                   "See the docs at http://nltk.org for more information.")
69             raise
70         tree = Tree.fromstring(data)
71         if subtrees:
72             return [cls.fromlist(
73                 [' '.join(t.leaves()), t.label()], fields) for t in tree.subtrees()]
74         return cls.fromlist([' '.join(tree.leaves()), tree.label()], fields)
75
```
--- 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/torchtext/data/example.py b/torchtext/data/example.py
--- a/torchtext/data/example.py
+++ b/torchtext/data/example.py
@@ -56,7 +56,9 @@
         ex = cls()
         for (name, field), val in zip(fields, data):
             if field is not None:
-                setattr(ex, name, field.preprocess(val.rstrip('\n')))
+                if isinstance(val, six.string_types):
+                    val = val.rstrip('\n')
+                setattr(ex, name, field.preprocess(val))
         return ex
 
     @classmethod

{"golden_diff": "diff --git a/torchtext/data/example.py b/torchtext/data/example.py\n--- a/torchtext/data/example.py\n+++ b/torchtext/data/example.py\n@@ -56,7 +56,9 @@\n         ex = cls()\n         for (name, field), val in zip(fields, data):\n             if field is not None:\n-                setattr(ex, name, field.preprocess(val.rstrip('\\n')))\n+                if isinstance(val, six.string_types):\n+                    val = val.rstrip('\\n')\n+                setattr(ex, name, field.preprocess(val))\n         return ex\n \n     @classmethod\n", "issue": "AttributeError: 'list' object has no attribute 'rstrip'\nHi all, previously torchtext works for me when I'm running anaconda python. However, now, when i uninstalled my anaconda python. It stops working.\r\n\r\nIt gives me the following error:  \r\n\r\n```\r\nFile \"/Library/Python/2.7/site-packages/torchtext/data/example.py\", line 59, in fromlist\r\n    setattr(ex, name, field.preprocess(val.rstrip('\\n')))\r\nAttributeError: 'list' object has no attribute 'rstrip'\r\n\r\n```\r\n\r\nThanks!\n", "before_files": [{"content": "import csv\nimport json\n\nimport six\n\n\nclass Example(object):\n    \"\"\"Defines a single training or test example.\n\n    Stores each column of the example as an attribute.\n    \"\"\"\n\n    @classmethod\n    def fromJSON(cls, data, fields):\n        return cls.fromdict(json.loads(data), fields)\n\n    @classmethod\n    def fromdict(cls, data, fields):\n        ex = cls()\n        for key, vals in fields.items():\n            if key not in data:\n                raise ValueError(\"Specified key {} was not found in \"\n                                 \"the input data\".format(key))\n            if vals is not None:\n                if not isinstance(vals, list):\n                    vals = [vals]\n                for val in vals:\n                    name, field = val\n                    setattr(ex, name, field.preprocess(data[key]))\n        return ex\n\n    @classmethod\n    def fromTSV(cls, data, fields):\n        return cls.fromlist(data.split('\\t'), fields)\n\n    @classmethod\n    def fromCSV(cls, data, fields):\n        data = data.rstrip(\"\\n\")\n        # If Python 2, encode to utf-8 since CSV doesn't take unicode input\n        if six.PY2:\n            data = data.encode('utf-8')\n        # Use Python CSV module to parse the CSV line\n        parsed_csv_lines = csv.reader([data])\n\n        # If Python 2, decode back to unicode (the original input format).\n        if six.PY2:\n            for line in parsed_csv_lines:\n                parsed_csv_line = [six.text_type(col, 'utf-8') for col in line]\n                break\n        else:\n            parsed_csv_line = list(parsed_csv_lines)[0]\n        return cls.fromlist(parsed_csv_line, fields)\n\n    @classmethod\n    def fromlist(cls, data, fields):\n        ex = cls()\n        for (name, field), val in zip(fields, data):\n            if field is not None:\n                setattr(ex, name, field.preprocess(val.rstrip('\\n')))\n        return ex\n\n    @classmethod\n    def fromtree(cls, data, fields, subtrees=False):\n        try:\n            from nltk.tree import Tree\n        except ImportError:\n            print(\"Please install NLTK. \"\n                  \"See the docs at http://nltk.org for more information.\")\n            raise\n        tree = Tree.fromstring(data)\n        if subtrees:\n            return [cls.fromlist(\n                [' '.join(t.leaves()), t.label()], fields) for t in tree.subtrees()]\n        return cls.fromlist([' '.join(tree.leaves()), tree.label()], fields)\n", "path": "torchtext/data/example.py"}], "after_files": [{"content": "import csv\nimport json\n\nimport six\n\n\nclass Example(object):\n    \"\"\"Defines a single training or test example.\n\n    Stores each column of the example as an attribute.\n    \"\"\"\n\n    @classmethod\n    def fromJSON(cls, data, fields):\n        return cls.fromdict(json.loads(data), fields)\n\n    @classmethod\n    def fromdict(cls, data, fields):\n        ex = cls()\n        for key, vals in fields.items():\n            if key not in data:\n                raise ValueError(\"Specified key {} was not found in \"\n                                 \"the input data\".format(key))\n            if vals is not None:\n                if not isinstance(vals, list):\n                    vals = [vals]\n                for val in vals:\n                    name, field = val\n                    setattr(ex, name, field.preprocess(data[key]))\n        return ex\n\n    @classmethod\n    def fromTSV(cls, data, fields):\n        return cls.fromlist(data.split('\\t'), fields)\n\n    @classmethod\n    def fromCSV(cls, data, fields):\n        data = data.rstrip(\"\\n\")\n        # If Python 2, encode to utf-8 since CSV doesn't take unicode input\n        if six.PY2:\n            data = data.encode('utf-8')\n        # Use Python CSV module to parse the CSV line\n        parsed_csv_lines = csv.reader([data])\n\n        # If Python 2, decode back to unicode (the original input format).\n        if six.PY2:\n            for line in parsed_csv_lines:\n                parsed_csv_line = [six.text_type(col, 'utf-8') for col in line]\n                break\n        else:\n            parsed_csv_line = list(parsed_csv_lines)[0]\n        return cls.fromlist(parsed_csv_line, fields)\n\n    @classmethod\n    def fromlist(cls, data, fields):\n        ex = cls()\n        for (name, field), val in zip(fields, data):\n            if field is not None:\n                if isinstance(val, six.string_types):\n                    val = val.rstrip('\\n')\n                setattr(ex, name, field.preprocess(val))\n        return ex\n\n    @classmethod\n    def fromtree(cls, data, fields, subtrees=False):\n        try:\n            from nltk.tree import Tree\n        except ImportError:\n            print(\"Please install NLTK. \"\n                  \"See the docs at http://nltk.org for more information.\")\n            raise\n        tree = Tree.fromstring(data)\n        if subtrees:\n            return [cls.fromlist(\n                [' '.join(t.leaves()), t.label()], fields) for t in tree.subtrees()]\n        return cls.fromlist([' '.join(tree.leaves()), tree.label()], fields)\n", "path": "torchtext/data/example.py"}]}