Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb1982b

Browse files
Deploy preview for PR 1160 🛫
1 parente0fb38a commitfb1982b

File tree

575 files changed

+782
-601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

575 files changed

+782
-601
lines changed

‎pr-preview/pr-1160/_sources/c-api/descriptor.rst.txt‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,45 @@ found in the dictionary of type objects.
3838
3939
4040
..c:function:: PyObject*PyWrapper_New(PyObject *, PyObject *)
41+
42+
43+
Built-in descriptors
44+
^^^^^^^^^^^^^^^^^^^^
45+
46+
..c:var:: PyTypeObject PySuper_Type
47+
48+
The type object for super objects. This is the same object as
49+
:class:`super` in the Python layer.
50+
51+
52+
..c:var:: PyTypeObject PyClassMethod_Type
53+
54+
The type of class method objects. This is the same object as
55+
:class:`classmethod` in the Python layer.
56+
57+
58+
..c:function:: PyObject *PyClassMethod_New(PyObject *callable)
59+
60+
Create a new:class:`classmethod` object wrapping *callable*.
61+
*callable* must be a callable object and must not be ``NULL``.
62+
63+
On success, this function returns a:term:`strong reference` to a new class
64+
method descriptor. On failure, this function returns ``NULL`` with an
65+
exception set.
66+
67+
68+
..c:var:: PyTypeObject PyStaticMethod_Type
69+
70+
The type of static method objects. This is the same object as
71+
:class:`staticmethod` in the Python layer.
72+
73+
74+
..c:function:: PyObject *PyStaticMethod_New(PyObject *callable)
75+
76+
Create a new:class:`staticmethod` object wrapping *callable*.
77+
*callable* must be a callable object and must not be ``NULL``.
78+
79+
On success, this function returns a:term:`strong reference` to a new static
80+
method descriptor. On failure, this function returns ``NULL`` with an
81+
exception set.
82+

‎pr-preview/pr-1160/_sources/c-api/function.rst.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ There are a few functions specific to Python functions.
102102
dictionary of arguments or ``NULL``.
103103
104104
105+
..c:function::intPyFunction_SetKwDefaults(PyObject *op, PyObject *defaults)
106+
107+
Set the keyword-only argument default values of the function object *op*.
108+
*defaults* must be a dictionary of keyword-only arguments or ``Py_None``.
109+
110+
This function returns ``0`` on success, and returns ``-1`` with an exception
111+
set on failure.
112+
113+
105114
..c:function:: PyObject*PyFunction_GetClosure(PyObject *op)
106115
107116
Return the closure associated with the function object *op*. This can be ``NULL``

‎pr-preview/pr-1160/_sources/library/dis.rst.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,9 +1673,13 @@ iterations of the loop.
16731673
* ``0x02`` a dictionary of keyword-only parameters' default values
16741674
* ``0x04`` a tuple of strings containing parameters' annotations
16751675
* ``0x08`` a tuple containing cells for free variables, making a closure
1676+
* ``0x10`` the:term:`annotate function` for the function object
16761677

16771678
..versionadded::3.13
16781679

1680+
..versionchanged::3.14
1681+
Added ``0x10`` to indicate the annotate function for the function object.
1682+
16791683

16801684
..opcode::BUILD_SLICE (argc)
16811685

‎pr-preview/pr-1160/_sources/library/unittest.mock-examples.rst.txt‎

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,13 @@ this list of calls for us::
600600
Partial mocking
601601
~~~~~~~~~~~~~~~
602602

603-
In some tests I wanted to mock out a call to:meth:`datetime.date.today`
604-
to return a known date, butI didn't want to prevent the code under test from
605-
creating new date objects. Unfortunately:class:`datetime.date` is written in C, and
606-
soI couldn't just monkey-patch out the static:meth:`datetime.date.today` method.
603+
For some tests, you may want to mock out a call to:meth:`datetime.date.today`
604+
to return a known date, butdon't want to prevent the code under test from
605+
creating new date objects. Unfortunately:class:`datetime.date` is written in C,
606+
soyou cannot just monkey-patch out the static:meth:`datetime.date.today` method.
607607

608-
I found a simple way of doing this that involvedeffectivelywrapping the date
609-
class with a mock,but passing through calls to the constructor to the real
608+
Instead, you caneffectivelywrap the date
609+
class with a mock,while passing through calls to the constructor to the real
610610
class (and returning real instances).
611611

612612
The:func:`patch decorator <patch>` is used here to
@@ -743,25 +743,24 @@ exception is raised in the setUp then tearDown is not called.
743743
Mocking Unbound Methods
744744
~~~~~~~~~~~~~~~~~~~~~~~
745745

