[Python-checkins] bpo-44344: Document that pow can return a complex number for non-complex inputs. (GH-27853) (GH-29135)

ambv webhook-mailer at python.org
Thu Oct 21 18:08:26 EDT 2021


https://github.com/python/cpython/commit/9b3cda56870d087cf50f605e91f3d26964868640
commit: 9b3cda56870d087cf50f605e91f3d26964868640
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-10-22T00:08:20+02:00
summary:

bpo-44344: Document that pow can return a complex number for non-complex inputs. (GH-27853) (GH-29135)

Co-authored-by: Łukasz Langa <lukasz at langa.pl>
(cherry picked from commit 887a55705bb6c05a507c2886c9978a9e0cff0dd7)

Co-authored-by: Mark Dickinson <mdickinson at enthought.com>

files:
M Doc/library/functions.rst

diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index f4c3ef4600f6b..689455409eec3 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1357,7 +1357,10 @@ are always available.  They are listed here in alphabetical order.
    operands, the result has the same type as the operands (after coercion)
    unless the second argument is negative; in that case, all arguments are
    converted to float and a float result is delivered.  For example, ``pow(10, 2)``
-   returns ``100``, but ``pow(10, -2)`` returns ``0.01``.
+   returns ``100``, but ``pow(10, -2)`` returns ``0.01``.  For a negative base of
+   type :class:`int` or :class:`float` and a non-integral exponent, a complex
+   result is delivered.  For example, ``pow(-9, 0.5)`` returns a value close
+   to ``3j``.
 
    For :class:`int` operands *base* and *exp*, if *mod* is present, *mod* must
    also be of integer type and *mod* must be nonzero. If *mod* is present and



More information about the Python-checkins mailing list