Skip to content

Commit 0cc3ea6

Browse files
committed
Revert the following revisions, as they don't fix security
problems: 52448, 52468, 52472, 52475, 52646, 52797, 52802, 52863, 52999, 53001, 53101, 53371, 53373, 53383, 53384, 53736, 53812, 53921, 55578, 55580, 55581, 55772, 55775, 56557, 57093, 57094, 58630, 60114
1 parent 0e42f0e commit 0cc3ea6

23 files changed

+71
-211
lines changed

Doc/api/concrete.tex

+4-4
Original file line numberDiff line numberDiff line change
@@ -2730,10 +2730,10 @@ \subsection{DateTime Objects \label{datetime-objects}}
27302730
Various date and time objects are supplied by the \module{datetime}
27312731
module. Before using any of these functions, the header file
27322732
\file{datetime.h} must be included in your source (note that this is
2733-
not included by \file{Python.h}), and the macro
2734-
\cfunction{PyDateTime_IMPORT} must be invoked. The macro puts a
2735-
pointer to a C structure into a static variable,
2736-
\code{PyDateTimeAPI}, that is used by the following macros.
2733+
not include by \file{Python.h}), and macro \cfunction{PyDateTime_IMPORT()}
2734+
must be invoked. The macro arranges to put a pointer to a C structure
2735+
in a static variable \code{PyDateTimeAPI}, which is used by the following
2736+
macros.
27372737

27382738
Type-check macros:
27392739

Doc/lib/libasyncore.tex

