We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
importlib module_from_spec error in Python 3.4
I download models like this
python -m spacy download en
python -m spacy download en_core_web_md

Above commands create a link like this 



 Linking successful
    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/en_core_web_md
    -->
    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/data/en_core_web_md

    You can now load the model via spacy.load('en_core_web_md')




But when I actually load the model ,it throws the following error 


>>> import spacy
>>> nlp= spacy.load('en_core_web_md')
Traceback (most recent call last):
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 126, in load_model_from_link
    cls = import_file(name, path)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/compat.py", line 118, in import_file
    module = importlib.util.module_from_spec(spec)
AttributeError: 'module' object has no attribute 'module_from_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/__init__.py", line 19, in load
    return util.load_model(name, **overrides)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 112, in load_model
    return load_model_from_link(name, **overrides)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 130, in load_model_from_link
    "points to a valid package (not just a data directory)." % name)
OSError: Cant' load 'en_core_web_md'. If you're using a shortcut link, make sure it points to a valid package (not just a data directory).
>>> 









## Your Environment
<!-- Include details of your environment. If you're using spaCy 1.7+, you can also type 
`python -m spacy info --markdown` and copy-paste the result here.-->* **Python version:** 3.4.5
* **Platform:** Linux-4.4.0-101-generic-x86_64-with-debian-jessie-sid
* **Models:** __cache__, en_core_web_md, en, en-1.1.0
* **spaCy version:** 2.0.5

* Operating System: Ububtu 14.04
* Python Version Used: 3.4.5
* spaCy Version Used: 2.0.5
* Environment Information: Conda Virtual Environment

importlib module_from_spec error in Python 3.4
I download models like this
python -m spacy download en
python -m spacy download en_core_web_md

Above commands create a link like this 



 Linking successful
    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/en_core_web_md
    -->
    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/data/en_core_web_md

    You can now load the model via spacy.load('en_core_web_md')




But when I actually load the model ,it throws the following error 


>>> import spacy
>>> nlp= spacy.load('en_core_web_md')
Traceback (most recent call last):
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 126, in load_model_from_link
    cls = import_file(name, path)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/compat.py", line 118, in import_file
    module = importlib.util.module_from_spec(spec)
AttributeError: 'module' object has no attribute 'module_from_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/__init__.py", line 19, in load
    return util.load_model(name, **overrides)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 112, in load_model
    return load_model_from_link(name, **overrides)
  File "/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py", line 130, in load_model_from_link
    "points to a valid package (not just a data directory)." % name)
OSError: Cant' load 'en_core_web_md'. If you're using a shortcut link, make sure it points to a valid package (not just a data directory).
>>> 









## Your Environment
<!-- Include details of your environment. If you're using spaCy 1.7+, you can also type 
`python -m spacy info --markdown` and copy-paste the result here.-->* **Python version:** 3.4.5
* **Platform:** Linux-4.4.0-101-generic-x86_64-with-debian-jessie-sid
* **Models:** __cache__, en_core_web_md, en, en-1.1.0
* **spaCy version:** 2.0.5

