Commit Graph

6152 Commits

Author SHA1 Message Date
Neal Norwitz
ec7cf1382b Remove another reference to stat.ST_MODE 2002-06-06 18:16:14 +00:00
Martin v. Löwis
33b77de106 Use isinstance for the type check, use booleans. 2002-06-06 18:14:50 +00:00
Guido van Rossum
a48cb8f77d Fix from SF patch 565085: copy._reduction doesn't __setstate__.
Straightforward fix.  Will backport to 2.2.  If there's ever a new 2.1
release, this could be backported there too (since it's an issue with
anything that's got both a __reduce__ and a __setstate__).
2002-06-06 17:53:03 +00:00
Guido van Rossum
3e3583c345 Fix from SF patch 565085: copy._reduction doesn't __setstate__.
Straightforward fix.  Will backport to 2.2.  If there's ever a new 2.1
release, this could be backported there too (since it's an issue with
anything that's got both a __reduce__ and a __setstate__).
2002-06-06 17:41:20 +00:00
Raymond Hettinger
478d47a168 Close SF bug 563740. complex() now finds __complex__() in new style classes.
Made conversion failure error messages consistent between types.
Added related unittests.
2002-06-06 15:45:38 +00:00
Jeremy Hylton
a683233d87 Change warning to debug level; it's a very minor issue.
The specific warning is that clean didn't find a directory that should
be removed if it exists.
2002-06-06 14:54:56 +00:00
Martin v. Löwis
446a25fa3c Patch 473512: add GNU style scanning as gnu_getopt. 2002-06-06 10:58:36 +00:00
Martin v. Löwis
cdbc131f03 Patch #551911: Escape . properly. 2002-06-06 09:52:49 +00:00
Walter Dörwald
294bbf3a59 Replace obsolete stat module constants with
equivalent attributes in a few more spots.

This closes SF patch http://www.python.org/sf/562373
2002-06-06 09:48:13 +00:00
Raymond Hettinger
c4c453f5ae Skip Montanaro's patch, SF 559833, exposing xrange type in builtins.
Also, added more regression tests to cover the new type and test its
conformity with range().
2002-06-05 23:12:45 +00:00
Piers Lauder
f97b2d7dad open method changed to use arguments and set instance host/port values (instead of __init__) 2002-06-05 22:31:57 +00:00
Guido van Rossum
d842e07470 SF bug 558179.
Change default for get() back to None.
Will backport to 2.2.1.
2002-06-05 19:07:39 +00:00
Jeremy Hylton
dc8412e541 Move warning about directory not on sys.path to debug level.
Fix a bunch of multiline string constants that used +.
2002-06-04 21:20:08 +00:00
Jeremy Hylton
8f787bf1d0 Test changes before checking them in. 2002-06-04 21:11:56 +00:00
Jeremy Hylton
40ebbeff23 Track extra arg to option_table to all uses of it 2002-06-04 21:10:35 +00:00
Jeremy Hylton
6b3996b2b9 Replace bogus bare variables with attribute access. 2002-06-04 21:06:16 +00:00
Jeremy Hylton
115fdc614f Define DEBUG as early as possible to avoid import problems. 2002-06-04 21:05:05 +00:00
Jeremy Hylton
4f2f1335a8 Add missing import of log. 2002-06-04 21:04:03 +00:00
Jeremy Hylton
7146073850 Use module-level import of DEBUG instead of many function-level imports. 2002-06-04 21:02:26 +00:00
Jeremy Hylton
fc861bab92 Remove unused imports 2002-06-04 21:00:33 +00:00
Jeremy Hylton
11a52708f7 Make None return explicit 2002-06-04 21:00:20 +00:00
Jeremy Hylton
c58e984837 import base64 at the top to avoid two different imports at other times 2002-06-04 20:55:10 +00:00
Jeremy Hylton
ec772744c7 ensure_filename() only takes one argument.
Call ensure_string() with one arg too, since the second value passed
was the default.
2002-06-04 20:45:17 +00:00
Jeremy Hylton
adb2b38543 Reindent lines to improve readability 2002-06-04 20:42:41 +00:00
Jeremy Hylton
711f91cf83 Remove (commented out) options that have moved into the distribution. 2002-06-04 20:40:03 +00:00
Jeremy Hylton
d003abccc7 get_script() implicitly returned None and also had explicit returns.
Make all returns explicit and rearrange logic to avoid extra
indentation.
2002-06-04 20:39:34 +00:00
Jeremy Hylton
d53f6e43e7 global _option_order is not used 2002-06-04 20:35:10 +00:00
Jeremy Hylton
e6f40ea4b6 Fix bug in recent change to logging code.
mode is not computed in dry_run mode, so it can't be included in the
log message.
2002-06-04 20:30:10 +00:00
Jeremy Hylton
a2f9989c1a Fix unused local variables caught by pychecker.
Fixes a bug for Solaris pkgtool (bdist_pkgtool) that would have
prevented it from building subpackages.
2002-06-04 20:26:44 +00:00
Jeremy Hylton
a181ec07af Set repeat metadata for an option based on repeat local var not
constant.
2002-06-04 20:24:05 +00:00
Jeremy Hylton
332a146127 Remove unused imports caught by pychecker 2002-06-04 20:18:24 +00:00
Jeremy Hylton
cd8a1148e1 Make setup.py less chatty by default.
This is a conservative version of SF patch 504889.  It uses the log
module instead of calling print in various places, and it ignores the
verbose argument passed to many functions and set as an attribute on
some objects.  Instead, it uses the verbosity set on the logger via
the command line.

The log module is now preferred over announce() and warn() methods
that exist only for backwards compatibility.

XXX This checkin changes a lot of modules that have no test suite and
aren't exercised by the Python build process.  It will need
substantial testing.
2002-06-04 20:14:43 +00:00
Jeremy Hylton
6fa82a3477 A simple log mechanism styled after the proposed std library module 2002-06-04 20:00:26 +00:00
Guido van Rossum
9923ffe2c0 Address SF bug 519621: slots weren't traversed by GC.
While I was at it, I added a tp_clear handler and changed the
tp_dealloc handler to use the clear_slots helper for the tp_clear
handler.

Also tightened the rules for slot names: they must now be proper
identifiers (ignoring the dirty little fact that <ctype.h> is locale
sensitive).

Also set mp->flags = READONLY for the __weakref__ pseudo-slot.

Most of this is a 2.2 bugfix candidate; I'll apply it there myself.
2002-06-04 19:52:53 +00:00
Jeremy Hylton
e22bc1e841 The comment said:
# XXX this isn't used anywhere, and worse, it has the same name as a method
 # in Command with subtly different semantics.  (This one just has one
 # source -> one dest; that one has many sources -> one dest.)  Nuke it?

Yes.  Nuke it.
2002-06-04 18:55:54 +00:00
Fred Drake
16c8d702a4 When using a Python that has not been installed to build 3rd-party
modules, distutils does not understand that the build version of the
source tree is needed.

This patch fixes distutils.sysconfig to understand that the running
Python is part of the build tree and needs to use the appropriate
"shape" of the tree. This does not assume anything about the current
directory, so can be used to build 3rd-party modules using Python's
build tree as well.

This is useful since it allows us to use a non-installed debug-mode
Python with 3rd-party modules for testing. It as the side-effect that
set_python_build() is no longer needed (the hack which was added to
allow distutils to be used to build the "standard" extension modules).

This closes SF patch #547734.
2002-06-04 15:28:21 +00:00
Walter Dörwald
474458da48 Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte
Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and
big endian systems.

The old names BOM32_* and BOM64_* were off by a factor of 2.

This closes SF bug http://www.python.org/sf/555360
2002-06-04 15:16:29 +00:00
Guido van Rossum
1bdd9b033a Test repair now that module.__init__ requires a name and initializes
__name__ and __doc__.
2002-06-04 06:10:37 +00:00
Guido van Rossum
bdabeccfb8 Repair the test (adding a docstring to the module type changed the
docstring for an uninitialized module object).
2002-06-04 06:06:54 +00:00
Guido van Rossum
c3a787e090 Surprising fix for SF bug 563060: module can be used as base class.
Change the module constructor (module_init) to have the signature
__init__(name:str, doc=None); this prevents the call from type_new()
to succeed.  While we're at it, prevent repeated calling of
module_init for the same module from leaking the dict, changing the
semantics so that __dict__ is only initialized if NULL.

Also adding a unittest, test_module.py.

This is an incompatibility with 2.2, if anybody was instantiating the
module class before, their argument list was probably empty; so this
can't be backported to 2.2.x.
2002-06-04 05:52:47 +00:00
Raymond Hettinger
88f72ff955 Replace .keys() with .iteritems(). Second review and test by Alex. 2002-06-04 02:17:04 +00:00
Guido van Rossum
155a34d2e5 The warning filter was ineffective when this module was invoked as a
script.
2002-06-03 19:45:32 +00:00
Jeremy Hylton
40bbae3b03 Fix HTTPError __init__ for cases where fp is None.
The HTTPError class tries to act as a regular response objects for
HTTP protocol errors that include full responses.  If the failure is
more basic, like no valid response, the __init__ choked when it tried
to initialize its superclasses in addinfourl hierarchy that requires a
valid response.

The solution isn't elegant but seems to be effective.  Do not
initialize the base classes if there isn't a file object containing
the response.  In this case, user code expecting to use the addinfourl
methods will fail; but it was going to fail anyway.

It might be cleaner to factor out HTTPError into two classes, only one
of which inherits from addinfourl.  Not sure that the extra complexity
would lead to any improved functionality, though.

Partial fix for SF bug # 563665.

Bug fix candidate for 2.1 and 2.2.
2002-06-03 16:53:00 +00:00
Walter Dörwald
65230a2de7 Remove uses of the string and types modules:
x in string.whitespace => x.isspace()
type(x) in types.StringTypes => isinstance(x, basestring)
isinstance(x, types.StringTypes) => isinstance(x, basestring)
type(x) is types.StringType => isinstance(x, str)
type(x) == types.StringType => isinstance(x, str)
string.split(x, ...) => x.split(...)
string.join(x, y) => y.join(x)
string.zfill(x, ...) => x.zfill(...)
string.count(x, ...) => x.count(...)
hasattr(types, "UnicodeType") => try: unicode except NameError:
type(x) != types.TupleTuple => not isinstance(x, tuple)
isinstance(x, types.TupleType) => isinstance(x, tuple)
type(x) is types.IntType => isinstance(x, int)

Do not mention the string module in the rlcompleter docstring.

This partially applies SF patch http://www.python.org/sf/562373
(with basestring instead of string). (It excludes the changes to
unittest.py and does not change the os.stat stuff.)
2002-06-03 15:58:32 +00:00
Walter Dörwald
a401ae4010 Fix a regression from the 1.68->1.69 checkin:
string.split(foo, bar) must be foo.split(bar) instead of bar.split(foo).
2002-06-03 10:41:45 +00:00
Tim Peters
c5000dfc40 regrtest has a new
-f/--fromfile <filename>
option.  This runs all and only the tests named in the file, in the
order given (although -x may weed that list, and -r may shuffle it).
Lines starting with '#' are ignored.

This goes a long way toward helping to automate the binary-search-like
procedure I keep reinventing by hand when a test fails due to interaction
among tests (no failure in isolation, and some unknown number of
predecessor tests need to run first -- now you can stick all the test
names in a file, and comment/uncomment blocks of lines until finding a
minimal set of predecessors).
2002-06-02 21:42:01 +00:00
Barry Warsaw
69e18af968 _parsebody(): Fix for the new message/rfc822 tree structure (the
parent is now a multipart with one element, the sub-message object).
2002-06-02 19:12:03 +00:00
Barry Warsaw
2c68506604 Generator.__call__() => Generator.flatten()
Also, adjust to the new message/rfc822 tree layout.
2002-06-02 19:09:27 +00:00
Barry Warsaw
d2b2e533c0 header_encode(), encode(): Use _floordiv() from the appropriate
compatibility module.
2002-06-02 19:08:31 +00:00
Barry Warsaw
21f77ac0bc Use absolute import paths for intrapackage imports. 2002-06-02 19:07:16 +00:00
Barry Warsaw
8ba76e8929 Use absolute import paths for intrapackage imports.
as_string(): Use Generator.flatten() for better performance.
2002-06-02 19:05:51 +00:00
Barry Warsaw
524af6f382 Use absolute import paths for intrapackage imports.
Use MIMENonMultipart as the base class so that you can't attach() to
these non-multipart message types.
2002-06-02 19:05:08 +00:00
Barry Warsaw
7dc865ad72 flatten(): Renamed from __call__() which is (silently) deprecated.
__call__() can be 2-3x slower than the equivalent normal method.

_handle_message(): The structure of message/rfc822 message has
changed.  Now parent's payload is a list of length 1, and the zeroth
element is the Message sub-object.  Adjust the printing of such
message trees to reflect this change.
2002-06-02 19:02:37 +00:00
Barry Warsaw
ff49279f7c _intdiv2() -> _floordiv(), merge of uncommitted changes. 2002-06-02 18:59:06 +00:00
Raymond Hettinger
e0d4972acc Replaced .keys() with dictionary iterators 2002-06-02 18:55:56 +00:00
Neal Norwitz
1fab9ee085 Get email test to pass. Barry, hope this is what you had in mind 2002-06-02 16:38:14 +00:00
Michael W. Hudson
1ccccc08c2 Make test_mhlib run again.
There's some wierdness here, but the test ran before and not after,
so I'm just hacking the change out.  Someone more motivated than
me can work out what's really happening.

Raymond: *PLEASE* run the test suite before checking things like
this in!
2002-06-02 16:12:06 +00:00
Martin v. Löwis
9ea6c19747 Patch #552060: Add SSLFakeSocket.sendall. Also committed for 2.2 maint. 2002-06-02 12:33:22 +00:00
Raymond Hettinger
10ff706e27 Replaced boolean tests with is None. 2002-06-02 03:04:52 +00:00
Raymond Hettinger
f13eb55d59 Replace boolean test with is None. 2002-06-02 00:40:05 +00:00
Raymond Hettinger
32200aeac6 Replaced obsolete stat module constants with equivalent attributes 2002-06-01 19:51:15 +00:00
Raymond Hettinger
16e3c427f3 Replace boolean test with is None. 2002-06-01 16:07:16 +00:00
Raymond Hettinger
793d4b4936 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:25:41 +00:00
Raymond Hettinger
54f0222547 SF 563203. Replaced 'has_key()' with 'in'. 2002-06-01 14:18:47 +00:00
Barry Warsaw
9d5e4aa414 Bump to version 2.0.5, and also use absolute import paths. 2002-06-01 06:03:09 +00:00
Barry Warsaw
2f514a806d These two classes provide bases for more specific content type
subclasses.

MIMENonMultipart: Base class for non-multipart/* content type subclass
specializations, e.g. image/gif.  This class overrides attach() which
raises an exception, since it makes no sense to attach a subpart to
e.g. an image/gif message.

MIMEMultipart: Base class for multipart/* content type subclass
specializations, e.g. multipart/mixed.  Does little more than provide
a useful constructor.
2002-06-01 05:59:12 +00:00
Barry Warsaw
1c30aa2292 The _compat modules now export _floordiv() instead of _intdiv2() for
better code reuse.

_split() Use _floordiv().
2002-06-01 05:49:17 +00:00
Barry Warsaw
c5d1c045ab Slightly better docstring 2002-06-01 05:45:37 +00:00
Barry Warsaw
bb98c8cff0 _is_unicode(): Use UnicodeType instead of the unicode builtin for
Python 2.1 compatibility.
2002-06-01 03:56:07 +00:00
Raymond Hettinger
936654bce0 Replaced boolean test with is None 2002-06-01 03:06:31 +00:00
Raymond Hettinger
094662a165 Replace boolean test with is None 2002-06-01 01:29:16 +00:00
Raymond Hettinger
0f4940c0a8 Replaced boolean test with 'is None' 2002-06-01 00:57:55 +00:00
Raymond Hettinger
8989ea6ce1 Use is None rather than general boolean 2002-06-01 00:06:20 +00:00
Raymond Hettinger
a144900b86 Use is None rather than general boolean 2002-05-31 23:54:44 +00:00
Raymond Hettinger
c0418609eb Use is None rather than general boolean 2002-05-31 23:03:33 +00:00
Raymond Hettinger
14bd6de0ec SF 560736. Optimize list iteration by filling the tp_iter slot. 2002-05-31 21:40:38 +00:00
Guido van Rossum
59b2a74c75 SF bug 533625 (Armin Rigo). rexec: potential security hole
If a rexec instance allows writing in the current directory (a common
thing to do), there's a way to execute bogus bytecode.  Fix this by
not allowing imports from .pyc files (in a way that allows a site to
configure things so that .pyc files *are* allowed, if writing is not
allowed).

I'll apply this to 2.2 and 2.1 too.
2002-05-31 21:12:53 +00:00
Neal Norwitz
ebb4190709 Use string methods, remove import string 2002-05-31 20:51:31 +00:00
Neal Norwitz
ab19962290 Use more string methods, remove import string 2002-05-31 20:46:39 +00:00
Raymond Hettinger
7fdfc2d231 Replace '== None' with 'is None' 2002-05-31 17:49:10 +00:00
Neal Norwitz
7616504dcf Fix printing plural (s or ""). 2002-05-31 14:15:11 +00:00
Neal Norwitz
5aee504ccb Remove import of re, it is not used 2002-05-31 14:14:06 +00:00
Neal Norwitz
7ce734cd72 Use string methods where possible, and remove import string 2002-05-31 14:13:04 +00:00
Jeremy Hylton
05ab2e693c Fix SF bug [ 561825 ] Confusing error for "del f()"
In the error message, say del for del and assign for everything else.
2002-05-31 14:08:29 +00:00
Andrew M. Kuchling
8c20916de2 Remove unneeded import 2002-05-30 19:15:16 +00:00
Jeremy Hylton
40b7703f1c Verify that the imp can find and load .py files. 2002-05-30 17:10:20 +00:00
Neal Norwitz
efbb67b1a7 Remove comment about inheritance, look one line up 2002-05-30 12:12:04 +00:00
Raymond Hettinger
1dbe6c0728 Move statement out of comment block 2002-05-30 00:06:01 +00:00
Guido van Rossum
ca948b40b4 Use floor division where appropriate. 2002-05-29 20:38:21 +00:00
Fred Drake
127ee1607f Minor cleanup:
- Add comment explaining the structure of the stack.
- Minor optimization: make stack tuple directly usable as part of return
  value for enter/exit events.
2002-05-29 19:40:36 +00:00
Raymond Hettinger
aef22fb9cd Patch 560023 adding docstrings. 2.2 Candidate (after verifying modules were not updated after 2.2). 2002-05-29 16:18:42 +00:00
Neal Norwitz
d68f5171eb As discussed on python-dev, add a mechanism to indicate features
that are in the process of deprecation (PendingDeprecationWarning).
Docs could be improved.
2002-05-29 15:54:55 +00:00
Neal Norwitz
72a2b4d43f Whitespace normalization 2002-05-29 00:54:38 +00:00
Guido van Rossum
1a7ac359a0 Importing Charset should not fail when Unicode is disabled. (XXX
Using Unicode-aware methods may still die with a NameError on unicode.
Maybe there's a more elegant solution but I doubt anybody cares.)
2002-05-28 18:49:03 +00:00
Christian Tismer
313a7513b0 This is a Python 2.1 and 2.2 bugfix candidate:
(or how do I "mark" something to be a candidate?)

fixed an old buglet that caused bdb to be unable to
continue in the botframe, after a breakpoint was set.
the key idea is not to set botframe to the bottom level frame,
but its f_back, which actually might be None.
Additional changes: migrated old exception trick to use
sys._getframe(), which exists both in 2.1 and 2.2 .

Note: I believe Mark Hammond needs to look over his code now.
F5 correctly starts up in the debugger, but later on doesn't stop at a given
breakpoint any longer.

kind regards - chris
2002-05-28 08:04:00 +00:00
Steven M. Gava
72de9c7a9c Geiger Ho's patch for better subclassing 2002-05-27 21:58:05 +00:00
Michael W. Hudson
34f20eac98 This is patch
[ 559250 ] more POSIX signal stuff

Adds support (and docs and tests and autoconfery) for posix signal
mask handling -- sigpending, sigprocmask and sigsuspend.
2002-05-27 15:08:24 +00:00
Chui Tey
5d2af63cc3 GvR's rpc patch 2002-05-26 13:36:41 +00:00
Guido van Rossum
9fc8a29663 Fix for SF bug 551412. When _PyType_Lookup() is called on a type
whose tp_mro hasn't been initialized, it would dump core.  Fix this by
checking for NULL and calling PyType_Ready().  Will fix this in 2.2.1
too.
2002-05-24 21:40:08 +00:00
Guido van Rossum
4b46c0a15f Don't require Unicode support. 2002-05-24 17:58:05 +00:00