Skip to content

Commit a9f3b8f

Browse files
Update translations
1 parent 42358b9 commit a9f3b8f

File tree

10 files changed

+504
-51
lines changed

10 files changed

+504
-51
lines changed

library/os.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgid ""
1111
msgstr ""
1212
"Project-Id-Version: Python 3.12\n"
1313
"Report-Msgid-Bugs-To: \n"
14-
"POT-Creation-Date: 2025-05-16 15:32+0000\n"
14+
"POT-Creation-Date: 2025-06-06 15:34+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/"
@@ -2429,7 +2429,7 @@ msgid ""
24292429
"sense to block because there are no writers connected to the write end of "
24302430
"the pipe."
24312431
msgstr ""
2432-
"Após a conclusão bem-sucedida, retorna o número de bytes unidos ao "
2432+
"Após a conclusão bem-sucedida, retorna o número de bytes unidos ao "
24332433
"encadeamento ou a partir dele. Um valor de retorno de 0 significa o fim da "
24342434
"entrada. Se *src* se refere a um encadeamento, isso significa que não havia "
24352435
"dados para transferir, e não faria sentido bloquear porque não há escritores "

library/pickle.po

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ msgid ""
1111
msgstr ""
1212
"Project-Id-Version: Python 3.12\n"
1313
"Report-Msgid-Bugs-To: \n"
14-
"POT-Creation-Date: 2025-05-02 14:54+0000\n"
14+
"POT-Creation-Date: 2025-06-06 15:34+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/"
@@ -1881,6 +1881,44 @@ msgid ""
18811881
" # Finally, save the file.\n"
18821882
" self.file = file"
18831883
msgstr ""
1884+
"class TextReader:\n"
1885+
" \"\"\"Exibe e numera linhas em um arquivo texto.\"\"\"\n"
1886+
"\n"
1887+
" def __init__(self, filename):\n"
1888+
" self.filename = filename\n"
1889+
" self.file = open(filename)\n"
1890+
" self.lineno = 0\n"
1891+
"\n"
1892+
" def readline(self):\n"
1893+
" self.lineno += 1\n"
1894+
" line = self.file.readline()\n"
1895+
" if not line:\n"
1896+
" return None\n"
1897+
" if line.endswith('\\n'):\n"
1898+
" line = line[:-1]\n"
1899+
" return \"%i: %s\" % (self.lineno, line)\n"
1900+
"\n"
1901+
" def __getstate__(self):\n"
1902+
" # Copia o estado do objeto de self.__dict__, que \n"
1903+
" # contém todos os nossos atributos de instância.\n"
1904+
" # Sempre use o método dict.copy() para evitar\n"
1905+
" # modificar o estado original.\n"
1906+
" state = self.__dict__.copy()\n"
1907+
" # Remove as entradas não serializáveis com pickle.\n"
1908+
" del state['file']\n"
1909+
" return state\n"
1910+
"\n"
1911+
" def __setstate__(self, state):\n"
1912+
" # Restaura os atributos da instância (isto é, filename e lineno).\n"
1913+
" self.__dict__.update(state)\n"
1914+
" # Restaura o estado do arquivo aberto anteriormente.\n"
1915+
" # Para fazer isso, precisamos reabri-lo e ler dele até\n"
1916+
" # a contagem de linha ser restaurada.\n"
1917+
" file = open(self.filename)\n"
1918+
" for _ in range(self.lineno):\n"
1919+
" file.readline()\n"
1920+
" # Ao final, salva o arquivo.\n"
1921+
" self.file = file"
18841922

18851923
#: ../../library/pickle.rst:874
18861924
msgid "A sample usage might be something like this::"
@@ -2180,6 +2218,26 @@ msgid ""
21802218
" else:\n"
21812219
" return cls(obj)"
21822220
msgstr ""
2221+
"class ZeroCopyByteArray(bytearray):\n"
2222+
"\n"
2223+
" def __reduce_ex__(self, protocol):\n"
2224+
" if protocol >= 5:\n"
2225+
" return type(self)._reconstruct, (PickleBuffer(self),), None\n"
2226+
" else:\n"
2227+
" # PickleBuffer é proibido no pickle nos protocolos <= 4.\n"
2228+
" return type(self)._reconstruct, (bytearray(self),)\n"
2229+
"\n"
2230+
" @classmethod\n"
2231+
" def _reconstruct(cls, obj):\n"
2232+
" with memoryview(obj) as m:\n"
2233+
" # Obtém um controle sobre o objeto buffer original\n"
2234+
" obj = m.obj\n"
2235+
" if type(obj) is cls:\n"
2236+
" # O objeto do buffer original é um ZeroCopyByteArray,\n"
2237+
" # retorna-o como está.\n"
2238+
" return obj\n"
2239+
" else:\n"
2240+
" return cls(obj)"
21832241

21842242
#: ../../library/pickle.rst:1031
21852243
msgid ""
@@ -2207,6 +2265,11 @@ msgid ""
22072265
"print(b == new_b) # True\n"
22082266
"print(b is new_b) # False: a copy was made"
22092267
msgstr ""
2268+
"b = ZeroCopyByteArray(b\"abc\")\n"
2269+
"data = pickle.dumps(b, protocol=5)\n"
2270+
"new_b = pickle.loads(data)\n"
2271+
"print(b == new_b) # True\n"
2272+
"print(b is new_b) # False: uma cópia foi feita"
22102273