* Operating System: Ububtu 14.04
* Python Version Used: 3.4.5
* spaCy Version Used: 2.0.5
* Environment Information: Conda Virtual Environment


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `spacy/compat.py`
Content:
```
1 # coding: utf8
2 from __future__ import unicode_literals
3 
4 import six
5 import ftfy
6 import sys
7 import ujson
8 import itertools
9 import locale
10 
11 from thinc.neural.util import copy_array
12 
13 try:
14     import cPickle as pickle
15 except ImportError:
16     import pickle
17 
18 try:
19     import copy_reg
20 except ImportError:
21     import copyreg as copy_reg
22 
23 try:
24     from cupy.cuda.stream import Stream as CudaStream
25 except ImportError:
26     CudaStream = None
27 
28 try:
29     import cupy
30 except ImportError:
31     cupy = None
32 
33 try:
34     from thinc.neural.optimizers import Optimizer
35 except ImportError:
36     from thinc.neural.optimizers import Adam as Optimizer
37 
38 pickle = pickle
39 copy_reg = copy_reg
40 CudaStream = CudaStream
41 cupy = cupy
42 fix_text = ftfy.fix_text
43 copy_array = copy_array
44 izip = getattr(itertools, 'izip', zip)
45 
46 is_python2 = six.PY2
47 is_python3 = six.PY3
48 is_windows = sys.platform.startswith('win')
49 is_linux = sys.platform.startswith('linux')
50 is_osx = sys.platform == 'darwin'
51 
52 
53 if is_python2:
54     import imp
55     bytes_ = str
56     unicode_ = unicode  # noqa: F821
57     basestring_ = basestring  # noqa: F821
58     input_ = raw_input  # noqa: F821
59     json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False).decode('utf8')
60     path2str = lambda path: str(path).decode('utf8')
61 
62 elif is_python3:
63     import importlib.util
64     bytes_ = bytes
65     unicode_ = str
66     basestring_ = str
67     input_ = input
68     json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False)
69     path2str = lambda path: str(path)
70 
71 
72 def b_to_str(b_str):
73     if is_python2:
74         return b_str
75     # important: if no encoding is set, string becomes "b'...'"
76     return str(b_str, encoding='utf8')
77 
78 
79 def getattr_(obj, name, *default):
80     if is_python3 and isinstance(name, bytes):
81         name = name.decode('utf8')
82     return getattr(obj, name, *default)
83 
84 
85 def symlink_to(orig, dest):
86     if is_python2 and is_windows:
87         import subprocess
88         subprocess.call(['mklink', '/d', path2str(orig), path2str(dest)], shell=True)
89     else:
90         orig.symlink_to(dest)
91 
92 
93 def is_config(python2=None, python3=None, windows=None, linux=None, osx=None):
94     return ((python2 is None or python2 == is_python2) and
95             (python3 is None or python3 == is_python3) and
96             (windows is None or windows == is_windows) and
97             (linux is None or linux == is_linux) and
98             (osx is None or osx == is_osx))
99 
100 
101 def normalize_string_keys(old):
102     """Given a dictionary, make sure keys are unicode strings, not bytes."""
103     new = {}
104     for key, value in old.items():
105         if isinstance(key, bytes_):
106             new[key.decode('utf8')] = value
107         else:
108             new[key] = value
109     return new
110 
111 
112 def import_file(name, loc):
113     loc = str(loc)
114     if is_python2:
115         return imp.load_source(name, loc)
116     else:
117         spec = importlib.util.spec_from_file_location(name, str(loc))
118         module = importlib.util.module_from_spec(spec)
119         spec.loader.exec_module(module)
120         return module
121 
122 
123 def locale_escape(string, errors='replace'):
124     '''
125     Mangle non-supported characters, for savages with ascii terminals.
126     '''
127     encoding = locale.getpreferredencoding()
128     string = string.encode(encoding, errors).decode('utf8')
129     return string
130
```
--- 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/spacy/compat.py b/spacy/compat.py
--- a/spacy/compat.py
+++ b/spacy/compat.py
@@ -43,15 +43,15 @@
 copy_array = copy_array
 izip = getattr(itertools, 'izip', zip)
 
-is_python2 = six.PY2
-is_python3 = six.PY3
 is_windows = sys.platform.startswith('win')
 is_linux = sys.platform.startswith('linux')
 is_osx = sys.platform == 'darwin'
 
+is_python2 = six.PY2
+is_python3 = six.PY3
+is_python_pre_3_5 = is_python2 or (is_python3 and sys.version_info[1]<5)
 
 if is_python2:
-    import imp
     bytes_ = str
     unicode_ = unicode  # noqa: F821
     basestring_ = basestring  # noqa: F821
@@ -60,7 +60,6 @@
     path2str = lambda path: str(path).decode('utf8')
 
 elif is_python3:
-    import importlib.util
     bytes_ = bytes
     unicode_ = str
     basestring_ = str
@@ -111,9 +110,11 @@
 
 def import_file(name, loc):
     loc = str(loc)
-    if is_python2:
+    if is_python_pre_3_5:
+        import imp
         return imp.load_source(name, loc)
     else:
+        import importlib.util
         spec = importlib.util.spec_from_file_location(name, str(loc))
         module = importlib.util.module_from_spec(spec)
         spec.loader.exec_module(module)

