]> granicus.if.org Git - python/commitdiff
Patch #823072: add option to NOT use ~/.netrc in nntplib.NNTP().
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 3 Aug 2004 14:36:32 +0000 (14:36 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 3 Aug 2004 14:36:32 +0000 (14:36 +0000)
Doc/lib/libnntplib.tex
Lib/nntplib.py
Misc/NEWS

index a2161ceaa45527a16e7d7f97638a51d3f8fdda95..1aa5d4342060647846f2c22d201cd51b68261659 100644 (file)
@@ -54,12 +54,14 @@ The module itself defines the following items:
 
 \begin{classdesc}{NNTP}{host\optional{, port
                         \optional{, user\optional{, password
-                       \optional{, readermode}}}}}
+                       \optional{, readermode}
+                       \optional{, usenetrc}}}}}
 Return a new instance of the \class{NNTP} class, representing a
 connection to the NNTP server running on host \var{host}, listening at
 port \var{port}.  The default \var{port} is 119.  If the optional
 \var{user} and \var{password} are provided, 
-or if suitable credentials are present in \file{~/.netrc},
+or if suitable credentials are present in \file{~/.netrc} and the
+optional flag \var{usenetrc} is true (the default),
 the \samp{AUTHINFO USER} and \samp{AUTHINFO PASS} commands are used to
 identify and authenticate the user to the server.  If the optional
 flag \var{readermode} is true, then a \samp{mode reader} command is
@@ -68,6 +70,9 @@ necessary if you are connecting to an NNTP server on the local machine
 and intend to call reader-specific commands, such as \samp{group}.  If
 you get unexpected \code{NNTPPermanentError}s, you might need to set
 \var{readermode}.  \var{readermode} defaults to \code{None}.
+\var{usenetrc} defaults to \code{True}.
+
+\versionchanged[\var{usenetrc} argument added]{2.4}
 \end{classdesc}
 
 \begin{classdesc}{NNTPError}{}
index d0bd5adcfd0126fda78aa2505cac7b76986526d7..8709fffc64322c35a65b009f18f3cffb768f1800 100644 (file)
@@ -92,7 +92,7 @@ CRLF = '\r\n'
 # The class itself
 class NNTP:
     def __init__(self, host, port=NNTP_PORT, user=None, password=None,
-                 readermode=None):
+                 readermode=None, usenetrc=True):
         """Initialize an instance.  Arguments:
         - host: hostname to connect to
         - port: port to connect to (default the standard NNTP port)
@@ -136,7 +136,7 @@ class NNTP:
         # If no login/password was specified, try to get them from ~/.netrc
         # Presume that if .netc has an entry, NNRP authentication is required.
         try:
-            if not user:
+            if usenetrc and not user:
                 import netrc
                 credentials = netrc.netrc()
                 auth = credentials.authenticators(host)
index 291cc772295f24b356a5e7d2783324e4dc731ac1..2ea4cb1e24767ffe8b82862e925e97b2731c1b16 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,8 @@ Extension modules
 Library
 -------
 
+- nntplib does now allow to ignore a .netrc file.
+
 - urllib2 now recognizes Basic authentication even if other authentication
   schemes are offered.