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

Skip to content

Commit 859c4ef

Browse files
committed
Make usenetrc False by default (the old behaviour of having it True by
default could be rather confusing).
1 parent 1cb121e commit 859c4ef

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

Doc/library/nntplib.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,26 @@ headers, and that you have right to post on the particular newsgroup)::
5252
The module itself defines the following classes:
5353

5454

55-
.. class:: NNTP(host, port=119, user=None, password=None, readermode=None, usenetrc=True, [timeout])
55+
.. class:: NNTP(host, port=119, user=None, password=None, readermode=None, usenetrc=False, [timeout])
5656

5757
Return a new :class:`NNTP` object, representing a connection
5858
to the NNTP server running on host *host*, listening at port *port*.
5959
An optional *timeout* can be specified for the socket connection.
6060
If the optional *user* and *password* are provided, or if suitable
6161
credentials are present in :file:`/.netrc` and the optional flag *usenetrc*
62-
is true (the default), the ``AUTHINFO USER`` and ``AUTHINFO PASS`` commands
63-
are used to identify and authenticate the user to the server. If the optional
62+
is true, the ``AUTHINFO USER`` and ``AUTHINFO PASS`` commands are used
63+
to identify and authenticate the user to the server. If the optional
6464
flag *readermode* is true, then a ``mode reader`` command is sent before
6565
authentication is performed. Reader mode is sometimes necessary if you are
6666
connecting to an NNTP server on the local machine and intend to call
6767
reader-specific commands, such as ``group``. If you get unexpected
6868
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*.
69-
*readermode* defaults to ``None``. *usenetrc* defaults to ``True``.
69+
70+
.. versionchanged:: 3.2
71+
*usenetrc* is now False by default.
7072

7173

72-
.. class:: NNTP_SSL(host, port=563, user=None, password=None, ssl_context=None, readermode=None, usenetrc=True, [timeout])
74+
.. class:: NNTP_SSL(host, port=563, user=None, password=None, ssl_context=None, readermode=None, usenetrc=False, [timeout])
7375

7476
Return a new :class:`NNTP_SSL` object, representing an encrypted
7577
connection to the NNTP server running on host *host*, listening at

Lib/nntplib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def __init__(self, file, host,
308308
readermode=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):
309309
"""Initialize an instance. Arguments:
310310
- file: file-like object (open for read/write in binary mode)
311-
- host: hostname of the server (used if `usenetrc` is True)
311+
- host: hostname of the server
312312
- readermode: if true, send 'mode reader' command after
313313
connecting.
314314
- timeout: timeout (in seconds) used for socket connections
@@ -986,7 +986,7 @@ def starttls(self, context=None):
986986
class NNTP(_NNTPBase):
987987

988988
def __init__(self, host, port=NNTP_PORT, user=None, password=None,
989-
readermode=None, usenetrc=True,
989+
readermode=None, usenetrc=False,
990990
timeout=_GLOBAL_DEFAULT_TIMEOUT):
991991
"""Initialize an instance. Arguments:
992992
- host: hostname to connect to
@@ -1026,7 +1026,7 @@ class NNTP_SSL(_NNTPBase):
10261026

10271027
def __init__(self, host, port=NNTP_SSL_PORT,
10281028
user=None, password=None, ssl_context=None,
1029-
readermode=None, usenetrc=True,
1029+
readermode=None, usenetrc=False,
10301030
timeout=_GLOBAL_DEFAULT_TIMEOUT):
10311031
"""This works identically to NNTP.__init__, except for the change
10321032
in default port and the `ssl_context` argument for SSL connections.

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Core and Builtins
6060
Library
6161
-------
6262

63+
- ``usenetrc`` is now false by default for NNTP objects.
64+
6365
- Issue #1926: Add support for NNTP over SSL on port 563, as well as
6466
STARTTLS. Patch by Andrew Vant.
6567

0 commit comments

Comments
 (0)