+3-5
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ \section{\module{asyncore} ---
199199
\end{methoddesc}
200200

201201
\begin{methoddesc}{bind}{address}
202-
Bind the socket to \var{address}. The socket must not already be
203-
bound. (The format of \var{address} depends on the address family
204-
--- see above.) To mark the socket as re-usable (setting the
205-
\constant{SO_REUSEADDR} option), call the \class{dispatcher}
206-
object's \method{set_reuse_addr()} method.
202+
Bind the socket to \var{address}. The socket must not already
203+
be bound. (The format of \var{address} depends on the address
204+
family --- see above.)
207205
\end{methoddesc}
208206

209207
\begin{methoddesc}{accept}{}

Doc/lib/libcommands.tex

-9
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ \section{\module{commands} ---
1212
return any output generated by the command and, optionally, the exit
1313
status.
1414

15-
The \module{subprocess} module provides more powerful facilities for
16-
spawning new processes and retrieving their results. Using the
17-
\module{subprocess} module is preferable to using the \module{commands}
18-
module.
19-
2015
The \module{commands} module defines the following functions:
2116

2217

@@ -56,7 +51,3 @@ \section{\module{commands} ---
5651
>>> commands.getstatus('/bin/ls')
5752
'-rwxr-xr-x 1 root 13352 Oct 14 1994 /bin/ls'
5853
\end{verbatim}
59-
60-
\begin{seealso}
61-
\seemodule{subprocess}{Module for spawning and managing subprocesses.}
62-
\end{seealso}

Doc/lib/liblogging.tex

+4-9
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,8 @@ \subsection{Logger Objects}
429429
\end{methoddesc}
430430

431431
\begin{methoddesc}{findCaller}{}
432-
Finds the caller's source filename and line number. Returns the filename,
433-
line number and function name as a 3-element tuple.
434-
\versionchanged[The function name was added. In earlier versions, the
435-
filename and line number were returned as a 2-element tuple.]{2.4}
432+
Finds the caller's source filename and line number. Returns the filename
433+
and line number as a 2-element tuple.
436434
\end{methoddesc}
437435

438436
\begin{methoddesc}{handle}{record}
@@ -1082,11 +1080,8 @@ \subsubsection{SysLogHandler}
10821080
communicate with a remote \UNIX{} machine whose address is given by
10831081
\var{address} in the form of a \code{(\var{host}, \var{port})}
10841082
tuple. If \var{address} is not specified, \code{('localhost', 514)} is
1085-
used. The address is used to open a UDP socket. An alternative to providing
1086-
a \code{(\var{host}, \var{port})} tuple is providing an address as a string,
1087-
for example "/dev/log". In this case, a Unix domain socket is used to send
1088-
the message to the syslog. If \var{facility} is not specified,
1089-
\constant{LOG_USER} is used.
1083+
used. The address is used to open a UDP socket. If \var{facility} is
1084+
not specified, \constant{LOG_USER} is used.
10901085
\end{classdesc}
10911086

10921087
\begin{methoddesc}{close}{}

Doc/lib/libos.tex

+2-21
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,6 @@ \subsection{File Object Creation \label{os-newstreams}}
357357
errors), \code{None} is returned.
358358
Availability: Macintosh, \UNIX, Windows.
359359

360-
The \module{subprocess} module provides more powerful facilities for
361-
spawning new processes and retrieving their results; using that module
362-
is preferable to using this function.
363-
364360
\versionchanged[This function worked unreliably under Windows in
365361
earlier versions of Python. This was due to the use of the
366362
\cfunction{_popen()} function from the libraries provided with
@@ -375,13 +371,8 @@ \subsection{File Object Creation \label{os-newstreams}}
375371
Availability: Macintosh, \UNIX, Windows.
376372
\end{funcdesc}
377373

378-
There are a number of different \function{popen*()} functions that
379-
provide slightly different ways to create subprocesses. Note that the
380-
\module{subprocess} module is easier to use and more powerful;
381-
consider using that module before writing code using the
382-
lower-level \function{popen*()} functions.
383374

384-
For each of the \function{popen*()} variants, if \var{bufsize} is
375+
For each of the following \function{popen()} variants, if \var{bufsize} is
385376
specified, it specifies the buffer size for the I/O pipes.
386377
\var{mode}, if provided, should be the string \code{'b'} or
387378
\code{'t'}; on Windows this is needed to determine whether the file
@@ -1513,13 +1504,7 @@ \subsection{Process Management \label{os-process}}
15131504
\funcline{spawnve}{mode, path, args, env}
15141505
\funcline{spawnvp}{mode, file, args}
15151506
\funcline{spawnvpe}{mode, file, args, env}
1516-
Execute the program \var{path} in a new process.
1517-
1518-
(Note that the \module{subprocess} module provides more powerful
1519-
facilities for spawning new processes and retrieving their results;
1520-
using that module is preferable to using these functions.)
1521-
1522-
If \var{mode} is
1507+
Execute the program \var{path} in a new process. If \var{mode} is
15231508
\constant{P_NOWAIT}, this function returns the process ID of the new
15241509
process; if \var{mode} is \constant{P_WAIT}, returns the process's
15251510
exit code if it exits normally, or \code{-\var{signal}}, where
@@ -1647,10 +1632,6 @@ \subsection{Process Management \label{os-process}}
16471632
a non-native shell, consult your shell documentation.
16481633

16491634
Availability: Macintosh, \UNIX, Windows.
1650-
1651-
The \module{subprocess} module provides more powerful facilities for
1652-
spawning new processes and retrieving their results; using that module
1653-
is preferable to using this function.
16541635
\end{funcdesc}
16551636

16561637
\begin{funcdesc}{times}{}

Doc/lib/libpopen2.tex

+4-8
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ \section{\module{popen2} ---
1111
input/output/error pipes and obtain their return codes under
1212
\UNIX{} and Windows.
1313

14-
The \module{subprocess} module provides more powerful facilities for
15-
spawning new processes and retrieving their results. Using the
16-
\module{subprocess} module is preferable to using the \module{popen2}
17-
module.
14+
Note that starting with Python 2.0, this functionality is available
15+
using functions from the \refmodule{os} module which have the same
16+
names as the factory functions here, but the order of the return
17+
values is more intuitive in the \refmodule{os} module variants.
1818

1919
The primary interface offered by this module is a trio of factory
2020
functions. For each of these, if \var{bufsize} is specified,
@@ -184,7 +184,3 @@ \subsection{Flow Control Issues \label{popen2-flow-control}}
184184
separate threads to read each of the individual files provided by
185185
whichever \function{popen*()} function or \class{Popen*} class was
186186
used.
187-
188-
\begin{seealso}
189-
\seemodule{subprocess}{Module for spawning and managing subprocesses.}
190-
\end{seealso}

Doc/lib/libsubprocess.tex

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ \section{\module{subprocess} --- Subprocess management}
1212
codes. This module intends to replace several other, older modules
1313
and functions, such as:
1414

15+
% XXX Should add pointers to this module to at least the popen2
16+
% and commands sections.
17+
1518
\begin{verbatim}
1619
os.system
1720
os.spawn*

Lib/idlelib/EditorWindow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def maybesave(self):
703703

704704
def close(self):
705705
reply = self.maybesave()
706-
if str(reply) != "cancel":
706+
if reply != "cancel":
707707
self._close()
708708
return reply
709709

Lib/logging/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -21,7 +21,7 @@
2121
Should work under Python versions >= 1.5.2, except that source line
2222
information is not available unless 'sys._getframe()' is.
2323
24-
Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
24+
Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
2525
2626
To use, simply 'import logging' and log away!
2727
"""
@@ -68,7 +68,7 @@ def currentframe():
6868
except:
6969
return sys.exc_traceback.tb_frame.f_back
7070

71-
if hasattr(sys, '_getframe'): currentframe = lambda: sys._getframe(3)
71+
if hasattr(sys, '_getframe'): currentframe = sys._getframe
7272
# done filching
7373

7474
# _srcfile is only used in conjunction with sys._getframe().
@@ -1318,14 +1318,14 @@ def disable(level):
13181318
"""
13191319
root.manager.disable = level
13201320

1321-
def shutdown(handlerList=_handlerList):
1321+
def shutdown():
13221322
"""
13231323
Perform any cleanup actions in the logging system (e.g. flushing
13241324
buffers).
13251325
13261326
Should be called at application exit.
13271327
"""
1328-
for h in handlerList[:]:
1328+
for h in _handlerList[:]: # was _handlers.keys():
13291329
#errors might occur, for example, if files are locked
13301330
#we just ignore them if raiseExceptions is not set
13311331
try:

Lib/logging/config.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def fileConfig(fname, defaults=None):
7878
flist = string.split(flist, ",")
7979
formatters = {}
8080
for form in flist:
81-
sectname = "formatter_%s" % string.strip(form)
81+
sectname = "formatter_%s" % form
8282
opts = cp.options(sectname)
8383
if "format" in opts:
8484
fs = cp.get(sectname, "format", 1)
@@ -97,7 +97,6 @@ def fileConfig(fname, defaults=None):
9797
try:
9898
#first, lose the existing handlers...
9999
logging._handlers.clear()
100-
del logging._handlerList[:]
101100
#now set up the new ones...
102101
hlist = cp.get("handlers", "keys")
103102
if len(hlist):
@@ -106,7 +105,7 @@ def fileConfig(fname, defaults=None):
106105
fixups = [] #for inter-handler references
107106
for hand in hlist:
108107
try:
109-
sectname = "handler_%s" % string.strip(hand)
108+
sectname = "handler_%s" % hand
110109
klass = cp.get(sectname, "class")
111110
opts = cp.options(sectname)
112111
if "formatter" in opts:
@@ -141,7 +140,6 @@ def fileConfig(fname, defaults=None):
141140
#at last, the loggers...first the root...
142141
llist = cp.get("loggers", "keys")
143142
llist = string.split(llist, ",")
144-
llist = map(lambda x: string.strip(x), llist)
145143
llist.remove("root")
146144
sectname = "logger_root"
147145
root = logging.root
@@ -156,7 +154,7 @@ def fileConfig(fname, defaults=None):
156154
if len(hlist):
157155
hlist = string.split(hlist, ",")
158156
for hand in hlist:
159-
log.addHandler(handlers[string.strip(hand)])
157+
log.addHandler(handlers[hand])
160158
#and now the others...
161159
#we don't want to lose the existing loggers,
162160
#since other threads may have pointers to them.
@@ -190,7 +188,7 @@ def fileConfig(fname, defaults=None):
190188
if len(hlist):
191189
hlist = string.split(hlist, ",")
192190
for hand in hlist:
193-
logger.addHandler(handlers[string.strip(hand)])
191+
logger.addHandler(handlers[hand])
194192
#Disable any old loggers. There's no point deleting
195193
#them as other threads may continue to hold references
196194
#and by disabling them, you stop them doing any logging.

Lib/logging/handlers.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -22,7 +22,7 @@
2222
Should work under Python versions >= 1.5.2, except that source line
2323
information is not available unless 'sys._getframe()' is.
2424
25-
Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
25+
Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
2626
2727
To use, simply 'import logging' and log away!
2828
"""
@@ -231,11 +231,11 @@ def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None)
231231
# of days in the next week until the rollover day (3).
232232
if when.startswith('W'):
233233
day = t[6] # 0 is Monday
234-
if day != self.dayOfWeek:
235-
if day < self.dayOfWeek:
236-
daysToWait = self.dayOfWeek - day - 1
237-
else:
238-
daysToWait = 6 - day + self.dayOfWeek
234+
if day > self.dayOfWeek:
235+
daysToWait = (day - self.dayOfWeek) - 1
236+
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
237+
if day < self.dayOfWeek:
238+
daysToWait = (6 - self.dayOfWeek) + day
239239
self.rolloverAt = self.rolloverAt + (daysToWait * (60 * 60 * 24))
240240

241241
#print "Will rollover at %d, %d seconds from now" % (self.rolloverAt, self.rolloverAt - currentTime)
@@ -566,20 +566,19 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):
566566
"""
567567
Initialize a handler.
568568
569-
If address is specified as a string, a UNIX socket is used. To log to a
570-
local syslogd, "SysLogHandler(address="/dev/log")" can be used.
569+
If address is specified as a string, UNIX socket is used.
571570
If facility is not specified, LOG_USER is used.
572571
"""
573572
logging.Handler.__init__(self)
574573

575574
self.address = address
576575
self.facility = facility
577576
if type(address) == types.StringType:
578-
self.unixsocket = 1
579577
self._connect_unixsocket(address)
578+
self.unixsocket = 1
580579
else:
581-
self.unixsocket = 0
582580
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
581+
self.unixsocket = 0
583582

584583
self.formatter = None
585584

Lib/random.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def randrange(self, start, stop=None, step=1, int=int, default=None,
205205
raise ValueError, "empty range for randrange()"
206206

207207
if n >= maxwidth:
208-
return istart + istep*self._randbelow(n)
208+
return istart + self._randbelow(n)
209209
return istart + istep*int(self.random() * n)
210210

211211
def randint(self, a, b):

Lib/subprocess.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ class Popen(args, bufsize=0, executable=None,
346346
import os
347347
import types
348348
import traceback
349-
import gc
350349

351350
if mswindows:
352351
import threading
@@ -900,16 +899,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
900899
errpipe_read, errpipe_write = os.pipe()
901900
self._set_cloexec_flag(errpipe_write)
902901

903-
gc_was_enabled = gc.isenabled()
904-
# Disable gc to avoid bug where gc -> file_dealloc ->
905-
# write to stderr -> hang. http://bugs.python.org/issue1336
906-
gc.disable()
907-
try:
908-
self.pid = os.fork()
909-
except:
910-
if gc_was_enabled:
911-
gc.enable()
912-
raise
902+
self.pid = os.fork()
913903
if self.pid == 0:
914904
# Child
915905
try:
@@ -968,8 +958,6 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
968958
os._exit(255)
969959

970960
# Parent
971-
if gc_was_enabled:
972-
gc.enable()
973961
os.close(errpipe_write)
974962
if p2cread and p2cwrite:
975963
os.close(p2cread)

Lib/test/test_dbm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
import random
77
import dbm
88
from dbm import error
9-
from test.test_support import verbose, verify, TestSkipped, TESTFN
9+
from test.test_support import verbose, verify, TestSkipped
1010

1111
# make filename unique to allow multiple concurrent tests
1212
# and to minimize the likelihood of a problem from an old file
13-
filename = TESTFN
13+
filename = '/tmp/delete_me_' + str(random.random())[-6:]
1414

1515
def cleanup():
1616
for suffix in ['', '.pag', '.dir', '.db']:

Lib/test/test_gdbm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
import gdbm
77
from gdbm import error
8-
from test.test_support import verbose, verify, TestFailed, TESTFN
8+
from test.test_support import verbose, verify, TestFailed
99

10-
filename = TESTFN
10+
filename= '/tmp/delete_me'
1111

1212
g = gdbm.open(filename, 'c')
1313
verify(g.keys() == [])

0 commit comments

Comments
 (0)