746-
Whilst writing tests today I needed to patch an *unbound method* (patching the
747-
method on the class rather than on the instance). I needed self to be passed
748-
in as the first argument because I want to make asserts about which objects
749-
were calling this particular method. The issue is that you can't patch with a
750-
mock for this, because if you replace an unbound method with a mock it doesn't
751-
become a bound method when fetched from the instance, and so it doesn't get
752-
self passed in. The workaround is to patch the unbound method with a real
753-
function instead. The:func:`patch` decorator makes it so simple to
754-
patch out methods with a mock that having to create a real function becomes a
755-
nuisance.
746+
Sometimes a test needs to patch an *unbound method*, which means patching the
747+
method on the class rather than on the instance. In order to make assertions
748+
about which objects were calling this particular method, you need to pass
749+
``self`` as the first argument. The issue is that you can't patch with a mock for
750+
this, because if you replace an unbound method with a mock it doesn't become
751+
a bound method when fetched from the instance, and so it doesn't get ``self``
752+
passed in. The workaround is to patch the unbound method with a real function
753+
instead. The:func:`patch` decorator makes it so simple to patch out methods
754+
with a mock that having to create a real function becomes a nuisance.
756755

757756
If you pass ``autospec=True`` to patch then it does the patching with a
758757
*real* function object. This function object has the same signature as the one
759758
it is replacing, but delegates to a mock under the hood. You still get your
760759
mock auto-created in exactly the same way as before. What it means though, is
761760
that if you use it to patch out an unbound method on a class the mocked
762761
function will be turned into a bound method if it is fetched from an instance.
763-
It will have ``self`` passed in as the first argument, which is exactly what I
764-
wanted:
762+
It will have ``self`` passed in as the first argument, which is exactly what
763+
was needed:
765764

766765
>>>classFoo:
767766
...deffoo(self):

‎pr-preview/pr-1160/about.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ <h3>導航</h3>
314314
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
315315
<br>
316316
<br>
317-
最後更新於 11月09, 2025 (17:30 UTC)。
317+
最後更新於 11月10, 2025 (00:21 UTC)。
318318

319319
<ahref="/bugs.html">發現 bug</a>
320320

‎pr-preview/pr-1160/bugs.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ <h2>說明文件的錯誤<a class="headerlink" href="#documentation-bugs" title=
229229
</section>
230230
<sectionid="getting-started-contributing-to-python-yourself">
231231
<spanid="contributing-to-python"></span><h2>開始讓自己貢獻 Python<aclass="headerlink"href="#getting-started-contributing-to-python-yourself"title="連結到這個標頭"></a></h2>
232-
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在<aclass="reference external"href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<aclass="reference external"href="https://devguide.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
232+
<p>除了只是回報你所發現的錯誤之外,同樣也歡迎你提交修正它們的修補程式 (patch)。你可以在<aclass="reference external"href="https://devguide.python.org/">Python 開發者指南</a>中找到如何開始修補 Python 的更多資訊。如果你有任何問題,<aclass="reference external"href="https://mail.python.org/mailman3/lists/core-mentorship.python.org/">核心導師郵寄清單</a>是一個友善的地方,你可以在那裡得到,關於 Python 修正錯誤的過程中,所有問題的答案。</p>
233233
</section>
234234
</section>
235235

@@ -351,7 +351,7 @@ <h3>導航</h3>
351351
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
352352
<br>
353353
<br>
354-
最後更新於 11月09, 2025 (17:30 UTC)。
354+
最後更新於 11月10, 2025 (00:21 UTC)。
355355

356356
<ahref="/bugs.html">發現 bug</a>
357357

‎pr-preview/pr-1160/c-api/abstract.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ <h3>導航</h3>
323323
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
324324
<br>
325325
<br>
326-
最後更新於 11月09, 2025 (17:30 UTC)。
326+
最後更新於 11月10, 2025 (00:21 UTC)。
327327

328328
<ahref="/bugs.html">發現 bug</a>
329329

‎pr-preview/pr-1160/c-api/allocation.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ <h3>導航</h3>
532532
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
533533
<br>
534534
<br>
535-
最後更新於 11月09, 2025 (17:30 UTC)。
535+
最後更新於 11月10, 2025 (00:21 UTC)。
536536

537537
<ahref="/bugs.html">發現 bug</a>
538538

‎pr-preview/pr-1160/c-api/apiabiversion.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ <h3>導航</h3>
471471
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
472472
<br>
473473
<br>
474-
最後更新於 11月09, 2025 (17:30 UTC)。
474+
最後更新於 11月10, 2025 (00:21 UTC)。
475475

476476
<ahref="/bugs.html">發現 bug</a>
477477

‎pr-preview/pr-1160/c-api/arg.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ <h3>導航</h3>
954954
<ahref="https://www.python.org/psf/donations/">敬請捐贈。</a>
955955
<br>
956956
<br>
957-
最後更新於 11月09, 2025 (17:30 UTC)。
957+
最後更新於 11月10, 2025 (00:21 UTC)。
958958

959959
<ahref="/bugs.html">發現 bug</a>
960960

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp