We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ValueError: invalid __array_struct__ when using js arrays of arrays and numpy
When using a matrix (array of array of numbers) in javascript and trying to convert that to a numpy array, it fails with the error `ValueError: invalid __array_struct__`

To reproduce:
JavaScript:
```
window.A = [[1,2,3],[4,5,6]];
```
Python:
```
import numpy
from js import A
m = numpy.array(A)
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/pyodide.py`
Content:
```
1 """
2 A library of helper utilities for connecting Python to the browser environment.
3 """
4 
5 import ast
6 import io
7 from textwrap import dedent
8 
9 __version__ = '0.8.2'
10 
11 
12 def open_url(url):
13     """
14     Fetches a given *url* and returns a io.StringIO to access its contents.
15     """
16     from js import XMLHttpRequest
17 
18     req = XMLHttpRequest.new()
19     req.open('GET', url, False)
20     req.send(None)
21     return io.StringIO(req.response)
22 
23 
24 def eval_code(code, ns):
25     """
26     Runs a string of code, the last part of which may be an expression.
27     """
28     # handle mis-indented input from multi-line strings
29     code = dedent(code)
30 
31     mod = ast.parse(code)
32     if len(mod.body) == 0:
33         return None
34 
35     if isinstance(mod.body[-1], ast.Expr):
36         expr = ast.Expression(mod.body[-1].value)
37         del mod.body[-1]
38     else:
39         expr = None
40 
41     if len(mod.body):
42         exec(compile(mod, '<exec>', mode='exec'), ns, ns)
43     if expr is not None:
44         return eval(compile(expr, '<eval>', mode='eval'), ns, ns)
45     else:
46         return None
47 
48 
49 def find_imports(code):
50     """
51     Finds the imports in a string of code and returns a list of their package
52     names.
53     """
54     # handle mis-indented input from multi-line strings
55     code = dedent(code)
56 
57     mod = ast.parse(code)
58     imports = set()
59     for node in ast.walk(mod):
60         if isinstance(node, ast.Import):
61             for name in node.names:
62                 name = name.name
63                 imports.add(name.split('.')[0])
64         elif isinstance(node, ast.ImportFrom):
65             name = node.module
66             imports.add(name.split('.')[0])
67     return list(imports)
68 
69 
70 __all__ = ['open_url', 'eval_code', 'find_imports']
71
```
--- 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/src/pyodide.py b/src/pyodide.py
--- a/src/pyodide.py
+++ b/src/pyodide.py
@@ -67,4 +67,16 @@
     return list(imports)
 
 
-__all__ = ['open_url', 'eval_code', 'find_imports']
+def as_nested_list(obj):
+    """
+    Assumes a Javascript object is made of (possibly nested) arrays and
+    converts them to nested Python lists.
+    """
+    try:
+        it = iter(obj)
+        return [as_nested_list(x) for x in it]
+    except TypeError:
+        return obj
+
+
+__all__ = ['open_url', 'eval_code', 'find_imports', 'as_nested_list']

