Skip to content

Commit f8ceebc

Browse files
committed
Fixed recipe 5.3.
1 parent fe01a4a commit f8ceebc

File tree

1 file changed

+17
-47
lines changed

1 file changed

+17
-47
lines changed

notebooks/chapter05_hpc/03_ctypes.ipynb

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:60711b6950fb35c6487a5512e30319cef20b61947da3e4191f0d519b168abb14"
4+
"signature": "sha256:0912cd4ebe8809197d28a717a26315f3d3ea8aeeb5846d224925eaaad7491c6d"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -98,16 +98,7 @@
9898
],
9999
"language": "python",
100100
"metadata": {},
101-
"outputs": [
102-
{
103-
"output_type": "stream",
104-
"stream": "stdout",
105-
"text": [
106-
"Writing mandelbrot.c\n"
107-
]
108-
}
109-
],
110-
"prompt_number": 1
101+
"outputs": []
111102
},
112103
{
113104
"cell_type": "markdown",
@@ -124,26 +115,7 @@
124115
],
125116
"language": "python",
126117
"metadata": {},
127-
"outputs": [
128-
{
129-
"output_type": "stream",
130-
"stream": "stdout",
131-
"text": [
132-
"mandelbrot.c\n",
133-
"mandelbrot.c(5) : fatal error C1034: stdio.h: no include path set\n"
134-
]
135-
},
136-
{
137-
"output_type": "stream",
138-
"stream": "stderr",
139-
"text": [
140-
"Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64\n",
141-
"Copyright (C) Microsoft Corporation. All rights reserved.\n",
142-
"\n"
143-
]
144-
}
145-
],
146-
"prompt_number": 2
118+
"outputs": []
147119
},
148120
{
149121
"cell_type": "markdown",
@@ -167,8 +139,7 @@
167139
],
168140
"language": "python",
169141
"metadata": {},
170-
"outputs": [],
171-
"prompt_number": 3
142+
"outputs": []
172143
},
173144
{
174145
"cell_type": "code",
@@ -178,20 +149,7 @@
178149
],
179150
"language": "python",
180151
"metadata": {},
181-
"outputs": [
182-
{
183-
"ename": "OSError",
184-
"evalue": "[WinError 126] Le module sp\u00e9cifi\u00e9 est introuvable",
185-
"output_type": "pyerr",
186-
"traceback": [
187-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mOSError\u001b[0m Traceback (most recent call last)",
188-
"\u001b[1;32m<ipython-input-4-d3932722f6f3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mlb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mctypes\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mCDLL\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'mandelbrot.dll'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
189-
"\u001b[1;32mP:\\anaconda\\lib\\ctypes\\__init__.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, name, mode, handle, use_errno, use_last_error)\u001b[0m\n\u001b[0;32m 349\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 350\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mhandle\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 351\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_handle\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_dlopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_name\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 352\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 353\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_handle\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mhandle\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
190-
"\u001b[1;31mOSError\u001b[0m: [WinError 126] Le module sp\u00e9cifi\u00e9 est introuvable"
191-
]
192-
}
193-
],
194-
"prompt_number": 4
152+
"outputs": []
195153
},
196154
{
197155
"cell_type": "code",
@@ -319,6 +277,18 @@
319277
"cell_type": "code",
320278
"collapsed": false,
321279
"input": [
280+
"lb._handle"
281+
],
282+
"language": "python",
283+
"metadata": {},
284+
"outputs": []
285+
},
286+
{
287+
"cell_type": "code",
288+
"collapsed": false,
289+
"input": [
290+
"from ctypes.wintypes import HMODULE\n",
291+
"ctypes.windll.kernel32.FreeLibrary.argtypes = [HMODULE]\n",
322292
"ctypes.windll.kernel32.FreeLibrary(lb._handle);"
323293
],
324294
"language": "python",

0 commit comments

Comments
 (0)