jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1016331?usp=email )

Change subject: [doc] Update documentation for BasePage.get() and BasePage.text
......................................................................

[doc] Update documentation for BasePage.get() and BasePage.text

The argument of IsRedirectPageError is the page itself since Pywikibot
core release. With compat release it was the redirect target page.
The reason for this change in core release is documented in
rPWBC1585a990e3d1:

   "... getting the redirect target requires an additional API request
    ... Knowing that we have a redirect page without knowing its target
    is sometimes enough."

Bug: T361531
Change-Id: I07f9ff7b270d561020fdf72c999df3641e3eda18
---
M pywikibot/page/_basepage.py
1 file changed, 66 insertions(+), 14 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py
index 6af8970..8eaeeb0 100644
--- a/pywikibot/page/_basepage.py
+++ b/pywikibot/page/_basepage.py
@@ -358,19 +358,31 @@
         """Return the wiki-text of the page.

         This will retrieve the page from the server if it has not been
-        retrieved yet, or if force is True. This can raise the following
-        exceptions that should be caught by the calling code:
+        retrieved yet, or if force is True. Exceptions should be caught
+        by the calling code.

-        :exception pywikibot.exceptions.NoPageError: The page does not exist
-        :exception pywikibot.exceptions.IsRedirectPageError: The page is a
-            redirect. The argument of the exception is the title of the page
-            it redirects to.
-        :exception pywikibot.exceptions.SectionError: The section does not
-            exist on a page with a # link
+        **Example:**

-        :param force:           reload all page attributes, including errors.
-        :param get_redirect:    return the redirect text, do not follow the
-                                redirect, do not raise an exception.
+        >>> import pywikibot
+        >>> site = pywikibot.Site('mediawiki')
+        >>> page = pywikibot.Page(site, 'Pywikibot')
+        >>> page.get(get_redirect=True)
+        '#REDIRECT[[Manual:Pywikibot]]'
+        >>> page.get()
+        Traceback (most recent call last):
+         ...
+        pywikibot.exceptions.IsRedirectPageError: ... is a redirect page.
+
+        .. seealso:: :attr:`text` property
+
+        :param force: reload all page attributes, including errors.
+        :param get_redirect: return the redirect text, do not follow the
+            redirect, do not raise an exception.
+
+        :raises NoPageError: The page does not exist.
+        :raises IsRedirectPageError: The page is a redirect.
+        :raises SectionError: The section does not exist on a page with
+            a # link.
         """
         if force:
             del self.latest_revision_id
@@ -519,8 +531,29 @@

     @property
     def text(self) -> str:
-        """
-        Return the current (edited) wikitext, loading it if necessary.
+        """Return the current (edited) wikitext, loading it if necessary.
+
+        This property should be prefered over :meth:`get`. If the page
+        does not exist, an empty string will be returned. For a redirect
+        it returns the redirect page content and does not raise an
+        :exc:`exceptions.IsRedirectPageError` exception.
+
+        **Example:**
+
+        >>> import pywikibot
+        >>> site = pywikibot.Site('mediawiki')
+        >>> page = pywikibot.Page(site, 'Pywikibot')
+        >>> page.text
+        '#REDIRECT[[Manual:Pywikibot]]'
+        >>> page.text = 'PWB Framework'
+        >>> page.text
+        'PWB Framework'
+        >>> page.text = None  # reload from wiki
+        >>> page.text
+        '#REDIRECT[[Manual:Pywikibot]]'
+        >>> del page.text  # other way to reload from wiki
+
+        To save the modified text :meth:`save` is one possible method.

         :return: text of the page
         """
@@ -534,7 +567,7 @@
             return ''

     @text.setter
-    def text(self, value: str | None):
+    def text(self, value: str | None) -> None:
         """Update the current (edited) wikitext.

         :param value: New value or None

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1016331?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I07f9ff7b270d561020fdf72c999df3641e3eda18
Gerrit-Change-Number: 1016331
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: RoySmith <r...@panix.com>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org
To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org

Reply via email to