2
2
# This file is distributed under the same license as the Python package.
3
3
#
4
4
# Translators:
5
+ # Skylull, 2024
5
6
msgid ""
6
7
msgstr ""
7
8
"Project-Id-Version : Python 3.12\n "
@@ -25,6 +26,14 @@ msgstr ":mod:`!pickle` --- Python 物件序列化"
25
26
msgid "**Source code:** :source:`Lib/pickle.py`"
26
27
msgstr "**原始碼:**\\ :source:`Lib/pickle.py`"
27
28
29
+ # Skylull: 我對 `pickle` 的命名原因進行了簡單的搜尋,只找到一則討論
30
+ # https://stackoverflow.com/questions/27324986/pickles-why-are-they-called-
31
+ # that
32
+ # 其中表示這名字很可能只是為了隨便找一個p開頭的單字、或原始開發人員的內部玩笑造成的約定俗成。也有人表示醃製黃瓜(pickle-
33
+ # ing)的目標就是保存和存放,所以取了這個名字。
34
+ # 無論如何似乎沒有一個定論。
35
+ # 因為不確定是否與醃漬的這個梗有關,我暫時選擇使用 `封裝` 與 `拆封` 作為譯文,大致保存那個把東西處裡後裝起來的感覺但又不至於太奇怪。
36
+ # 唯一需要擔心的是是否有與 `encapsulation` (封裝,網路協定名詞)或 `package`(封包,網路協定名詞)搞混的可能。
28
37
#: ../../library/pickle.rst:22
29
38
msgid ""
30
39
"The :mod:`pickle` module implements binary protocols for serializing and de-"
@@ -36,29 +45,40 @@ msgid ""
36
45
"\" serialization\" , \" marshalling,\" [#]_ or \" flattening\" ; however, to "
37
46
"avoid confusion, the terms used here are \" pickling\" and \" unpickling\" ."
38
47
msgstr ""
48
+ ":mod:`pickle` 模組實作的是一個在二進位層級上對 Python 物件進行序列化"
49
+ "(serialize)或去序列化(de-serialize)。*\" Pickling\" * 用於專門指摘將一個 "
50
+ "Python 物件轉換為一個二進位串流的過程,*\" unpickling\" * 則相反,指的是將一個"
51
+ "(來自 :term:`binary file` 或 :term:`bytes-like object` 的)二進位串流轉換回 "
52
+ "Python 物件的過程。Pickling(和 unpickling)的過程也可能被稱作 "
53
+ "\" serialization\" , \" marshalling,\" [#]_ 或 \" flattening\" 。不過,為了避免混"
54
+ "淆,本文件將統一稱作封裝(pickling)、拆封(unpickling)。"
39
55
40
56
#: ../../library/pickle.rst:33
41
57
msgid "The ``pickle`` module **is not secure**. Only unpickle data you trust."
42
- msgstr ""
58
+ msgstr "``pickle`` 模組**並不安全**,切記只拆封你信任的資料。 "
43
59
44
60
#: ../../library/pickle.rst:35
45
61
msgid ""
46
62
"It is possible to construct malicious pickle data which will **execute "
47
63
"arbitrary code during unpickling**. Never unpickle data that could have come "
48
64
"from an untrusted source, or that could have been tampered with."
49
65
msgstr ""
66
+ "pickle 封包是有可能被建立來在拆封的時候**執行任意惡意程式碼**的。絕對不要拆封"
67
+ "任何你無法信任其來源、或可能被修改過的 pickle 封包。"
50
68
51
69
#: ../../library/pickle.rst:39
52
70
msgid ""
53
71
"Consider signing data with :mod:`hmac` if you need to ensure that it has not "
54
72
"been tampered with."
55
- msgstr ""
73
+ msgstr "建議你可以使用 :mod:`hmac` 模組來簽署這個封包,以確保其未被修改過。 "
56
74
57
75
#: ../../library/pickle.rst:42
58
76
msgid ""
59
77
"Safer serialization formats such as :mod:`json` may be more appropriate if "
60
78
"you are processing untrusted data. See :ref:`comparison-with-json`."
61
79
msgstr ""
80
+ "如果你在處理不受信任的資料,其他比較安全的序列化格式(例如 :mod:`json`)可能"
81
+ "會更適合。請參照 See :ref:`comparison-with-json` 的說明。"
62
82
63
83
#: ../../library/pickle.rst:47
64
84
msgid "Relationship to other Python modules"
@@ -75,19 +95,24 @@ msgid ""
75
95
"Python objects. :mod:`marshal` exists primarily to support Python's :file:`."
76
96
"pyc` files."
77
97
msgstr ""
98
+ "Python 有另一個比較原始的序列化模組叫 :mod:`marshal`,不過其設計目的是為了支"
99
+ "援 Python 的預編譯功能 :file:`.pyc` 運作。總地來說,沒事不要用 :mod:"
100
+ "`marshal`。"
78
101
79
102
#: ../../library/pickle.rst:57
80
103
msgid ""
81
104
"The :mod:`pickle` module differs from :mod:`marshal` in several significant "
82
105
"ways:"
83
- msgstr ""
106
+ msgstr ":mod:`pickle` 和 :mod:`marshal` 有幾個明顯不同的地方: "
84
107
85
108
#: ../../library/pickle.rst:59
86
109
msgid ""
87
110
"The :mod:`pickle` module keeps track of the objects it has already "
88
111
"serialized, so that later references to the same object won't be serialized "
89
112
"again. :mod:`marshal` doesn't do this."
90
113
msgstr ""
114
+ ":mod:`pickle` 會記住哪些物件已經被序列化過了,稍後再次參照到這個物件的時候才"
115
+ "不會進行重複的序列化。:mod:`marshal` 沒有這個功能。"
91
116
92
117
#: ../../library/pickle.rst:63
93
118
msgid ""
@@ -101,6 +126,11 @@ msgid ""
101
126
"Shared objects remain shared, which can be very important for mutable "
102
127
"objects."
103
128
msgstr ""
129
+ "這對遞迴物件和物件共用都有影響。遞迴物件是指包含自我參照的物件。這些情況在 "
130
+ "marshal 模組中不會被處理,若嘗試使用 marshal 處理遞迴物件會導致 Python 直譯器"
131
+ "崩潰。物件共用發生在序列化的物件階層中,不同位置對同一物件有多個參照時。:mod:"
132
+ "`pickle` 只會儲存這個被參照的物件一次,並確保所有其他參照指向這個主要的版本。"
133
+ "共用的物件會保持共用,這對於可變(mutable)物件來說非常重要。"
104
134
105
135
#: ../../library/pickle.rst:72
106
136
msgid ""
@@ -109,6 +139,9 @@ msgid ""
109
139
"transparently, however the class definition must be importable and live in "
110
140
"the same module as when the object was stored."
111
141
msgstr ""
142
+ ":mod:`marshal` 無法序列化使用者自訂的類別和的實例。:mod:`pickle` 則可以讓使用"
143
+ "者儲存並還原自訂的類別實例,前提是儲存時該類別的定義存在於與要被儲存的物件所"
144
+ "在的模組中、且可以被引入(import)。"
112
145
113
146
#: ../../library/pickle.rst:77
114
147
msgid ""
@@ -122,6 +155,11 @@ msgid ""
122
155
"differences if your data is crossing that unique breaking change language "
123
156
"boundary."
124
157
msgstr ""
158
+ ":mod:`marshal` 序列化格式無法保證能在不同版本的 Python 之間移植。因為其主要的"
159
+ "作用是支援 :file:`.pyc` 檔案的運作,Python 的實作人員會在需要時實作無法前向相"
160
+ "容的序列化方式。但只要選擇了相容的 pickle 協定,且處理了 Python 2 和 Python "
161
+ "3 之間的資料類型差異,:mod:`pickle` 序列化協定能保證在不同 Python 版本間的相"
162
+ "容性。"
125
163
126
164
#: ../../library/pickle.rst:90
127
165
msgid "Comparison with ``json``"
@@ -132,24 +170,34 @@ msgid ""
132
170
"There are fundamental differences between the pickle protocols and `JSON "
133
171
"(JavaScript Object Notation) <https://json.org>`_:"
134
172
msgstr ""
173
+ "pickle 協定和 `JSON (JavaScript Object Notation) <https://json.org>`_ 有一些"
174
+ "根本上的不同:"
135
175
136
176
#: ../../library/pickle.rst:95
137
177
msgid ""
138
178
"JSON is a text serialization format (it outputs unicode text, although most "
139
179
"of the time it is then encoded to ``utf-8``), while pickle is a binary "
140
180
"serialization format;"
141
181
msgstr ""
182
+ "JSON 以文字形式作為序列化的輸出(輸出 unicode 文字,但大多數又會被編碼為 "
183
+ "``UTF-8``),而 pickle 則是以二進位形式作為序列化的輸出;"
142
184
143
185
#: ../../library/pickle.rst:99
144
186
msgid "JSON is human-readable, while pickle is not;"
145
- msgstr "JSON 是人類可讀的,而 pickle 不是 ;"
187
+ msgstr "JSON 是人類可讀的,而 pickle 則無法 ;"
146
188
147
189
#: ../../library/pickle.rst:101
148
190
msgid ""
149
191
"JSON is interoperable and widely used outside of the Python ecosystem, while "
150
192
"pickle is Python-specific;"
151
193
msgstr ""
194
+ "JSON 具有高互通性(interoperability)且在 Python 以外的環境也被大量利用,但 "
195
+ "pickle 只能在 Python 內使用。"
152
196
197
+ # Skylull: introspection, introspection facilities
198
+ # https://zh.wikipedia.org/wiki/%E5%86%85%E7%9C%81_(%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6)
199
+ # https://book.pythontips.com/en/latest/object_introspection.html
200
+ # https://www.geeksforgeeks.org/code-introspection-in-python/
153
201
#: ../../library/pickle.rst:104
154
202
msgid ""
155
203
"JSON, by default, can only represent a subset of the Python built-in types, "
@@ -158,6 +206,9 @@ msgid ""
158
206
"introspection facilities; complex cases can be tackled by implementing :ref:"
159
207
"`specific object APIs <pickle-inst>`);"
160
208
msgstr ""
209
+ "預設狀態下的 JSON 只能紀錄一小部份的 Python 內建型別,且無法紀錄自訂類別;但"
210
+ "透過 Python 的自省功能,pickle 可以紀錄絕大多數的 Python 型別(其他比較複雜的"
211
+ "狀況也可以透過實作 :ref:`specific object APIs <pickle-inst>` 來解決);"
161
212
162
213
#: ../../library/pickle.rst:110
163
214
msgid ""
0 commit comments