Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3265b7

Browse files
[po] auto sync
1 parent 4a69abf commit c3265b7

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

library/contextlib.po

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ msgid ""
593593
" to handle various situations that can't be handled directly in a "
594594
":keyword:`with` statement."
595595
msgstr ""
596+
"实际上需要这样做很可能表明下层的 API 应该提供一个直接的资源管理接口以便与 "
597+
":keyword:`try`/:keyword:`except`/:keyword:`finally` 语句配合使用,但并不是所有的 API "
598+
"在这方面都设计得很好。 当上下文管理器是所提供的唯一资源管理 API 时,则 :class:`ExitStack` 可以让处理各种无法在 "
599+
":keyword:`with` 语句中直接处理的情况变得更为容易。"
596600

597601
#: ../../library/contextlib.rst:555
598602
msgid "Cleaning up in an ``__enter__`` implementation"
@@ -604,13 +608,15 @@ msgid ""
604608
"useful in cleaning up an already allocated resource if later steps in the "
605609
":meth:`__enter__` implementation fail."
606610
msgstr ""
611+
"正如 :meth:`ExitStack.push` 的文档中所指出,如果在 :meth:`__enter__` "
612+
"实现中的后续步骤失败则此方法在清理已分配的资源时将很有用处。"
607613

608614
#: ../../library/contextlib.rst:561
609615
msgid ""
610616
"Here's an example of doing this for a context manager that accepts resource "
611617
"acquisition and release functions, along with an optional validation "
612618
"function, and maps them to the context management protocol::"
613-
msgstr ""
619+
msgstr "下面是为一个上下文管理器做这件事的例子,该上下文管理器可接受资源获取和释放函数,以及可选的验证函数,并将它们映射到上下文管理协议::"
614620

615621
#: ../../library/contextlib.rst:601
616622
msgid "Replacing any use of ``try-finally`` and flag variables"
@@ -659,13 +665,15 @@ msgid ""
659665
"function, then it is still possible to use the decorator form of "
660666
":meth:`ExitStack.callback` to declare the resource cleanup in advance::"
661667
msgstr ""
668+
"如果资源清理操作尚未完善地捆绑到一个独立的函数中,则仍然可以使用 :meth:`ExitStack.callback` "
669+
"的装饰器形式来提前声明资源清理::"
662670

663671
#: ../../library/contextlib.rst:669
664672
msgid ""
665673
"Due to the way the decorator protocol works, a callback function declared "
666674
"this way cannot take any parameters. Instead, any resources to be released "
667675
"must be accessed as closure variables."
668-
msgstr ""
676+
msgstr "受装饰器协议工作方式的影响,以此方式声明的回调函数无法接受任何形参。 作为替代,任何要释放的资源必须作为闭包变量来访问。"
669677

670678
#: ../../library/contextlib.rst:675
671679
msgid "Using a context manager as a function decorator"
@@ -685,6 +693,8 @@ msgid ""
685693
"the task, inheriting from :class:`ContextDecorator` provides both "
686694
"capabilities in a single definition::"
687695
msgstr ""
696+
"例如,有时将函数或语句组包装在一个可以跟踪进入和退出时间的记录器中是很有用的。 与其为任务同时编写函数装饰器和上下文管理器,不如继承 "
697+
":class:`ContextDecorator` 在一个定义中同时提供这两种能力::"
688698

689699
#: ../../library/contextlib.rst:701
690700
msgid "Instances of this class can be used as both a context manager::"
@@ -726,6 +736,8 @@ msgid ""
726736
"them a second time will trigger an exception or otherwise not work "
727737
"correctly."
728738
msgstr ""
739+
"大多数上下文管理器的编写方式意味着它们只能在一个 :keyword:`with` 语句中被有效使用一次。 "
740+
"这些一次性使用的上下文管理器必须在每次被使用时重新创建 —— 试图第二次使用它们将会触发异常或是不能正确工作。"
729741

730742
#: ../../library/contextlib.rst:736
731743
msgid ""

whatsnew/3.6.po

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,16 @@ msgstr "PYTHONMALLOC 环境变量"
792792
msgid ""
793793
"The new :envvar:`PYTHONMALLOC` environment variable allows setting the "
794794
"Python memory allocators and installing debug hooks."
795-
msgstr ""
795+
msgstr "新的 :envvar:`PYTHONMALLOC` 环境变量允许设置 Python 内存分配器并安装调试钩子。"
796796

797797
#: ../../whatsnew/3.6.rst:642
798798
msgid ""
799799
"It is now possible to install debug hooks on Python memory allocators on "
800800
"Python compiled in release mode using ``PYTHONMALLOC=debug``. Effects of "
801801
"debug hooks:"
802802
msgstr ""
803+
"现在将可以使用 ``PYTHONMALLOC=debug`` 在以发布模式编译的 Python 上为 Python 内存分配器安装调试钩子。 "
804+
"调试钩子的效果:"
803805

804806
#: ../../whatsnew/3.6.rst:645
805807
msgid "Newly allocated memory is filled with the byte ``0xCB``"
@@ -815,6 +817,8 @@ msgid ""
815817
":c:func:`PyObject_Free` called on a memory block allocated by "
816818
":c:func:`PyMem_Malloc`."
817819
msgstr ""
820+
"检测违反 Python 内存分配器 API 的操作。 例如,:c:func:`PyObject_Free` 在 "
821+
":c:func:`PyMem_Malloc` 所分配的内存块上被调用。"
818822

819823
#: ../../whatsnew/3.6.rst:650
820824
msgid "Detect writes before the start of a buffer (buffer underflows)"
@@ -842,7 +846,7 @@ msgstr "检查是否保留了 GIL 也是Python 3.6 的新特性。"
842846
msgid ""
843847
"See the :c:func:`PyMem_SetupDebugHooks` function for debug hooks on Python "
844848
"memory allocators."
845-
msgstr ""
849+
msgstr "请参阅 :c:func:`PyMem_SetupDebugHooks` 函数来了解 Python 内存分配器上的调试钩子。"
846850

847851
#: ../../whatsnew/3.6.rst:661
848852
msgid ""
@@ -851,19 +855,21 @@ msgid ""
851855
"``PYTHONMALLOC=malloc``. This is helpful when using external memory "
852856
"debuggers like Valgrind on a Python compiled in release mode."
853857
msgstr ""
858+
"现在还可以使用 ``PYTHONMALLOC=malloc`` 为所有的 Python 内存分配强制使用 C 库的 :c:func:`malloc` "
859+
"分配器。 这在以发布模式编译的 Python 上使用外部内存调试器如 Valgrind 时会很有用处。"
854860

855861
#: ../../whatsnew/3.6.rst:666
856862
msgid ""
857863
"On error, the debug hooks on Python memory allocators now use the "
858864
":mod:`tracemalloc` module to get the traceback where a memory block was "
859865
"allocated."
860-
msgstr ""
866+
msgstr "发生错误时,Python 内存分配器上的调试钩子现在会使用 :mod:`tracemalloc` 模块来获取内存块被分配所在位置上的回溯。"
861867

862868
#: ../../whatsnew/3.6.rst:670
863869
msgid ""
864870
"Example of fatal error on buffer overflow using ``python3.6 -X "
865871
"tracemalloc=5`` (store 5 frames in traces)::"
866-
msgstr ""
872+
msgstr "使用 ``python3.6 -X tracemalloc=5`` (在回溯中存储 5 帧) 的缓冲区溢出的致命错误示例::"
867873

868874
#: ../../whatsnew/3.6.rst:707
869875
msgid "(Contributed by Victor Stinner in :issue:`26516` and :issue:`26564`.)"
@@ -877,7 +883,7 @@ msgstr "DTrace 和 SystemTap 探测支持"
877883
msgid ""
878884
"Python can now be built ``--with-dtrace`` which enables static markers for "
879885
"the following events in the interpreter:"
880-
msgstr ""
886+
msgstr "Python 现在可以附带 ``--with-dtrace`` 来构建以便为解释器中的下列事件启用静态标记:"
881887

882888
#: ../../whatsnew/3.6.rst:718
883889
msgid "function call/return"
@@ -913,6 +919,8 @@ msgid ""
913919
"(Contributed by Łukasz Langa in :issue:`21590`, based on patches by Jesús "
914920
"Cea Avión, David Malcolm, and Nikhil Benesch.)"
915921
msgstr ""
922+
"(由 Łukasz Langa 在 :issue:`21590` 中贡献,基于 Jesús Cea Avión, David Malcolm 和 "
923+
"Nikhil Benesch 的补丁。)"
916924

917925
#: ../../whatsnew/3.6.rst:738
918926
msgid "Other Language Changes"

0 commit comments

Comments
 (0)