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

Skip to content

Commit f00e840

Browse files
[po] auto sync
1 parent c3265b7 commit f00e840

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

library/contextlib.po

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,20 +745,24 @@ msgid ""
745745
"context managers directly in the header of the :keyword:`with` statement "
746746
"where they are used (as shown in all of the usage examples above)."
747747
msgstr ""
748+
"这个常见的限制意味着通常来说都建议在 :keyword:`with` 语句开头上下文管理器被使用的位置直接创建它们(如下面所有的使用示例所显示的)。"
748749

749750
#: ../../library/contextlib.rst:740
750751
msgid ""
751752
"Files are an example of effectively single use context managers, since the "
752753
"first :keyword:`with` statement will close the file, preventing any further "
753754
"IO operations using that file object."
754755
msgstr ""
756+
"文件是一个高效的单独使用上下文管理器的例子,因为第一个 :keyword:`with` 语句将关闭文件,防止任何后续的使用该文件对象的 IO 操作。"
755757

756758
#: ../../library/contextlib.rst:744
757759
msgid ""
758760
"Context managers created using :func:`contextmanager` are also single use "
759761
"context managers, and will complain about the underlying generator failing "
760762
"to yield if an attempt is made to use them a second time::"
761763
msgstr ""
764+
"使用 :func:`contextmanager` "
765+
"创建的上下文管理器也是单次使用的上下文管理器,并会在试图第二次使用它们时报告下层生成器无法执行产生操作::"
762766

763767
#: ../../library/contextlib.rst:772
764768
msgid "Reentrant context managers"
@@ -780,13 +784,15 @@ msgid ""
780784
"are :func:`suppress` and :func:`redirect_stdout`. Here's a very simple "
781785
"example of reentrant use::"
782786
msgstr ""
787+
":class:`threading.RLock` 是一个可重入上下管理器的例子,:func:`suppress` 和 "
788+
":func:`redirect_stdout` 也是如此。 下面是一个非常简单的可重入使用的示例::"
783789

784790
#: ../../library/contextlib.rst:798
785791
msgid ""
786792
"Real world examples of reentrancy are more likely to involve multiple "
787793
"functions calling each other and hence be far more complicated than this "
788794
"example."
789-
msgstr ""
795+
msgstr "现实世界的可重入例子更可能涉及到多个函数的相互调用因此会比这个例子要复杂得多。"
790796

791797
#: ../../library/contextlib.rst:802
792798
msgid ""
@@ -795,6 +801,8 @@ msgid ""
795801
"makes a global modification to the system state by binding "
796802
":data:`sys.stdout` to a different stream."
797803
msgstr ""
804+
"还要注意可重入与线程安全 *不是* 一回事。 举例来说,:func:`redirect_stdout` 肯定不是线程安全的,因为它会通过将 "
805+
":data:`sys.stdout` 绑定到一个不同的流对系统状态做了全局性的修改。"
798806

799807
#: ../../library/contextlib.rst:811
800808
msgid "Reusable context managers"
@@ -809,20 +817,26 @@ msgid ""
809817
"but will fail (or otherwise not work correctly) if the specific context "
810818
"manager instance has already been used in a containing with statement."
811819
msgstr ""
820+
"与单次使用和可重入上下文管理器都不同的还有“可重用”上下文管理器(或者,使用完全显式的表达应为“可重用,但不可重入”上下文管理器,因为可重入上下文管理器也会是可重用的)。"
821+
" 这些上下文管理器支持多次使用,但如果特定的上下文管理器实例已经在包含它的 with 语句中被使用过则将失败(或者不能正确工作)。"
812822

813823
#: ../../library/contextlib.rst:820
814824
msgid ""
815825
":class:`threading.Lock` is an example of a reusable, but not reentrant, "
816826
"context manager (for a reentrant lock, it is necessary to use "
817827
":class:`threading.RLock` instead)."
818828
msgstr ""
829+
":class:`threading.Lock` 是一个可重用,但是不可重入的上下文管理器的例子(对于可重入锁,则有必要使用 "
830+
":class:`threading.RLock` 来代替)。"
819831

820832
#: ../../library/contextlib.rst:824
821833
msgid ""
822834
"Another example of a reusable, but not reentrant, context manager is "
823835
":class:`ExitStack`, as it invokes *all* currently registered callbacks when "
824836
"leaving any with statement, regardless of where those callbacks were added::"
825837
msgstr ""
838+
"另一个可重用,但不可重入的上下文管理器的例子是 :class:`ExitStack`,因为它在离开任何 with 语句时会发起调用 *所有* "
839+
"当前已注册的回调,不论回调是在哪里添加的::"
826840

827841
#: ../../library/contextlib.rst:855
828842
msgid ""
@@ -831,6 +845,8 @@ msgid ""
831845
"cause the stack to be cleared at the end of the innermost with statement, "
832846
"which is unlikely to be desirable behaviour."
833847
msgstr ""
848+
"正如这个例子的输出所显示的,在多个 with 语句中重用一个单独的栈对象可以正确工作,但调试嵌套它们就将导致栈在最内层的 with "
849+
"语句结束时被清空,这不大可能是符合期望的行为。"
834850

835851
#: ../../library/contextlib.rst:860
836852
msgid ""

0 commit comments

Comments
 (0)