[Python-checkins] bpo-29235: Update document for Profiler's context manager (GH-7331)

INADA Naoki webhook-mailer at python.org
Thu Jun 7 05:46:46 EDT 2018


https://github.com/python/cpython/commit/cebe80b59b7386db3cce904d280dab61d1037e7a
commit: cebe80b59b7386db3cce904d280dab61d1037e7a
branch: master
author: Scott Sanderson <ssanderson at quantopian.com>
committer: INADA Naoki <methane at users.noreply.github.com>
date: 2018-06-07T18:46:42+09:00
summary:

bpo-29235: Update document for Profiler's context manager (GH-7331)

files:
M Doc/library/profile.rst
M Doc/whatsnew/3.8.rst
M Misc/NEWS.d/next/Library/2018-05-14-15-01-55.bpo-29235.47Fzwt.rst

diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst
index 7b60426fbc0a..5e33efe1c165 100644
--- a/Doc/library/profile.rst
+++ b/Doc/library/profile.rst
@@ -272,6 +272,9 @@ functions:
 
       pr.print_stats()
 
+   .. versionchanged:: 3.8
+      Added context manager support.
+
    .. method:: enable()
 
       Start collecting profiling data.
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 9aad908f927f..52c762632647 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -151,6 +151,8 @@ Changes in the Python API
   ``type.__new__``.  A :exc:`DeprecationWarning` was emitted in Python
   3.6--3.7.  (Contributed by Serhiy Storchaka in :issue:`23722`.)
 
+* The :class:`cProfile.Profile` class can now be used as a context
+  manager. (Contributed by Scott Sanderson in :issue:`29235`.)
 
 CPython bytecode changes
 ------------------------
diff --git a/Misc/NEWS.d/next/Library/2018-05-14-15-01-55.bpo-29235.47Fzwt.rst b/Misc/NEWS.d/next/Library/2018-05-14-15-01-55.bpo-29235.47Fzwt.rst
index 4618afc13ae0..2ce9096126ab 100644
--- a/Misc/NEWS.d/next/Library/2018-05-14-15-01-55.bpo-29235.47Fzwt.rst
+++ b/Misc/NEWS.d/next/Library/2018-05-14-15-01-55.bpo-29235.47Fzwt.rst
@@ -1,8 +1,2 @@
-The :class:`cProfile.Profile` class can now be used as a context manager.
-You can profile a block of code by running::
-
-  import cProfile
-  with cProfile.Profile() as profiler:
-      # ... code to be profiled ...
-
-Patch by Scott Sanderson.
+The :class:`cProfile.Profile` class can now be used as a context manager. Patch
+by Scott Sanderson.



More information about the Python-checkins mailing list