]> granicus.if.org Git - python/commitdiff
Issue #8890: Stop advertising an insecure use of /tmp in docs
authorPetri Lehtinen <petri@digip.org>
Sat, 23 Feb 2013 18:24:08 +0000 (19:24 +0100)
committerPetri Lehtinen <petri@digip.org>
Sat, 23 Feb 2013 18:24:31 +0000 (19:24 +0100)
17 files changed:
Doc/install/index.rst
Doc/library/atexit.rst
Doc/library/bsddb.rst
Doc/library/cgi.rst
Doc/library/compiler.rst
Doc/library/gzip.rst
Doc/library/imghdr.rst
Doc/library/mailcap.rst
Doc/library/nntplib.rst
Doc/library/optparse.rst
Doc/library/pipes.rst
Doc/library/posixfile.rst
Doc/library/trace.rst
Doc/library/zipimport.rst
Doc/tutorial/inputoutput.rst
Misc/ACKS
Misc/NEWS

index b1881b5469ef62dd31608c098071133ee9bf43ef..d3e8babe52353173a8af04fd31f53e62a58f3cba 100644 (file)
@@ -189,7 +189,7 @@ under the distribution root; if you're excessively concerned with speed, or want
 to keep the source tree pristine, you can change the build directory with the
 :option:`--build-base` option. For example::
 
-   python setup.py build --build-base=/tmp/pybuild/foo-1.0
+   python setup.py build --build-base=/path/to/pybuild/foo-1.0
 
 (Or you could do this permanently with a directive in your system or personal
 Distutils configuration file; see section :ref:`inst-config-files`.)  Normally, this
index 6ac36b214269cec2480504843920d697e7c1ba06..37d8d500ef1d4e8c9ff4a60835ff17de063f034e 100644 (file)
@@ -76,7 +76,7 @@ automatically when the program terminates without relying on the application
 making an explicit call into this module at termination. ::
 
    try:
-       _count = int(open("/tmp/counter").read())
+       _count = int(open("counter").read())
    except IOError:
        _count = 0
 
@@ -85,7 +85,7 @@ making an explicit call into this module at termination. ::
        _count = _count + n
 
    def savecounter():
-       open("/tmp/counter", "w").write("%d" % _count)
+       open("counter", "w").write("%d" % _count)
 
    import atexit
    atexit.register(savecounter)
index 0ed109d028804d85f9a80cb31c4eb584ae291c5b..74bcc0f43413a2c63b7f249b3cef33100bee5521 100644 (file)
@@ -170,7 +170,7 @@ dictionaries.  In addition, they support the methods listed below.
 Example::
 
    >>> import bsddb
-   >>> db = bsddb.btopen('/tmp/spam.db', 'c')
+   >>> db = bsddb.btopen('spam.db', 'c')
    >>> for i in range(10): db['%d'%i] = '%d'% (i*i)
    ...
    >>> db['3']
index 0240998a142c3841ff228abaf01e27831eb01137..1b342c33d370d429cde657ccc8abfae6ff38f1f9 100644 (file)
@@ -81,7 +81,7 @@ program to users of your script, you can have the reports saved to files
 instead, with code like this::
 
    import cgitb
-   cgitb.enable(display=0, logdir="/tmp")
+   cgitb.enable(display=0, logdir="/path/to/logdir")
 
 It's very helpful to use this feature during script development. The reports
 produced by :mod:`cgitb` provide information that can save you a lot of time in
index 229bcb22915b8f6583f1bd6b02b1236465507d23..494902e17f2735f43d0e08672e185f9079995eac 100644 (file)
@@ -540,7 +540,7 @@ examples demonstrate how to use the :func:`parse` function, what the repr of an
 AST looks like, and how to access attributes of an AST node.
 
 The first module defines a single function.  Assume it is stored in