{"golden_diff": "diff --git a/src/pyodide.py b/src/pyodide.py\n--- a/src/pyodide.py\n+++ b/src/pyodide.py\n@@ -67,4 +67,16 @@\n     return list(imports)\n \n \n-__all__ = ['open_url', 'eval_code', 'find_imports']\n+def as_nested_list(obj):\n+    \"\"\"\n+    Assumes a Javascript object is made of (possibly nested) arrays and\n+    converts them to nested Python lists.\n+    \"\"\"\n+    try:\n+        it = iter(obj)\n+        return [as_nested_list(x) for x in it]\n+    except TypeError:\n+        return obj\n+\n+\n+__all__ = ['open_url', 'eval_code', 'find_imports', 'as_nested_list']\n", "issue": "ValueError: invalid __array_struct__ when using js arrays of arrays and numpy\nWhen using a matrix (array of array of numbers) in javascript and trying to convert that to a numpy array, it fails with the error `ValueError: invalid __array_struct__`\r\n\r\nTo reproduce:\r\nJavaScript:\r\n```\r\nwindow.A = [[1,2,3],[4,5,6]];\r\n```\r\nPython:\r\n```\r\nimport numpy\r\nfrom js import A\r\nm = numpy.array(A)\r\n```\n", "before_files": [{"content": "\"\"\"\nA library of helper utilities for connecting Python to the browser environment.\n\"\"\"\n\nimport ast\nimport io\nfrom textwrap import dedent\n\n__version__ = '0.8.2'\n\n\ndef open_url(url):\n    \"\"\"\n    Fetches a given *url* and returns a io.StringIO to access its contents.\n    \"\"\"\n    from js import XMLHttpRequest\n\n    req = XMLHttpRequest.new()\n    req.open('GET', url, False)\n    req.send(None)\n    return io.StringIO(req.response)\n\n\ndef eval_code(code, ns):\n    \"\"\"\n    Runs a string of code, the last part of which may be an expression.\n    \"\"\"\n    # handle mis-indented input from multi-line strings\n    code = dedent(code)\n\n    mod = ast.parse(code)\n    if len(mod.body) == 0:\n        return None\n\n    if isinstance(mod.body[-1], ast.Expr):\n        expr = ast.Expression(mod.body[-1].value)\n        del mod.body[-1]\n    else:\n        expr = None\n\n    if len(mod.body):\n        exec(compile(mod, '<exec>', mode='exec'), ns, ns)\n    if expr is not None:\n        return eval(compile(expr, '<eval>', mode='eval'), ns, ns)\n    else:\n        return None\n\n\ndef find_imports(code):\n    \"\"\"\n    Finds the imports in a string of code and returns a list of their package\n    names.\n    \"\"\"\n    # handle mis-indented input from multi-line strings\n    code = dedent(code)\n\n    mod = ast.parse(code)\n    imports = set()\n    for node in ast.walk(mod):\n        if isinstance(node, ast.Import):\n            for name in node.names:\n                name = name.name\n                imports.add(name.split('.')[0])\n        elif isinstance(node, ast.ImportFrom):\n            name = node.module\n            imports.add(name.split('.')[0])\n    return list(imports)\n\n\n__all__ = ['open_url', 'eval_code', 'find_imports']\n", "path": "src/pyodide.py"}], "after_files": [{"content": "\"\"\"\nA library of helper utilities for connecting Python to the browser environment.\n\"\"\"\n\nimport ast\nimport io\nfrom textwrap import dedent\n\n__version__ = '0.8.2'\n\n\ndef open_url(url):\n    \"\"\"\n    Fetches a given *url* and returns a io.StringIO to access its contents.\n    \"\"\"\n    from js import XMLHttpRequest\n\n    req = XMLHttpRequest.new()\n    req.open('GET', url, False)\n    req.send(None)\n    return io.StringIO(req.response)\n\n\ndef eval_code(code, ns):\n    \"\"\"\n    Runs a string of code, the last part of which may be an expression.\n    \"\"\"\n    # handle mis-indented input from multi-line strings\n    code = dedent(code)\n\n    mod = ast.parse(code)\n    if len(mod.body) == 0:\n        return None\n\n    if isinstance(mod.body[-1], ast.Expr):\n        expr = ast.Expression(mod.body[-1].value)\n        del mod.body[-1]\n    else:\n        expr = None\n\n    if len(mod.body):\n        exec(compile(mod, '<exec>', mode='exec'), ns, ns)\n    if expr is not None:\n        return eval(compile(expr, '<eval>', mode='eval'), ns, ns)\n    else:\n        return None\n\n\ndef find_imports(code):\n    \"\"\"\n    Finds the imports in a string of code and returns a list of their package\n    names.\n    \"\"\"\n    # handle mis-indented input from multi-line strings\n    code = dedent(code)\n\n    mod = ast.parse(code)\n    imports = set()\n    for node in ast.walk(mod):\n        if isinstance(node, ast.Import):\n            for name in node.names:\n                name = name.name\n                imports.add(name.split('.')[0])\n        elif isinstance(node, ast.ImportFrom):\n            name = node.module\n            imports.add(name.split('.')[0])\n    return list(imports)\n\n\ndef as_nested_list(obj):\n    \"\"\"\n    Assumes a Javascript object is made of (possibly nested) arrays and\n    converts them to nested Python lists.\n    \"\"\"\n    try:\n        it = iter(obj)\n        return [as_nested_list(x) for x in it]\n    except TypeError:\n        return obj\n\n\n__all__ = ['open_url', 'eval_code', 'find_imports', 'as_nested_list']\n", "path": "src/pyodide.py"}]}