22112274
#: ../../library/pickle.rst:1044
22122275
msgid ""
@@ -2225,6 +2288,12 @@ msgid ""
22252288
"print(b == new_b) # True\n"
22262289
"print(b is new_b) # True: no copy was made"
22272290
msgstr ""
2291+
"b = ZeroCopyByteArray(b\"abc\")\n"
2292+
"buffers = []\n"
2293+
"data = pickle.dumps(b, protocol=5, buffer_callback=buffers.append)\n"
2294+
"new_b = pickle.loads(data, buffers=buffers)\n"
2295+
"print(b == new_b) # True\n"
2296+
"print(b is new_b) # True: nenhuma cópia foi feita"
22282297

22292298
#: ../../library/pickle.rst:1054
22302299
msgid ""
@@ -2336,6 +2405,31 @@ msgid ""
23362405
" \"\"\"Helper function analogous to pickle.loads().\"\"\"\n"
23372406
" return RestrictedUnpickler(io.BytesIO(s)).load()"
23382407
msgstr ""
2408+
"import builtins\n"
2409+
"import io\n"
2410+
"import pickle\n"
2411+
"\n"
2412+
"safe_builtins = {\n"
2413+
" 'range',\n"
2414+
" 'complex',\n"
2415+
" 'set',\n"
2416+
" 'frozenset',\n"
2417+
" 'slice',\n"
2418+
"}\n"
2419+
"\n"
2420+
"class RestrictedUnpickler(pickle.Unpickler):\n"
2421+
"\n"
2422+
" def find_class(self, module, name):\n"
2423+
" # Só permite classes seguras de bultins.\n"
2424+
" if module == \"builtins\" and name in safe_builtins:\n"
2425+
" return getattr(builtins, name)\n"
2426+
" # Proíbe todo o resto.\n"
2427+
" raise pickle.UnpicklingError(\"global '%s.%s' is forbidden\" %\n"
2428+
" (module, name))\n"
2429+
"\n"
2430+
"def restricted_loads(s):\n"
2431+
" \"\"\"Função auxiliar análoga a pickle.loads().\"\"\"\n"
2432+
" return RestrictedUnpickler(io.BytesIO(s)).load()"
23392433

23402434
#: ../../library/pickle.rst:1121
23412435
msgid "A sample usage of our unpickler working as intended::"
@@ -2356,6 +2450,18 @@ msgid ""
23562450
" ...\n"
23572451
"pickle.UnpicklingError: global 'builtins.eval' is forbidden"
23582452
msgstr ""
2453+
">>> restricted_loads(pickle.dumps([1, 2, range(15)]))\n"
2454+
"[1, 2, range(0, 15)]\n"
2455+
">>> restricted_loads(b\"cos\\nsystem\\n(S'echo hello world'\\ntR.\")\n"
2456+
"Traceback (most recent call last):\n"
2457+
" ...\n"
2458+
"pickle.UnpicklingError: global 'os.system' is forbidden\n"
2459+
">>> restricted_loads(b'cbuiltins\\neval\\n'\n"
2460+
"... b'(S\\'getattr(__import__(\"os\"), \"system\")'\n"
2461+
"... b'(\"echo hello world\")\\'\\ntR.')\n"
2462+
"Traceback (most recent call last):\n"
2463+
" ...\n"
2464+
"pickle.UnpicklingError: global 'builtins.eval' is forbidden"
23592465

23602466
#: ../../library/pickle.rst:1140
23612467
msgid ""
@@ -2409,6 +2515,19 @@ msgid ""
24092515
" # Pickle the 'data' dictionary using the highest protocol available.\n"
24102516
" pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)"
24112517
msgstr ""
2518+
"import pickle\n"
2519+
"\n"
2520+
"# Uma coleção arbitrária de objetos aceitos por pickle.\n"
2521+
"data = {\n"
2522+
" 'a': [1, 2.0, 3+4j],\n"
2523+
" 'b': (\"character string\", b\"byte string\"),\n"
2524+
" 'c': {None, True, False}\n"
2525+
"}\n"
2526+
"\n"
2527+
"with open('data.pickle', 'wb') as f:\n"
2528+
" # Serializa com pickle o dicionário 'data' usando\n"
2529+
" # o protocolo mais alto disponível.\n"
2530+
" pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)"
24122531

24132532
#: ../../library/pickle.rst:1175
24142533
msgid "The following example reads the resulting pickled data. ::"
@@ -2424,6 +2543,12 @@ msgid ""
24242543
" # have to specify it.\n"
24252544
" data = pickle.load(f)"
24262545
msgstr ""
2546+
"import pickle\n"
2547+
"\n"
2548+
"with open('data.pickle', 'rb') as f:\n"
2549+
" # A versão do protocolo utilizada é detectada automaticamente,\n"
2550+
" # portanto não precisamos especificá-la.\n"
2551+
" data = pickle.load(f)"
24272552

24282553
#: ../../library/pickle.rst:1191
24292554
msgid "Module :mod:`copyreg`"

0 commit comments

Comments
 (0)