@@ -11,7 +11,7 @@ msgid ""
11
11
msgstr ""
12
12
"Project-Id-Version : Python 3.12\n "
13
13
"Report-Msgid-Bugs-To : \n "
14
- "POT-Creation-Date : 2025-02-21 14:51 +0000\n "
14
+ "POT-Creation-Date : 2025-06-13 15:39 +0000\n "
15
15
"PO-Revision-Date : 2024-05-11 00:33+0000\n "
16
16
"Last-Translator : Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n "
17
17
"Language-Team : Portuguese (Brazil) (https://app.transifex.com/python-doc/ "
@@ -128,6 +128,13 @@ msgid ""
128
128
">>> libc = cdll.msvcrt\n"
129
129
">>>"
130
130
msgstr ""
131
+ ">>> from ctypes import *\n"
132
+ ">>> print(windll.kernel32)\n"
133
+ "<WinDLL 'kernel32', handle ... at ...>\n"
134
+ ">>> print(cdll.msvcrt)\n"
135
+ "<CDLL 'msvcrt', handle ... at ...>\n"
136
+ ">>> libc = cdll.msvcrt\n"
137
+ ">>>"
131
138
132
139
#: ../../library/ctypes.rst:65
133
140
msgid "Windows appends the usual ``.dll`` file suffix automatically."
@@ -169,6 +176,12 @@ msgid ""
169
176
"<CDLL 'libc.so.6', handle ... at ...>\n"
170
177
">>>"
171
178
msgstr ""
179
+ ">>> cdll.LoadLibrary(\" libc.so.6\" )\n"
180
+ "<CDLL 'libc.so.6', handle ... at ...>\n"
181
+ ">>> libc = CDLL(\" libc.so.6\" )\n"
182
+ ">>> libc\n"
183
+ "<CDLL 'libc.so.6', handle ... at ...>\n"
184
+ ">>>"
172
185
173
186
#: ../../library/ctypes.rst:92
174
187
msgid "Accessing functions from loaded dlls"
@@ -192,6 +205,17 @@ msgid ""
192
205
"AttributeError: function 'MyOwnFunction' not found\n"
193
206
">>>"
194
207
msgstr ""
208
+ ">>> libc.printf\n"
209
+ "<_FuncPtr object at 0x...>\n"
210
+ ">>> print(windll.kernel32.GetModuleHandleA)\n"
211
+ "<_FuncPtr object at 0x...>\n"
212
+ ">>> print(windll.kernel32.MyOwnFunction)\n"
213
+ "Traceback (most recent call last):\n"
214
+ " File \" <stdin>\" , line 1, in <module>\n"
215
+ " File \" ctypes.py\" , line 239, in __getattr__\n"
216
+ " func = _StdcallFuncPtr(name, self)\n"
217
+ "AttributeError: function 'MyOwnFunction' not found\n"
218
+ ">>>"
195
219
196
220
#: ../../library/ctypes.rst:108
197
221
msgid ""
@@ -203,6 +227,13 @@ msgid ""
203
227
"following C prototype, and a macro is used to expose one of them as "
204
228
"``GetModuleHandle`` depending on whether UNICODE is defined or not::"
205
229
msgstr ""
230
+ "Observe que DLLs de sistema do Win32, como ``kernel32`` e ``user32``, "
231
+ "frequentemente exportam versões ANSI e UNICODE de uma função. A versão "
232
+ "UNICODE é exportada com um ``W`` anexado ao nome, enquanto a versão ANSI é "
233
+ "exportada com um ``A`` anexado ao nome. A função ``GetModuleHandle`` do "
234
+ "Win32, que retorna um *identificador de módulo* para um determinado nome de "
235
+ "módulo, tem o seguinte protótipo em C, e uma macro é usada para expor um "
236
+ "deles como ``GetModuleHandle``, dependendo se UNICODE está definido ou não:"
206
237
207
238
#: ../../library/ctypes.rst:116
208
239
msgid ""
@@ -211,27 +242,40 @@ msgid ""
211
242
"/* UNICODE version */\n"
212
243
"HMODULE GetModuleHandleW(LPCWSTR lpModuleName);"
213
244
msgstr ""
245
+ "/* versão ANSI */\n"
246
+ "HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n"
247
+ "/* versão UNICODE */\n"
248
+ "HMODULE GetModuleHandleW(LPCWSTR lpModuleName);"
214
249
215
250
#: ../../library/ctypes.rst:121
216
251
msgid ""
217
252
"*windll* does not try to select one of them by magic, you must access the "
218
253
"version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW`` "
219
254
"explicitly, and then call it with bytes or string objects respectively."
220
255
msgstr ""
256
+ "*windll* não tenta selecionar um deles magicamente, você deve acessar a "
257
+ "versão necessária especificando ``GetModuleHandleA`` ou ``GetModuleHandleW`` "
258
+ "explicitamente e então chamá-lo com objetos bytes ou string, respectivamente."
221
259
222
260
#: ../../library/ctypes.rst:125
223
261
msgid ""
224
262
"Sometimes, dlls export functions with names which aren't valid Python "
225
263
"identifiers, like ``\" ??2@YAPAXI@Z\" ``. In this case you have to use :func:"
226
264
"`getattr` to retrieve the function::"
227
265
msgstr ""
266
+ "Às vezes, DLLs exportam funções com nomes que não são identificadores Python "
267
+ "válidos, como ``\" ??2@YAPAXI@Z\" ``. Nesse caso, você precisa usar :func:"
268
+ "`getattr` para recuperar a função::"
228
269
229
270
#: ../../library/ctypes.rst:129
230
271
msgid ""
231
272
">>> getattr(cdll.msvcrt, \" ??2@YAPAXI@Z\" )\n"
232
273
"<_FuncPtr object at 0x...>\n"
233
274
">>>"
234
275
msgstr ""
276
+ ">>> getattr(cdll.msvcrt, \" ??2@YAPAXI@Z\" )\n"
277
+ "<_FuncPtr object at 0x...>\n"
278
+ ">>>"
235
279
236
280
#: ../../library/ctypes.rst:133
237
281
msgid ""
@@ -255,43 +299,65 @@ msgid ""
255
299
"AttributeError: function ordinal 0 not found\n"
256
300
">>>"
257
301
msgstr ""
302
+ ">>> cdll.kernel32[1]\n"
303
+ "<_FuncPtr object at 0x...>\n"
304
+ ">>> cdll.kernel32[0]\n"
305
+ "Traceback (most recent call last):\n"
306
+ " File \" <stdin>\" , line 1, in <module>\n"
307
+ " File \" ctypes.py\" , line 310, in __getitem__\n"
308
+ " func = _StdcallFuncPtr(name, self)\n"
309
+ "AttributeError: function ordinal 0 not found\n"
310
+ ">>>"
258
311
259
312
#: ../../library/ctypes.rst:150
260
313
msgid "Calling functions"
261
- msgstr ""
314
+ msgstr "Chamando funções "
262
315
263
316
#: ../../library/ctypes.rst:152
264
317
msgid ""
265
318
"You can call these functions like any other Python callable. This example "
266
319
"uses the ``rand()`` function, which takes no arguments and returns a pseudo-"
267
320
"random integer::"
268
321
msgstr ""
322
+ "Você pode chamar essas funções como qualquer outro chamável do Python. Este "
323
+ "exemplo usa a função ``rand()``, que não aceita argumentos e retorna um "
324
+ "inteiro pseudoaleatório:"
269
325
270
326
#: ../../library/ctypes.rst:155
271
327
msgid ""
272
328
">>> print(libc.rand())\n"
273
329
"1804289383"
274
330
msgstr ""
331
+ ">>> print(libc.rand())\n"
332
+ "1804289383"
275
333
276
334
#: ../../library/ctypes.rst:158
277
335
msgid ""
278
336
"On Windows, you can call the ``GetModuleHandleA()`` function, which returns "
279
337
"a win32 module handle (passing ``None`` as single argument to call it with a "
280
338
"``NULL`` pointer)::"
281
339
msgstr ""
340
+ "No Windows, você pode chamar a função ``GetModuleHandleA()``, que retorna um "
341
+ "identificador de módulo win32 (passando ``None`` como único argumento para "
342
+ "chamá-lo com um ponteiro ``NULL``)::"
282
343
283
344
#: ../../library/ctypes.rst:161
284
345
msgid ""
285
346
">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n"
286
347
"0x1d000000\n"
287
348
">>>"
288
349
msgstr ""
350
+ ">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n"
351
+ "0x1d000000\n"
352
+ ">>>"
289
353
290
354
#: ../../library/ctypes.rst:165
291
355
msgid ""
292
356
":exc:`ValueError` is raised when you call an ``stdcall`` function with the "
293
357
"``cdecl`` calling convention, or vice versa::"
294
358
msgstr ""
359
+ ":exc:`ValueError` é gerado quando você chama uma função ``stdcall`` com a "
360
+ "convenção de chamada ``cdecl``, ou vice-versa::"
295
361
296
362
#: ../../library/ctypes.rst:168
297
363
msgid ""
@@ -309,19 +375,37 @@ msgid ""
309
375
"excess)\n"
310
376
">>>"
311
377
msgstr ""
378
+ ">>> cdll.kernel32.GetModuleHandleA(None)\n"
379
+ "Traceback (most recent call last):\n"
380
+ " File \" <stdin>\" , line 1, in <module>\n"
381
+ "ValueError: Procedure probably called with not enough arguments (4 bytes "
382
+ "missing)\n"
383
+ ">>>\n"
384
+ "\n"
385
+ ">>> windll.msvcrt.printf(b\" spam\" )\n"
386
+ "Traceback (most recent call last):\n"
387
+ " File \" <stdin>\" , line 1, in <module>\n"
388
+ "ValueError: Procedure probably called with too many arguments (4 bytes in "
389
+ "excess)\n"
390
+ ">>>"
312
391
313
392
#: ../../library/ctypes.rst:180
314
393
msgid ""
315
394
"To find out the correct calling convention you have to look into the C "
316
395
"header file or the documentation for the function you want to call."
317
396
msgstr ""
397
+ "Para descobrir a convenção de chamada correta, você precisa consultar o "
398
+ "arquivo de cabeçalho C ou a documentação da função que deseja chamar."
318
399
319
400
#: ../../library/ctypes.rst:183
320
401
msgid ""
321
402
"On Windows, :mod:`ctypes` uses win32 structured exception handling to "
322
403
"prevent crashes from general protection faults when functions are called "
323
404
"with invalid argument values::"
324
405
msgstr ""
406
+ "No Windows, :mod:`ctypes` usa o tratamento de exceções estruturado do win32 "
407
+ "para evitar travamentos devido a falhas gerais de proteção quando funções "
408
+ "são chamadas com valores de argumentos inválidos::"
325
409
326
410
#: ../../library/ctypes.rst:187
327
411
msgid ""
@@ -331,6 +415,11 @@ msgid ""
331
415
"OSError: exception: access violation reading 0x00000020\n"
332
416
">>>"
333
417
msgstr ""
418
+ ">>> windll.kernel32.GetModuleHandleA(32)\n"
419
+ "Traceback (most recent call last):\n"
420
+ " File \" <stdin>\" , line 1, in <module>\n"
421
+ "OSError: exception: access violation reading 0x00000020\n"
422
+ ">>>"
334
423
335
424
#: ../../library/ctypes.rst:193
336
425
msgid ""
@@ -339,6 +428,10 @@ msgid ""
339
428
"debugging crashes (e.g. from segmentation faults produced by erroneous C "
340
429
"library calls)."
341
430
msgstr ""
431
+ "No entanto, existem maneiras suficientes de travar o Python com :mod:"
432
+ "`ctypes`, então você deve ter cuidado de qualquer maneira. O módulo :mod:"
433
+ "`faulthandler` pode ser útil na depuração de travamentos (por exemplo, de "
434
+ "falhas de segmentação produzidas por chamadas errôneas da biblioteca C)."
342
435
343
436
#: ../../library/ctypes.rst:198
344
437
msgid ""
0 commit comments