-:file:`/tmp/doublelib.py`.  ::
+:file:`doublelib.py`.  ::
 
    """This is an example module.
 
@@ -557,7 +557,7 @@ to create an instance from a repr, you must import the class names from the
 :mod:`compiler.ast` module. ::
 
    >>> import compiler
-   >>> mod = compiler.parseFile("/tmp/doublelib.py")
+   >>> mod = compiler.parseFile("doublelib.py")
    >>> mod
    Module('This is an example module.\n\nThis is the docstring.\n',
           Stmt([Function(None, 'double', ['x'], [], 0,
index 465510f6b6e6af1c041a105b373937f13ec65276..ce11eec1cc221bc1e95a0873a45a8e3479193703 100644 (file)
@@ -93,7 +93,7 @@ Examples of usage
 Example of how to read a compressed file::
 
    import gzip
-   f = gzip.open('/home/joe/file.txt.gz', 'rb')
+   f = gzip.open('file.txt.gz', 'rb')
    file_content = f.read()
    f.close()
 
@@ -101,15 +101,15 @@ Example of how to create a compressed GZIP file::
 
    import gzip
    content = "Lots of content here"
-   f = gzip.open('/home/joe/file.txt.gz', 'wb')
+   f = gzip.open('file.txt.gz', 'wb')
    f.write(content)
    f.close()
 
 Example of how to GZIP compress an existing file::
 
    import gzip
-   f_in = open('/home/joe/file.txt', 'rb')
-   f_out = gzip.open('/home/joe/file.txt.gz', 'wb')
+   f_in = open('file.txt', 'rb')
+   f_out = gzip.open('file.txt.gz', 'wb')
    f_out.writelines(f_in)
    f_out.close()
    f_in.close()
index 20f789f6a50432126abeb9a193ca9c21813462f7..24ab5716fafc6a4e2070f8a6dd47dfa7ba2f1712 100644 (file)
@@ -68,6 +68,6 @@ to this variable:
 Example::
 
    >>> import imghdr
-   >>> imghdr.what('/tmp/bass.gif')
+   >>> imghdr.what('bass.gif')
    'gif'
 
index 5507211751ca8b326607788e08b51741ab8d7e5f..b359509465fc7f334ab64ae42376ec4d58a48b6a 100644 (file)
@@ -71,6 +71,6 @@ An example usage::
 
    >>> import mailcap
    >>> d=mailcap.getcaps()
-   >>> mailcap.findmatch(d, 'video/mpeg', filename='/tmp/tmp1223')
-   ('xmpeg /tmp/tmp1223', {'view': 'xmpeg %s'})
+   >>> mailcap.findmatch(d, 'video/mpeg', filename='tmp1223')
+   ('xmpeg tmp1223', {'view': 'xmpeg %s'})
 
index acbb7a5d900b87f5b446c1562a06247c59978bd4..f87c2eb6a76146be14a50d7fea81a07fffe6e9b1 100644 (file)
@@ -46,7 +46,7 @@ To post an article from a file (this assumes that the article has valid
 headers, and that you have right to post on the particular newsgroup)::
 
    >>> s = NNTP('news.gmane.org')
-   >>> f = open('/tmp/article')
+   >>> f = open('articlefile')
    >>> s.post(f)
    '240 Article posted successfully.'
    >>> s.quit()
index d5a35c269f74b316777d305f30c8395eab7a0cfd..417b3bb84d577ffdf9a3b0163ff9ce37ba1e6769 100644 (file)
@@ -173,10 +173,10 @@ required option
 
 For example, consider this hypothetical command-line::
 
-   prog -v --report /tmp/report.txt foo bar
+   prog -v --report report.txt foo bar
 
 ``-v`` and ``--report`` are both options.  Assuming that ``--report``
-takes one argument, ``/tmp/report.txt`` is an option argument.  ``foo`` and
+takes one argument, ``report.txt`` is an option argument.  ``foo`` and
 ``bar`` are positional arguments.
 
 
index c44c62e87a3025a2fd44befe073e3f45895b585b..6d7dff8c378554436f73d9893b42985865af195d 100644 (file)
@@ -24,12 +24,12 @@ shell for :func:`os.system` and :func:`os.popen` is required.
 Example::
 
    >>> import pipes
-   >>> t=pipes.Template()
+   >>> t = pipes.Template()
    >>> t.append('tr a-z A-Z', '--')
-   >>> f=t.open('/tmp/1', 'w')
+   >>> f = t.open('pipefile', 'w')
    >>> f.write('hello world')
    >>> f.close()
-   >>> open('/tmp/1').read()
+   >>> open('pipefile').read()
    'HELLO WORLD'
 
 
index c27e4126a2fd8f089749bfbdfc6d8328bd4b9d21..97ef800fb03efc585874d5637aab63f336ab5b2b 100644 (file)
@@ -181,7 +181,7 @@ Examples::
 
    import posixfile
 
-   file = posixfile.open('/tmp/test', 'w')
+   file = posixfile.open('testfile', 'w')
    file.lock('w|')
    ...
    file.lock('u')
index 9cd4996be560cc401ebdd504ab181bfd3c0d408c..29cb3e14935b6699c5cf17f18b691451c1321189 100644 (file)
@@ -200,7 +200,7 @@ A simple example demonstrating the use of the programmatic interface::
    # run the new command using the given tracer
    tracer.run('main()')
 
-   # make a report, placing output in /tmp
+   # make a report, placing output in the current directory
    r = tracer.results()
-   r.write_results(show_missing=True, coverdir="/tmp")
+   r.write_results(show_missing=True, coverdir=".")
 
index af18d159e4d5519603e91a22b322dd5e0596bed0..450f93a97c9ee8b77d67fb2a78aabb9084e2d4ca 100644 (file)
@@ -19,7 +19,7 @@ Typically, :data:`sys.path` is a list of directory names as strings.  This modul
 also allows an item of :data:`sys.path` to be a string naming a ZIP file archive.
 The ZIP archive can contain a subdirectory structure to support package imports,
 and a path within the archive can be specified to only import from a
-subdirectory.  For example, the path :file:`/tmp/example.zip/lib/` would only
+subdirectory.  For example, the path :file:`example.zip/lib/` would only
 import from the :file:`lib/` subdirectory within the archive.
 
 Any files may be present in the ZIP archive, but only files :file:`.py` and
@@ -151,8 +151,8 @@ Examples
 Here is an example that imports a module from a ZIP archive - note that the
 :mod:`zipimport` module is not explicitly used. ::
 
-   $ unzip -l /tmp/example.zip
-   Archive:  /tmp/example.zip
+   $ unzip -l example.zip
+   Archive:  example.zip
      Length     Date   Time    Name
     --------    ----   ----    ----
         8467  11-26-02 22:30   jwzthreading.py
@@ -161,8 +161,8 @@ Here is an example that imports a module from a ZIP archive - note that the
    $ ./python
    Python 2.3 (#1, Aug 1 2003, 19:54:32)
    >>> import sys
-   >>> sys.path.insert(0, '/tmp/example.zip')  # Add .zip file to front of path
+   >>> sys.path.insert(0, 'example.zip')  # Add .zip file to front of path
    >>> import jwzthreading
    >>> jwzthreading.__file__
-   '/tmp/example.zip/jwzthreading.py'
+   'example.zip/jwzthreading.py'
 
index 8da972bb8ac0f4a43c335b0428729b9deab9bf64..2f08110feefcbbff7885b055e1cccc9df81cfcf3 100644 (file)
@@ -236,9 +236,9 @@ arguments: ``open(filename, mode)``.
 
 ::
 
-   >>> f = open('/tmp/workfile', 'w')
+   >>> f = open('workfile', 'w')
    >>> print f
-   <open file '/tmp/workfile', mode 'w' at 80a0960>
+   <open file 'workfile', mode 'w' at 80a0960>
 
 The first argument is a string containing the filename.  The second argument is
 another string containing a few characters describing the way in which the file
@@ -339,7 +339,7 @@ of the file, 1 uses the current file position, and 2 uses the end of the file as
 the reference point.  *from_what* can be omitted and defaults to 0, using the
 beginning of the file as the reference point. ::
 
-   >>> f = open('/tmp/workfile', 'r+')
+   >>> f = open('workfile', 'r+')
    >>> f.write('0123456789abcdef')
    >>> f.seek(5)     # Go to the 6th byte in the file
    >>> f.read(1)
@@ -363,7 +363,7 @@ objects.  This has the advantage that the file is properly closed after its
 suite finishes, even if an exception is raised on the way.  It is also much
 shorter than writing equivalent :keyword:`try`\ -\ :keyword:`finally` blocks::
 
-    >>> with open('/tmp/workfile', 'r') as f:
+    >>> with open('workfile', 'r') as f:
     ...     read_data = f.read()
     >>> f.closed
     True
index c488644113c7f8a76f3762a87b53930d98ad0836..1c453f0c741aafc26b32f7dd45a8e75c9d09215d 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1081,6 +1081,7 @@ Sue Williams
 Gerald S. Williams
 Steven Willis
 Frank Willison
+Geoff Wilson
 Greg V. Wilson
 J Derek Wilson
 Paul Winkler
index 7a51f8ac818abc61f62d4cbcbb4fb77d104c27cb..926593ae0949339433dbbceba4acf6741b578162 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -926,6 +926,10 @@ Tools/Demos
 Documentation
 -------------
 
+- Issue #8890: Stop advertising an insecure practice by replacing uses
+  of the /tmp directory with better alternatives in the documentation.
+  Patch by Geoff Wilson.
+
 - Issue #17203: add long option names to unittest discovery docs.
 
 - Issue #13094: add "Why do lambdas defined in a loop with different values