@@ -1263,16 +1263,19 @@ msgid ""
1263
1263
" except for this latter category is to use :keyword:`except` "
1264
1264
":exc:`Exception`."
1265
1265
msgstr ""
1266
+ "几乎所有异常实际上都应当派生自 :exc:`Exception`;:exc:`BaseException` "
1267
+ "仅应当被用作那些仅应当在最高层级中处理的异常的基类,如 :exc:`SystemExit` 或 :exc:`KeyboardInterrupt`。 "
1268
+ "处理除了后面这一类之外的所有异常的推荐写法是使用 :keyword:`except` :exc:`Exception`。"
1266
1269
1267
1270
#: ../../whatsnew/3.0.rst:705
1268
1271
msgid ":exc:`!StandardError` was removed."
1269
- msgstr ""
1272
+ msgstr ":exc:`!StandardError` 已被移除。 "
1270
1273
1271
1274
#: ../../whatsnew/3.0.rst:707
1272
1275
msgid ""
1273
1276
"Exceptions no longer behave as sequences. Use the "
1274
1277
":attr:`~BaseException.args` attribute instead."
1275
- msgstr ""
1278
+ msgstr "异常已不再被当作序列来处理。 而应改用 :attr:`~BaseException.args` 属性。 "
1276
1279
1277
1280
#: ../../whatsnew/3.0.rst:710
1278
1281
msgid ""
@@ -1282,6 +1285,9 @@ msgid ""
1282
1285
"you *have* to do this, you can assign directly to the "
1283
1286
":attr:`~BaseException.__traceback__` attribute (see below)."
1284
1287
msgstr ""
1288
+ ":pep:`3109`: 引发异常。 你现在必须使用 :samp:`raise {Exception}({args})` 而不是 "
1289
+ ":samp:`raise {Exception}, {args}`。 此外,你不再可以显式地指定回溯;作为替代,如果你 *必须* "
1290
+ "这样做,你可以直接赋值给 :attr:`~BaseException.__traceback__` 属性(见下文)。"
1285
1291
1286
1292
#: ../../whatsnew/3.0.rst:716
1287
1293
msgid ""
@@ -1290,6 +1296,9 @@ msgid ""
1290
1296
"{variable}`. Moreover, the *variable* is explicitly deleted when the "
1291
1297
":keyword:`except` block is left."
1292
1298
msgstr ""
1299
+ ":pep:`3110`: 捕获异常。 你现在必须使用 :samp:`except {SomeException} as {variable}` 而不是 "
1300
+ ":samp:`except {SomeException}, {variable}`。 此外,*variable* 会在离开 "
1301
+ ":keyword:`except` 代码块时被显式地删除。"
1293
1302
1294
1303
#: ../../whatsnew/3.0.rst:722
1295
1304
msgid ""
@@ -1301,10 +1310,14 @@ msgid ""
1301
1310
" saved as the :attr:`~BaseException.__context__` attribute of the secondary "
1302
1311
"exception. Explicit chaining is invoked with this syntax::"
1303
1312
msgstr ""
1313
+ ":pep:`3134`: 异常串连。 存在两种情况:隐式串连和显式串连。 当异常在 :keyword:`except` 或 "
1314
+ ":keyword:`finally` 处理器代码块中被引发时将发生隐式串连。 通常发生这种情况是由于处理器代码块中存在程序缺陷;我们将其称为 *二级* "
1315
+ "异常。 在这种情况下,(正在处理的)原始异常将被保存为该二级异常的 :attr:`~BaseException.__context__` 属性。 "
1316
+ "显式串连则是由以下语法来唤起::"
1304
1317
1305
1318
#: ../../whatsnew/3.0.rst:731
1306
1319
msgid "raise SecondaryException() from primary_exception"
1307
- msgstr ""
1320
+ msgstr "raise SecondaryException() from primary_exception "
1308
1321
1309
1322
#: ../../whatsnew/3.0.rst:733
1310
1323
msgid ""
@@ -1317,6 +1330,10 @@ msgid ""
1317
1330
"traceback for each component of the chain, with the primary exception at the"
1318
1331
" top. (Java users may recognize this behavior.)"
1319
1332
msgstr ""
1333
+ "(这里 *primary_exception* 是产生一个异常对象的任何异常,它可能是在之前被捕获的异常)。 在这种情况下,该原始异常将存储在二级异常的"
1334
+ " :attr:`~BaseException.__cause__` 属性中。 如果遍历 :attr:`!__cause__` 和 "
1335
+ ":attr:`~BaseException.__context__` "
1336
+ "属性链时发生了未被处理的异常则会打印回溯信息并为属性链中的每个部分打印单独的回溯信息,原始异常将位于最上面。 (Java 用户可能很了解这样的行为。)"
1320
1337
1321
1338
#: ../../whatsnew/3.0.rst:743
1322
1339
msgid ""
@@ -1326,34 +1343,38 @@ msgid ""
1326
1343
"exception, and there are fewer reasons to use :func:`sys.exc_info` (though "
1327
1344
"the latter is not removed)."
1328
1345
msgstr ""
1346
+ ":pep:`3134`: 异常对象现在会将其回溯信息保存为 :attr:`~BaseException.__traceback__` 属性。 "
1347
+ "这意味着一个异常对象现在将包含从属于异常的所有信息,没有什么理由再使用 :func:`sys.exc_info` (不过后者并未被移除)。"
1329
1348
1330
1349
#: ../../whatsnew/3.0.rst:749
1331
1350
msgid ""
1332
1351
"A few exception messages are improved when Windows fails to load an "
1333
1352
"extension module. For example, ``error code 193`` is now ``%1 is not a "
1334
1353
"valid Win32 application``. Strings now deal with non-English locales."
1335
1354
msgstr ""
1355
+ "一些提示 Windows 载入扩展模块失败的异常消息得到了改进。 例如,``error code 193`` 现在是 ``%1 is not a "
1356
+ "valid Win32 application``。 字符串现在可处理非英语的语言区域。"
1336
1357
1337
1358
#: ../../whatsnew/3.0.rst:756
1338
1359
msgid "Miscellaneous Other Changes"
1339
- msgstr ""
1360
+ msgstr "其他杂项修改 "
1340
1361
1341
1362
#: ../../whatsnew/3.0.rst:759
1342
1363
msgid "Operators And Special Methods"
1343
- msgstr ""
1364
+ msgstr "运算符与特殊方法 "
1344
1365
1345
1366
#: ../../whatsnew/3.0.rst:761
1346
1367
msgid ""
1347
1368
"``!=`` now returns the opposite of ``==``, unless ``==`` returns "
1348
1369
":data:`NotImplemented`."
1349
- msgstr ""
1370
+ msgstr "现在 ``!=`` 将返回与 ``==`` 相反的结果,除非 ``==`` 是返回 :data:`NotImplemented`。 "
1350
1371
1351
1372
#: ../../whatsnew/3.0.rst:764
1352
1373
msgid ""
1353
1374
"The concept of\" unbound methods\" has been removed from the language. When "
1354
1375
"referencing a method as a class attribute, you now get a plain function "
1355
1376
"object."
1356
- msgstr ""
1377
+ msgstr "“未绑定方法”的概念已从语言中移除。 现在当把一个方法作为类属性来引用时,你将得到一个普通函数对象。 "
1357
1378
1358
1379
#: ../../whatsnew/3.0.rst:768
1359
1380
msgid ""
@@ -1362,23 +1383,28 @@ msgid ""
1362
1383
"j))`` (or :meth:`~object.__setitem__` or :meth:`~object.__delitem__`, when "
1363
1384
"used as an assignment or deletion target, respectively)."
1364
1385
msgstr ""
1386
+ ":meth:`!__getslice__`, :meth:`!__setslice__` 和 :meth:`!__delslice__` 已被去除。 "
1387
+ "现在 ``a[i:j]`` 语法形式将被转为 ``a.__getitem__(slice(i, j))`` (或者当用作赋值或删除的目标时,分别被转为 "
1388
+ ":meth:`~object.__setitem__` 或 :meth:`~object.__delitem__`)。"
1365
1389
1366
1390
#: ../../whatsnew/3.0.rst:774
1367
1391
msgid ""
1368
1392
":pep:`3114`: the standard :meth:`next` method has been renamed to "
1369
1393
":meth:`~iterator.__next__`."
1370
- msgstr ""
1394
+ msgstr ":pep:`3114`: 标准的 :meth:`next` 方法已被重命名为 :meth:`~iterator.__next__`。 "
1371
1395
1372
1396
#: ../../whatsnew/3.0.rst:777
1373
1397
msgid ""
1374
1398
"The :meth:`!__oct__` and :meth:`!__hex__` special methods are removed -- "
1375
1399
":func:`oct` and :func:`hex` use :meth:`~object.__index__` now to convert the"
1376
1400
" argument to an integer."
1377
1401
msgstr ""
1402
+ ":meth:`!__oct__` 和 :meth:`!__hex__` 特殊方法已被移除 -- 现在 :func:`oct` 和 :func:`hex`"
1403
+ " 将使用 :meth:`~object.__index__` 来将参数转换为整数。"
1378
1404
1379
1405
#: ../../whatsnew/3.0.rst:781
1380
1406
msgid "Removed support for :attr:`!__members__` and :attr:`!__methods__`."
1381
- msgstr ""
1407
+ msgstr "移除了对 :attr:`!__members__` 和 :attr:`!__methods__` 的支持。 "
1382
1408
1383
1409
#: ../../whatsnew/3.0.rst:783
1384
1410
msgid ""
@@ -1392,10 +1418,18 @@ msgid ""
1392
1418
":attr:`~function.__doc__`, :attr:`~function.__globals__`, "
1393
1419
":attr:`~function.__name__`, respectively."
1394
1420
msgstr ""
1421
+ "名为 :attr:`!func_X` 的函数属性已被重命名为使用 :attr:`!__X__` "
1422
+ "的形式,在函数属性命名空间中释放这些名称以便作为用户自定义属性。 也就是说,:attr:`!func_closure`, "
1423
+ ":attr:`!func_code`, :attr:`!func_defaults`, :attr:`!func_dict`, "
1424
+ ":attr:`!func_doc`, :attr:`!func_globals`, :attr:`!func_name` 分别被重命名为 "
1425
+ ":attr:`~function.__closure__`, :attr:`~function.__code__`, "
1426
+ ":attr:`~function.__defaults__`, :attr:`~function.__dict__`, "
1427
+ ":attr:`~function.__doc__`, :attr:`~function.__globals__`, "
1428
+ ":attr:`~function.__name__`。"
1395
1429
1396
1430
#: ../../whatsnew/3.0.rst:794
1397
1431
msgid ":meth:`!__nonzero__` is now :meth:`~object.__bool__`."
1398
- msgstr ""
1432
+ msgstr ":meth:`!__nonzero__` 现在为 :meth:`~object.__bool__`。 "
1399
1433
1400
1434
#: ../../whatsnew/3.0.rst:797
1401
1435
msgid "Builtins"