@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.12\n "
1313"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 "
1515"PO-Revision-Date : 2024-05-11 00:33+0000\n "
1616"Last-Translator : Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n "
1717"Language-Team : Portuguese (Brazil) (https://app.transifex.com/python-doc/ "
@@ -128,6 +128,13 @@ msgid ""
128128">>> libc = cdll.msvcrt\n"
129129">>>"
130130msgstr ""
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+ ">>>"
131138
132139#: ../../library/ctypes.rst:65
133140msgid "Windows appends the usual ``.dll`` file suffix automatically."
@@ -169,6 +176,12 @@ msgid ""
169176"<CDLL 'libc.so.6', handle ... at ...>\n"
170177">>>"
171178msgstr ""
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+ ">>>"
172185
173186#: ../../library/ctypes.rst:92
174187msgid "Accessing functions from loaded dlls"
@@ -192,6 +205,17 @@ msgid ""
192205"AttributeError: function 'MyOwnFunction' not found\n"
193206">>>"
194207msgstr ""
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+ ">>>"
195219
196220#: ../../library/ctypes.rst:108
197221msgid ""
@@ -203,6 +227,13 @@ msgid ""
203227"following C prototype, and a macro is used to expose one of them as "
204228"``GetModuleHandle`` depending on whether UNICODE is defined or not::"
205229msgstr ""
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:"
206237
207238#: ../../library/ctypes.rst:116
208239msgid ""
@@ -211,27 +242,40 @@ msgid ""
211242"/* UNICODE version */\n"
212243"HMODULE GetModuleHandleW(LPCWSTR lpModuleName);"
213244msgstr ""
245+ "/* versão ANSI */\n"
246+ "HMODULE GetModuleHandleA(LPCSTR lpModuleName);\n"
247+ "/* versão UNICODE */\n"
248+ "HMODULE GetModuleHandleW(LPCWSTR lpModuleName);"
214249
215250#: ../../library/ctypes.rst:121
216251msgid ""
217252"*windll* does not try to select one of them by magic, you must access the "
218253"version you need by specifying ``GetModuleHandleA`` or ``GetModuleHandleW`` "
219254"explicitly, and then call it with bytes or string objects respectively."
220255msgstr ""
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."
221259
222260#: ../../library/ctypes.rst:125
223261msgid ""
224262"Sometimes, dlls export functions with names which aren't valid Python "
225263"identifiers, like ``\" ??2@YAPAXI@Z\" ``. In this case you have to use :func:"
226264"`getattr` to retrieve the function::"
227265msgstr ""
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::"
228269
229270#: ../../library/ctypes.rst:129
230271msgid ""
231272">>> getattr(cdll.msvcrt, \" ??2@YAPAXI@Z\" )\n"
232273"<_FuncPtr object at 0x...>\n"
233274">>>"
234275msgstr ""
276+ ">>> getattr(cdll.msvcrt, \" ??2@YAPAXI@Z\" )\n"
277+ "<_FuncPtr object at 0x...>\n"
278+ ">>>"
235279
236280#: ../../library/ctypes.rst:133
237281msgid ""
@@ -255,43 +299,65 @@ msgid ""
255299"AttributeError: function ordinal 0 not found\n"
256300">>>"
257301msgstr ""
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+ ">>>"
258311
259312#: ../../library/ctypes.rst:150
260313msgid "Calling functions"
261- msgstr ""
314+ msgstr "Chamando funções "
262315
263316#: ../../library/ctypes.rst:152
264317msgid ""
265318"You can call these functions like any other Python callable. This example "
266319"uses the ``rand()`` function, which takes no arguments and returns a pseudo-"
267320"random integer::"
268321msgstr ""
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:"
269325
270326#: ../../library/ctypes.rst:155
271327msgid ""
272328">>> print(libc.rand())\n"
273329"1804289383"
274330msgstr ""
331+ ">>> print(libc.rand())\n"
332+ "1804289383"
275333
276334#: ../../library/ctypes.rst:158
277335msgid ""
278336"On Windows, you can call the ``GetModuleHandleA()`` function, which returns "
279337"a win32 module handle (passing ``None`` as single argument to call it with a "
280338"``NULL`` pointer)::"
281339msgstr ""
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``)::"
282343
283344#: ../../library/ctypes.rst:161
284345msgid ""
285346">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n"
286347"0x1d000000\n"
287348">>>"
288349msgstr ""
350+ ">>> print(hex(windll.kernel32.GetModuleHandleA(None)))\n"
351+ "0x1d000000\n"
352+ ">>>"
289353
290354#: ../../library/ctypes.rst:165
291355msgid ""
292356":exc:`ValueError` is raised when you call an ``stdcall`` function with the "
293357"``cdecl`` calling convention, or vice versa::"
294358msgstr ""
359+ ":exc:`ValueError` é gerado quando você chama uma função ``stdcall`` com a "
360+ "convenção de chamada ``cdecl``, ou vice-versa::"
295361
296362#: ../../library/ctypes.rst:168
297363msgid ""
@@ -309,19 +375,37 @@ msgid ""
309375"excess)\n"
310376">>>"
311377msgstr ""
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+ ">>>"
312391
313392#: ../../library/ctypes.rst:180
314393msgid ""
315394"To find out the correct calling convention you have to look into the C "
316395"header file or the documentation for the function you want to call."
317396msgstr ""
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."
318399
319400#: ../../library/ctypes.rst:183
320401msgid ""
321402"On Windows, :mod:`ctypes` uses win32 structured exception handling to "
322403"prevent crashes from general protection faults when functions are called "
323404"with invalid argument values::"
324405msgstr ""
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::"
325409
326410#: ../../library/ctypes.rst:187
327411msgid ""
@@ -331,6 +415,11 @@ msgid ""
331415"OSError: exception: access violation reading 0x00000020\n"
332416">>>"
333417msgstr ""
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+ ">>>"
334423
335424#: ../../library/ctypes.rst:193
336425msgid ""
@@ -339,6 +428,10 @@ msgid ""
339428"debugging crashes (e.g. from segmentation faults produced by erroneous C "
340429"library calls)."
341430msgstr ""
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)."
342435
343436#: ../../library/ctypes.rst:198
344437msgid ""
0 commit comments