{"golden_diff": "diff --git a/spacy/compat.py b/spacy/compat.py\n--- a/spacy/compat.py\n+++ b/spacy/compat.py\n@@ -43,15 +43,15 @@\n copy_array = copy_array\n izip = getattr(itertools, 'izip', zip)\n \n-is_python2 = six.PY2\n-is_python3 = six.PY3\n is_windows = sys.platform.startswith('win')\n is_linux = sys.platform.startswith('linux')\n is_osx = sys.platform == 'darwin'\n \n+is_python2 = six.PY2\n+is_python3 = six.PY3\n+is_python_pre_3_5 = is_python2 or (is_python3 and sys.version_info[1]<5)\n \n if is_python2:\n-    import imp\n     bytes_ = str\n     unicode_ = unicode  # noqa: F821\n     basestring_ = basestring  # noqa: F821\n@@ -60,7 +60,6 @@\n     path2str = lambda path: str(path).decode('utf8')\n \n elif is_python3:\n-    import importlib.util\n     bytes_ = bytes\n     unicode_ = str\n     basestring_ = str\n@@ -111,9 +110,11 @@\n \n def import_file(name, loc):\n     loc = str(loc)\n-    if is_python2:\n+    if is_python_pre_3_5:\n+        import imp\n         return imp.load_source(name, loc)\n     else:\n+        import importlib.util\n         spec = importlib.util.spec_from_file_location(name, str(loc))\n         module = importlib.util.module_from_spec(spec)\n         spec.loader.exec_module(module)\n", "issue": "importlib module_from_spec error in Python 3.4\nI download models like this\r\npython -m spacy download en\r\npython -m spacy download en_core_web_md\r\n\r\nAbove commands create a link like this \r\n\r\n\r\n\r\n Linking successful\r\n    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/en_core_web_md\r\n    -->\r\n    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/data/en_core_web_md\r\n\r\n    You can now load the model via spacy.load('en_core_web_md')\r\n\r\n\r\n\r\n\r\nBut when I actually load the model ,it throws the following error \r\n\r\n\r\n>>> import spacy\r\n>>> nlp= spacy.load('en_core_web_md')\r\nTraceback (most recent call last):\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 126, in load_model_from_link\r\n    cls = import_file(name, path)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/compat.py\", line 118, in import_file\r\n    module = importlib.util.module_from_spec(spec)\r\nAttributeError: 'module' object has no attribute 'module_from_spec'\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/__init__.py\", line 19, in load\r\n    return util.load_model(name, **overrides)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 112, in load_model\r\n    return load_model_from_link(name, **overrides)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 130, in load_model_from_link\r\n    \"points to a valid package (not just a data directory).\" % name)\r\nOSError: Cant' load 'en_core_web_md'. If you're using a shortcut link, make sure it points to a valid package (not just a data directory).\r\n>>> \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n## Your Environment\r\n<!-- Include details of your environment. If you're using spaCy 1.7+, you can also type \r\n`python -m spacy info --markdown` and copy-paste the result here.-->* **Python version:** 3.4.5\r\n* **Platform:** Linux-4.4.0-101-generic-x86_64-with-debian-jessie-sid\r\n* **Models:** __cache__, en_core_web_md, en, en-1.1.0\r\n* **spaCy version:** 2.0.5\r\n\r\n* Operating System: Ububtu 14.04\r\n* Python Version Used: 3.4.5\r\n* spaCy Version Used: 2.0.5\r\n* Environment Information: Conda Virtual Environment\r\n\nimportlib module_from_spec error in Python 3.4\nI download models like this\r\npython -m spacy download en\r\npython -m spacy download en_core_web_md\r\n\r\nAbove commands create a link like this \r\n\r\n\r\n\r\n Linking successful\r\n    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/en_core_web_md\r\n    -->\r\n    /home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/data/en_core_web_md\r\n\r\n    You can now load the model via spacy.load('en_core_web_md')\r\n\r\n\r\n\r\n\r\nBut when I actually load the model ,it throws the following error \r\n\r\n\r\n>>> import spacy\r\n>>> nlp= spacy.load('en_core_web_md')\r\nTraceback (most recent call last):\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 126, in load_model_from_link\r\n    cls = import_file(name, path)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/compat.py\", line 118, in import_file\r\n    module = importlib.util.module_from_spec(spec)\r\nAttributeError: 'module' object has no attribute 'module_from_spec'\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/__init__.py\", line 19, in load\r\n    return util.load_model(name, **overrides)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 112, in load_model\r\n    return load_model_from_link(name, **overrides)\r\n  File \"/home/sameer/anaconda2/envs/py34/lib/python3.4/site-packages/spacy/util.py\", line 130, in load_model_from_link\r\n    \"points to a valid package (not just a data directory).\" % name)\r\nOSError: Cant' load 'en_core_web_md'. If you're using a shortcut link, make sure it points to a valid package (not just a data directory).\r\n>>> \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n## Your Environment\r\n<!-- Include details of your environment. If you're using spaCy 1.7+, you can also type \r\n`python -m spacy info --markdown` and copy-paste the result here.-->* **Python version:** 3.4.5\r\n* **Platform:** Linux-4.4.0-101-generic-x86_64-with-debian-jessie-sid\r\n* **Models:** __cache__, en_core_web_md, en, en-1.1.0\r\n* **spaCy version:** 2.0.5\r\n\r\n* Operating System: Ububtu 14.04\r\n* Python Version Used: 3.4.5\r\n* spaCy Version Used: 2.0.5\r\n* Environment Information: Conda Virtual Environment\r\n\n", "before_files": [{"content": "# coding: utf8\nfrom __future__ import unicode_literals\n\nimport six\nimport ftfy\nimport sys\nimport ujson\nimport itertools\nimport locale\n\nfrom thinc.neural.util import copy_array\n\ntry:\n    import cPickle as pickle\nexcept ImportError:\n    import pickle\n\ntry:\n    import copy_reg\nexcept ImportError:\n    import copyreg as copy_reg\n\ntry:\n    from cupy.cuda.stream import Stream as CudaStream\nexcept ImportError:\n    CudaStream = None\n\ntry:\n    import cupy\nexcept ImportError:\n    cupy = None\n\ntry:\n    from thinc.neural.optimizers import Optimizer\nexcept ImportError:\n    from thinc.neural.optimizers import Adam as Optimizer\n\npickle = pickle\ncopy_reg = copy_reg\nCudaStream = CudaStream\ncupy = cupy\nfix_text = ftfy.fix_text\ncopy_array = copy_array\nizip = getattr(itertools, 'izip', zip)\n\nis_python2 = six.PY2\nis_python3 = six.PY3\nis_windows = sys.platform.startswith('win')\nis_linux = sys.platform.startswith('linux')\nis_osx = sys.platform == 'darwin'\n\n\nif is_python2:\n    import imp\n    bytes_ = str\n    unicode_ = unicode  # noqa: F821\n    basestring_ = basestring  # noqa: F821\n    input_ = raw_input  # noqa: F821\n    json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False).decode('utf8')\n    path2str = lambda path: str(path).decode('utf8')\n\nelif is_python3:\n    import importlib.util\n    bytes_ = bytes\n    unicode_ = str\n    basestring_ = str\n    input_ = input\n    json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False)\n    path2str = lambda path: str(path)\n\n\ndef b_to_str(b_str):\n    if is_python2:\n        return b_str\n    # important: if no encoding is set, string becomes \"b'...'\"\n    return str(b_str, encoding='utf8')\n\n\ndef getattr_(obj, name, *default):\n    if is_python3 and isinstance(name, bytes):\n        name = name.decode('utf8')\n    return getattr(obj, name, *default)\n\n\ndef symlink_to(orig, dest):\n    if is_python2 and is_windows:\n        import subprocess\n        subprocess.call(['mklink', '/d', path2str(orig), path2str(dest)], shell=True)\n    else:\n        orig.symlink_to(dest)\n\n\ndef is_config(python2=None, python3=None, windows=None, linux=None, osx=None):\n    return ((python2 is None or python2 == is_python2) and\n            (python3 is None or python3 == is_python3) and\n            (windows is None or windows == is_windows) and\n            (linux is None or linux == is_linux) and\n            (osx is None or osx == is_osx))\n\n\ndef normalize_string_keys(old):\n    \"\"\"Given a dictionary, make sure keys are unicode strings, not bytes.\"\"\"\n    new = {}\n    for key, value in old.items():\n        if isinstance(key, bytes_):\n            new[key.decode('utf8')] = value\n        else:\n            new[key] = value\n    return new\n\n\ndef import_file(name, loc):\n    loc = str(loc)\n    if is_python2:\n        return imp.load_source(name, loc)\n    else:\n        spec = importlib.util.spec_from_file_location(name, str(loc))\n        module = importlib.util.module_from_spec(spec)\n        spec.loader.exec_module(module)\n        return module\n\n\ndef locale_escape(string, errors='replace'):\n    '''\n    Mangle non-supported characters, for savages with ascii terminals.\n    '''\n    encoding = locale.getpreferredencoding()\n    string = string.encode(encoding, errors).decode('utf8')\n    return string\n", "path": "spacy/compat.py"}], "after_files": [{"content": "# coding: utf8\nfrom __future__ import unicode_literals\n\nimport six\nimport ftfy\nimport sys\nimport ujson\nimport itertools\nimport locale\n\nfrom thinc.neural.util import copy_array\n\ntry:\n    import cPickle as pickle\nexcept ImportError:\n    import pickle\n\ntry:\n    import copy_reg\nexcept ImportError:\n    import copyreg as copy_reg\n\ntry:\n    from cupy.cuda.stream import Stream as CudaStream\nexcept ImportError:\n    CudaStream = None\n\ntry:\n    import cupy\nexcept ImportError:\n    cupy = None\n\ntry:\n    from thinc.neural.optimizers import Optimizer\nexcept ImportError:\n    from thinc.neural.optimizers import Adam as Optimizer\n\npickle = pickle\ncopy_reg = copy_reg\nCudaStream = CudaStream\ncupy = cupy\nfix_text = ftfy.fix_text\ncopy_array = copy_array\nizip = getattr(itertools, 'izip', zip)\n\nis_windows = sys.platform.startswith('win')\nis_linux = sys.platform.startswith('linux')\nis_osx = sys.platform == 'darwin'\n\nis_python2 = six.PY2\nis_python3 = six.PY3\nis_python_pre_3_5 = is_python2 or (is_python3 and sys.version_info[1]<5)\n\nif is_python2:\n    bytes_ = str\n    unicode_ = unicode  # noqa: F821\n    basestring_ = basestring  # noqa: F821\n    input_ = raw_input  # noqa: F821\n    json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False).decode('utf8')\n    path2str = lambda path: str(path).decode('utf8')\n\nelif is_python3:\n    bytes_ = bytes\n    unicode_ = str\n    basestring_ = str\n    input_ = input\n    json_dumps = lambda data: ujson.dumps(data, indent=2, escape_forward_slashes=False)\n    path2str = lambda path: str(path)\n\n\ndef b_to_str(b_str):\n    if is_python2:\n        return b_str\n    # important: if no encoding is set, string becomes \"b'...'\"\n    return str(b_str, encoding='utf8')\n\n\ndef getattr_(obj, name, *default):\n    if is_python3 and isinstance(name, bytes):\n        name = name.decode('utf8')\n    return getattr(obj, name, *default)\n\n\ndef symlink_to(orig, dest):\n    if is_python2 and is_windows:\n        import subprocess\n        subprocess.call(['mklink', '/d', path2str(orig), path2str(dest)], shell=True)\n    else:\n        orig.symlink_to(dest)\n\n\ndef is_config(python2=None, python3=None, windows=None, linux=None, osx=None):\n    return ((python2 is None or python2 == is_python2) and\n            (python3 is None or python3 == is_python3) and\n            (windows is None or windows == is_windows) and\n            (linux is None or linux == is_linux) and\n            (osx is None or osx == is_osx))\n\n\ndef normalize_string_keys(old):\n    \"\"\"Given a dictionary, make sure keys are unicode strings, not bytes.\"\"\"\n    new = {}\n    for key, value in old.items():\n        if isinstance(key, bytes_):\n            new[key.decode('utf8')] = value\n        else:\n            new[key] = value\n    return new\n\n\ndef import_file(name, loc):\n    loc = str(loc)\n    if is_python_pre_3_5:\n        import imp\n        return imp.load_source(name, loc)\n    else:\n        import importlib.util\n        spec = importlib.util.spec_from_file_location(name, str(loc))\n        module = importlib.util.module_from_spec(spec)\n        spec.loader.exec_module(module)\n        return module\n\n\ndef locale_escape(string, errors='replace'):\n    '''\n    Mangle non-supported characters, for savages with ascii terminals.\n    '''\n    encoding = locale.getpreferredencoding()\n    string = string.encode(encoding, errors).decode('utf8')\n    return string\n", "path": "spacy/compat.py"}]}