]> granicus.if.org Git - python/log
python
22 years agoUse True/False instead of 1/0.
Greg Ward [Fri, 7 Jun 2002 22:35:41 +0000 (22:35 +0000)]
Use True/False instead of 1/0.

22 years agoRemove islower() -- not used anymore.
Greg Ward [Fri, 7 Jun 2002 22:33:11 +0000 (22:33 +0000)]
Remove islower() -- not used anymore.

22 years agoConform to the bloody coding standards: "def foo()" not "def foo ()".
Greg Ward [Fri, 7 Jun 2002 22:32:15 +0000 (22:32 +0000)]
Conform to the bloody coding standards: "def foo()" not "def foo ()".
Yuck.

22 years agoConvert _fix_sentence_endings() to use a regex, and augment it to
Greg Ward [Fri, 7 Jun 2002 22:04:15 +0000 (22:04 +0000)]
Convert _fix_sentence_endings() to use a regex, and augment it to
handle sentences like this:
  And she said, "Go to hell!"  Can you believe that?

22 years agoAdd fix_sentence_endings option to control whether we ensure that
Greg Ward [Fri, 7 Jun 2002 21:56:16 +0000 (21:56 +0000)]
Add fix_sentence_endings option to control whether we ensure that
sentences are separated by two spaces.

Improve _fix_sentence_endings() a bit -- look for ".!?" instead of just
".", and factor out the list of sentence-ending punctuation characters
to a class attribute.

22 years agoInitial revision. Currently biased towards English in a fixed-width font,
Greg Ward [Fri, 7 Jun 2002 21:43:37 +0000 (21:43 +0000)]
Initial revision.  Currently biased towards English in a fixed-width font,
according to the conventions that I (and Tim Peters) learned in school.

22 years agoMove the conex_finally label up, so that the errno value is always
Guido van Rossum [Fri, 7 Jun 2002 19:55:29 +0000 (19:55 +0000)]
Move the conex_finally label up, so that the errno value is always
returned.

22 years agoAdded Bernard Yue who wrote test_timeout.py and participated in the
Guido van Rossum [Fri, 7 Jun 2002 15:58:53 +0000 (15:58 +0000)]
Added Bernard Yue who wrote test_timeout.py and participated in the
timeout socket patch design.

22 years agoAdded the 7 new top level domains, and reworded the nameorgs output.
Barry Warsaw [Fri, 7 Jun 2002 15:48:52 +0000 (15:48 +0000)]
Added the 7 new top level domains, and reworded the nameorgs output.
Not sure this is better in all cases.

parse(): Fixed a bug in the output; the dict is referred to in the
code as `countries' not `country'.  Also added no-case-fold for the
string "U.S." since the Virgin Islands name no longer wraps those in
parentheses.

main(): Fixed the argument parsing to agree with the docstring, i.e.
--outputdict instead of --output.

In the module docstring:

- updated my email address
- we don't need to explain about Python 1.5 regexps <wink>

We also don't need to wrap the import of re with a try/except.

Other style fixes:

- untabification
- revert back to <> style everywhere (and consistently)

22 years agoAdded -t (--threshold) option to call gc.set_threshold(N).
Guido van Rossum [Fri, 7 Jun 2002 15:17:03 +0000 (15:17 +0000)]
Added -t (--threshold) option to call gc.set_threshold(N).

22 years agoApply diff2.txt from SF patch http://www.python.org/sf/565471
Walter Dörwald [Fri, 7 Jun 2002 14:47:20 +0000 (14:47 +0000)]
Apply diff2.txt from SF patch http://www.python.org/sf/565471

This patch replaces string module functions with string
methods in the Tools/world/world scripts.

It also updates two outdated URLs and the countrycodes
dictionary.

It fixes a bug where result of string.find() was checked
for truth instead of compared with -1.

It also replaces <> with != in two spots.

22 years agoAdd timeout mode. Clarify gnu_getopt.
Guido van Rossum [Fri, 7 Jun 2002 12:40:52 +0000 (12:40 +0000)]
Add timeout mode.  Clarify gnu_getopt.

22 years agoClarify the interaction between timeout/non-blocking mode, makefile
Guido van Rossum [Fri, 7 Jun 2002 12:38:23 +0000 (12:38 +0000)]
Clarify the interaction between timeout/non-blocking mode, makefile
and fromfd.

22 years agoFix typo
Neal Norwitz [Fri, 7 Jun 2002 12:36:44 +0000 (12:36 +0000)]
Fix typo

22 years agoClarify the interaction between blocking and timeouts. Explain that
Guido van Rossum [Fri, 7 Jun 2002 03:39:21 +0000 (03:39 +0000)]
Clarify the interaction between blocking and timeouts.  Explain that
fromfd() assumes a blocking non-timeout socket.

22 years agoI decided to change the interaction between setblocking() and
Guido van Rossum [Fri, 7 Jun 2002 03:36:20 +0000 (03:36 +0000)]
I decided to change the interaction between setblocking() and
settimeout().   Already, settimeout() canceled non-blocking mode; now,
setblocking() also cancels the timeout.  This is easier to document.

(XXX should settimeout(0) be an alias for setblocking(0)?  They seem
to have roughly the same effect.  Also, I'm not sure that the code in
connect() and accept() is correct in all cases.  We'll sort this out
soon enough.)

22 years agognu_getopt should be exported in __all__
Skip Montanaro [Fri, 7 Jun 2002 03:26:43 +0000 (03:26 +0000)]
gnu_getopt should be exported in __all__

22 years agoMajor cleanup. Renamed static methods to avoid Py prefix. Other misc
Guido van Rossum [Fri, 7 Jun 2002 03:19:37 +0000 (03:19 +0000)]
Major cleanup.  Renamed static methods to avoid Py prefix.  Other misc
cleanup as well, e.g. renamed NTinit to os_init.

22 years agoRepair a comment.
Guido van Rossum [Fri, 7 Jun 2002 02:27:50 +0000 (02:27 +0000)]
Repair a comment.

22 years agoWhitespace normalization, folding long lines, uniform comment
Guido van Rossum [Fri, 7 Jun 2002 02:08:35 +0000 (02:08 +0000)]
Whitespace normalization, folding long lines, uniform comment
delimiters.  Also repaired some docstrings and comments.

22 years agoCorrect several blunders in the timeout code, mostly my own fault (for
Guido van Rossum [Fri, 7 Jun 2002 01:42:47 +0000 (01:42 +0000)]
Correct several blunders in the timeout code, mostly my own fault (for
not testing it -- apparently test_timeout.py doesn't test anything
useful):

In internal_select():

- The tv_usec part of the timeout for select() was calculated wrong.

- The first argument to select() was one too low.

- The sense of the direction argument to internal_select() was
  inverted.

In PySocketSock_settimeout():

- The calls to internal_setblocking() were swapped.

Also, repaired some comments and fixed the test for the return value
of internal_select() in sendall -- this was in the original patch.

22 years agoRemove casts to PyObject * when declaration is for PyObject *
Jeremy Hylton [Thu, 6 Jun 2002 23:23:55 +0000 (23:23 +0000)]
Remove casts to PyObject * when declaration is for PyObject *

22 years agoAdd version info, and fix another typo and wording spotted by /F. I think this is...
Neal Norwitz [Thu, 6 Jun 2002 22:24:10 +0000 (22:24 +0000)]
Add version info, and fix another typo and wording spotted by /F.  I think this is what he meant. :-)

22 years agoFix typo spotted by Fredrik Lundh.
Fred Drake [Thu, 6 Jun 2002 22:19:20 +0000 (22:19 +0000)]
Fix typo spotted by Fredrik Lundh.

22 years agoFix some markup errors and adjust wording slightly.
Fred Drake [Thu, 6 Jun 2002 21:57:48 +0000 (21:57 +0000)]
Fix some markup errors and adjust wording slightly.

22 years agoSF patch 555085 (timeout socket implementation) by Michael Gilfix.
Guido van Rossum [Thu, 6 Jun 2002 21:51:01 +0000 (21:51 +0000)]
SF patch 555085 (timeout socket implementation) by Michael Gilfix.

I've made considerable changes to Michael's code, specifically to use
the select() system call directly and to store the timeout as a C
double instead of a Python object; internally, -1.0 (or anything
negative) represents the None from the API.

I'm not 100% sure that all corner cases are covered correctly, so
please keep an eye on this.  Next I'm going to try it Windows before
Tim complains.

No way is this a bugfix candidate. :-)

22 years agoMichael Gilfix of SF patch 555085 fame.
Guido van Rossum [Thu, 6 Jun 2002 21:08:46 +0000 (21:08 +0000)]
Michael Gilfix of SF patch 555085 fame.

22 years agoSF patch 555085 (timeout socket implementation) by Michael Gilfix.
Guido van Rossum [Thu, 6 Jun 2002 21:08:16 +0000 (21:08 +0000)]
SF patch 555085 (timeout socket implementation) by Michael Gilfix.

I've made considerable changes to Michael's code, specifically to use
the select() system call directly and to store the timeout as a C
double instead of a Python object; internally, -1.0 (or anything
negative) represents the None from the API.

I'm not 100% sure that all corner cases are covered correctly, so
please keep an eye on this.  Next I'm going to try it Windows before
Tim complains.

No way is this a bugfix candidate. :-)

22 years agoThe insint() function is not used. Nuke it.
Guido van Rossum [Thu, 6 Jun 2002 20:41:10 +0000 (20:41 +0000)]
The insint() function is not used.  Nuke it.

22 years agoThe tp_new implementation should initialize the errorhandler field,
Guido van Rossum [Thu, 6 Jun 2002 20:08:25 +0000 (20:08 +0000)]
The tp_new implementation should initialize the errorhandler field,
otherwise this code could segfault:

  from socket import socket
  s = socket.__new__(socket)
  s.recv(100)

22 years agoRemove uses of string module and stat.ST_MODE
Neal Norwitz [Thu, 6 Jun 2002 18:30:10 +0000 (18:30 +0000)]
Remove uses of string module and stat.ST_MODE

22 years agoRemove another reference to stat.ST_MODE
Neal Norwitz [Thu, 6 Jun 2002 18:16:14 +0000 (18:16 +0000)]
Remove another reference to stat.ST_MODE

22 years agoUse isinstance for the type check, use booleans.
Martin v. Löwis [Thu, 6 Jun 2002 18:14:50 +0000 (18:14 +0000)]
Use isinstance for the type check, use booleans.

22 years agoFix from SF patch 565085: copy._reduction doesn't __setstate__.
Guido van Rossum [Thu, 6 Jun 2002 17:53:03 +0000 (17:53 +0000)]
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__).

22 years agoFix from SF patch 565085: copy._reduction doesn't __setstate__.
Guido van Rossum [Thu, 6 Jun 2002 17:41:20 +0000 (17:41 +0000)]
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__).

22 years agoApply diff.txt from SF patch http://www.python.org/sf/561478
Walter Dörwald [Thu, 6 Jun 2002 17:01:21 +0000 (17:01 +0000)]
Apply diff.txt from SF patch http://www.python.org/sf/561478

This uses cgi.parse_header() in Checker.checkforhtml(), so that
webchecker recognises the mime type text/html even if options
are specified.

22 years agoClose SF bug 563740. complex() now finds __complex__() in new style classes.
Raymond Hettinger [Thu, 6 Jun 2002 15:45:38 +0000 (15:45 +0000)]
Close SF bug 563740. complex() now finds __complex__() in new style classes.
Made conversion failure error messages consistent between types.
Added related unittests.

22 years agoPyrangeiter_Type && range_iter should be static
Neal Norwitz [Thu, 6 Jun 2002 14:58:21 +0000 (14:58 +0000)]
Pyrangeiter_Type && range_iter should be static

22 years agoChange warning to debug level; it's a very minor issue.
Jeremy Hylton [Thu, 6 Jun 2002 14:54:56 +0000 (14:54 +0000)]
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.

22 years agoStop testing for sigprocmask. This is a stop gap measure until I work
Michael W. Hudson [Thu, 6 Jun 2002 13:03:44 +0000 (13:03 +0000)]
Stop testing for sigprocmask.  This is a stop gap measure until I work
out how to just activate my code on platforms where I know it works
(currently only linux/x86).

22 years agoPatch 473512: add GNU style scanning as gnu_getopt.
Martin v. Löwis [Thu, 6 Jun 2002 10:58:36 +0000 (10:58 +0000)]
Patch 473512: add GNU style scanning as gnu_getopt.

22 years agoPatch #551911: Escape . properly.
Martin v. Löwis [Thu, 6 Jun 2002 09:52:49 +0000 (09:52 +0000)]
Patch #551911: Escape . properly.

22 years agoReplace obsolete stat module constants with
Walter Dörwald [Thu, 6 Jun 2002 09:48:13 +0000 (09:48 +0000)]
Replace obsolete stat module constants with
equivalent attributes in a few more spots.

This closes SF patch http://www.python.org/sf/562373

22 years agoCRLF -> LF
Guido van Rossum [Thu, 6 Jun 2002 00:44:16 +0000 (00:44 +0000)]
CRLF -> LF

22 years agoSkip Montanaro's patch, SF 559833, exposing xrange type in builtins.
Raymond Hettinger [Wed, 5 Jun 2002 23:12:45 +0000 (23:12 +0000)]
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().

22 years agoopen method changed to use arguments and set instance host/port values (instead of...
Piers Lauder [Wed, 5 Jun 2002 22:31:57 +0000 (22:31 +0000)]
open method changed to use arguments and set instance host/port values (instead of __init__)

22 years agoSF 564601 adding rangeiterobject to make xrange() iterate like range().
Raymond Hettinger [Wed, 5 Jun 2002 20:08:48 +0000 (20:08 +0000)]
SF 564601 adding rangeiterobject to make xrange() iterate like range().

22 years agoSF bug 558179.
Guido van Rossum [Wed, 5 Jun 2002 19:07:39 +0000 (19:07 +0000)]
SF bug 558179.
Change default for get() back to None.
Will backport to 2.2.1.

22 years agofixed refcount leak in CreateNewWindow() and CreateWindowFromResource().
Just van Rossum [Wed, 5 Jun 2002 17:41:03 +0000 (17:41 +0000)]
fixed refcount leak in CreateNewWindow() and CreateWindowFromResource().

22 years agoBetter isinstance error message.
Thomas Heller [Wed, 5 Jun 2002 12:55:19 +0000 (12:55 +0000)]
Better isinstance error message.

Closes SF patch # 560250.

Bugfix candidate IMO.

22 years agoMove warning about directory not on sys.path to debug level.
Jeremy Hylton [Tue, 4 Jun 2002 21:20:08 +0000 (21:20 +0000)]
Move warning about directory not on sys.path to debug level.

Fix a bunch of multiline string constants that used +.

22 years agoTest changes before checking them in.
Jeremy Hylton [Tue, 4 Jun 2002 21:11:56 +0000 (21:11 +0000)]
Test changes before checking them in.

22 years agoTrack extra arg to option_table to all uses of it
Jeremy Hylton [Tue, 4 Jun 2002 21:10:35 +0000 (21:10 +0000)]
Track extra arg to option_table to all uses of it

22 years agoReplace bogus bare variables with attribute access.
Jeremy Hylton [Tue, 4 Jun 2002 21:06:16 +0000 (21:06 +0000)]
Replace bogus bare variables with attribute access.

22 years agoDefine DEBUG as early as possible to avoid import problems.
Jeremy Hylton [Tue, 4 Jun 2002 21:05:05 +0000 (21:05 +0000)]
Define DEBUG as early as possible to avoid import problems.

22 years agoAdd missing import of log.
Jeremy Hylton [Tue, 4 Jun 2002 21:04:03 +0000 (21:04 +0000)]
Add missing import of log.

22 years agoUse module-level import of DEBUG instead of many function-level imports.
Jeremy Hylton [Tue, 4 Jun 2002 21:02:26 +0000 (21:02 +0000)]
Use module-level import of DEBUG instead of many function-level imports.

22 years agoRemove unused imports
Jeremy Hylton [Tue, 4 Jun 2002 21:00:33 +0000 (21:00 +0000)]
Remove unused imports

22 years agoMake None return explicit
Jeremy Hylton [Tue, 4 Jun 2002 21:00:20 +0000 (21:00 +0000)]
Make None return explicit

22 years agoimport base64 at the top to avoid two different imports at other times
Jeremy Hylton [Tue, 4 Jun 2002 20:55:10 +0000 (20:55 +0000)]
import base64 at the top to avoid two different imports at other times

22 years agoensure_filename() only takes one argument.
Jeremy Hylton [Tue, 4 Jun 2002 20:45:17 +0000 (20:45 +0000)]
ensure_filename() only takes one argument.

Call ensure_string() with one arg too, since the second value passed
was the default.

22 years agoReindent lines to improve readability
Jeremy Hylton [Tue, 4 Jun 2002 20:42:41 +0000 (20:42 +0000)]
Reindent lines to improve readability

22 years agoRemove (commented out) options that have moved into the distribution.
Jeremy Hylton [Tue, 4 Jun 2002 20:40:03 +0000 (20:40 +0000)]
Remove (commented out) options that have moved into the distribution.

22 years agoget_script() implicitly returned None and also had explicit returns.
Jeremy Hylton [Tue, 4 Jun 2002 20:39:34 +0000 (20:39 +0000)]
get_script() implicitly returned None and also had explicit returns.

Make all returns explicit and rearrange logic to avoid extra
indentation.

22 years agoglobal _option_order is not used
Jeremy Hylton [Tue, 4 Jun 2002 20:35:10 +0000 (20:35 +0000)]
global _option_order is not used

22 years agoFix bug in recent change to logging code.
Jeremy Hylton [Tue, 4 Jun 2002 20:30:10 +0000 (20:30 +0000)]
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.

22 years agoFix unused local variables caught by pychecker.
Jeremy Hylton [Tue, 4 Jun 2002 20:26:44 +0000 (20:26 +0000)]
Fix unused local variables caught by pychecker.

Fixes a bug for Solaris pkgtool (bdist_pkgtool) that would have
prevented it from building subpackages.

22 years agoSet repeat metadata for an option based on repeat local var not
Jeremy Hylton [Tue, 4 Jun 2002 20:24:05 +0000 (20:24 +0000)]
Set repeat metadata for an option based on repeat local var not
constant.

22 years agoRemove unused imports caught by pychecker
Jeremy Hylton [Tue, 4 Jun 2002 20:18:24 +0000 (20:18 +0000)]
Remove unused imports caught by pychecker

22 years agoMake setup.py less chatty by default.
Jeremy Hylton [Tue, 4 Jun 2002 20:14:43 +0000 (20:14 +0000)]
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.

22 years agoA simple log mechanism styled after the proposed std library module
Jeremy Hylton [Tue, 4 Jun 2002 20:00:26 +0000 (20:00 +0000)]
A simple log mechanism styled after the proposed std library module

22 years agoAddress SF bug 519621: slots weren't traversed by GC.
Guido van Rossum [Tue, 4 Jun 2002 19:52:53 +0000 (19:52 +0000)]
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.

22 years agoThe comment said:
Jeremy Hylton [Tue, 4 Jun 2002 18:55:54 +0000 (18:55 +0000)]
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.

22 years agoInverted test for small speedup
Raymond Hettinger [Tue, 4 Jun 2002 18:45:50 +0000 (18:45 +0000)]
Inverted test for small speedup

22 years agoFiddle wording.
Michael W. Hudson [Tue, 4 Jun 2002 18:27:35 +0000 (18:27 +0000)]
Fiddle wording.

22 years agoFix SF bug #557436, TclError is a str should be an Exception
Neal Norwitz [Tue, 4 Jun 2002 17:14:07 +0000 (17:14 +0000)]
Fix SF bug #557436, TclError is a str should be an Exception

Make Tkinter.TclError derive from Exception, it was a string.

22 years agoFix up Guido's markup.
Fred Drake [Tue, 4 Jun 2002 16:25:57 +0000 (16:25 +0000)]
Fix up Guido's markup.

22 years agoWhen using a Python that has not been installed to build 3rd-party
Fred Drake [Tue, 4 Jun 2002 15:28:21 +0000 (15:28 +0000)]
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.

22 years agoAdd constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE,
Walter Dörwald [Tue, 4 Jun 2002 15:16:29 +0000 (15:16 +0000)]
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

22 years agoPatch #555929: Cygwin AH_BOTTOM cleanup patch (*** version 2 ***)
Jason Tishler [Tue, 4 Jun 2002 15:07:08 +0000 (15:07 +0000)]
Patch #555929: Cygwin AH_BOTTOM cleanup patch (*** version 2 ***)

This patch complies with the following request found
near the top of configure.in:

# This is for stuff that absolutely must end up in pyconfig.h.
# Please use pyport.h instead, if possible.

I tested this patch under Cygwin, Win32, and Red
Hat Linux. Python built and ran successfully on
each of these platforms.

22 years agoTest repair now that module.__init__ requires a name and initializes
Guido van Rossum [Tue, 4 Jun 2002 06:10:37 +0000 (06:10 +0000)]
Test repair now that module.__init__ requires a name and initializes
__name__ and __doc__.

22 years agoRepair the test (adding a docstring to the module type changed the
Guido van Rossum [Tue, 4 Jun 2002 06:06:54 +0000 (06:06 +0000)]
Repair the test (adding a docstring to the module type changed the
docstring for an uninitialized module object).

22 years agoAdd a docstring to the module type.
Guido van Rossum [Tue, 4 Jun 2002 06:02:35 +0000 (06:02 +0000)]
Add a docstring to the module type.

22 years agoSurprising fix for SF bug 563060: module can be used as base class.
Guido van Rossum [Tue, 4 Jun 2002 05:58:34 +0000 (05:58 +0000)]
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.

22 years agoSurprising fix for SF bug 563060: module can be used as base class.
Guido van Rossum [Tue, 4 Jun 2002 05:52:47 +0000 (05:52 +0000)]
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.

22 years agoReplace .keys() with .iteritems(). Second review and test by Alex.
Raymond Hettinger [Tue, 4 Jun 2002 02:17:04 +0000 (02:17 +0000)]
Replace .keys() with .iteritems().  Second review and test by Alex.

22 years agoAddress the residual issue with the fix for SF 551412 in
Guido van Rossum [Mon, 3 Jun 2002 19:52:41 +0000 (19:52 +0000)]
Address the residual issue with the fix for SF 551412 in
_PyType_Lookup().  Decided to clear the error condition in the
unfortunate but unlikely case that PyType_Ready() fails.

Will fix in 2.2.x too.

22 years agoThe warning filter was ineffective when this module was invoked as a
Guido van Rossum [Mon, 3 Jun 2002 19:45:32 +0000 (19:45 +0000)]
The warning filter was ineffective when this module was invoked as a
script.

22 years agoAddressed SF bug 421973 (finally).
Guido van Rossum [Mon, 3 Jun 2002 19:06:41 +0000 (19:06 +0000)]
Addressed SF bug 421973 (finally).

Rewrote the subsection on coercion rules (and made it a proper
subsection, with a label).  The new section is much less precise,
because precise rules would be too hard to give (== I don't know what
they are any more :-).  OTOH, the new section gives much more
up-to-date information.

Also noted that __coerce__ may return NotImplemented, with the same
meaning as None.

I beg Fred forgiveness: my use of \code{} is probably naive.  Please
fix this and other markup nits.  An index entry would be nice.

This could be a 2.2 bugfix candidate, if we bother about old docs
(Fred?)

22 years agoFix HTTPError __init__ for cases where fp is None.
Jeremy Hylton [Mon, 3 Jun 2002 16:53:00 +0000 (16:53 +0000)]
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.

22 years agoRemove uses of the string and types modules:
Walter Dörwald [Mon, 3 Jun 2002 15:58:32 +0000 (15:58 +0000)]
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.)

22 years agoFix a regression from the 1.68->1.69 checkin:
Walter Dörwald [Mon, 3 Jun 2002 10:41:45 +0000 (10:41 +0000)]
Fix a regression from the 1.68->1.69 checkin:

string.split(foo, bar) must be foo.split(bar) instead of bar.split(foo).

22 years agoregrtest has a new
Tim Peters [Sun, 2 Jun 2002 21:42:01 +0000 (21:42 +0000)]
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).

22 years ago_parsebody(): Fix for the new message/rfc822 tree structure (the
Barry Warsaw [Sun, 2 Jun 2002 19:12:03 +0000 (19:12 +0000)]
_parsebody(): Fix for the new message/rfc822 tree structure (the
parent is now a multipart with one element, the sub-message object).

22 years agoGenerator.__call__() => Generator.flatten()
Barry Warsaw [Sun, 2 Jun 2002 19:09:27 +0000 (19:09 +0000)]
Generator.__call__() => Generator.flatten()

Also, adjust to the new message/rfc822 tree layout.

22 years agoheader_encode(), encode(): Use _floordiv() from the appropriate
Barry Warsaw [Sun, 2 Jun 2002 19:08:31 +0000 (19:08 +0000)]
header_encode(), encode(): Use _floordiv() from the appropriate
compatibility module.

22 years agoUse absolute import paths for intrapackage imports.
Barry Warsaw [Sun, 2 Jun 2002 19:07:16 +0000 (19:07 +0000)]
Use absolute import paths for intrapackage imports.

22 years agoUse absolute import paths for intrapackage imports.
Barry Warsaw [Sun, 2 Jun 2002 19:05:51 +0000 (19:05 +0000)]
Use absolute import paths for intrapackage imports.

as_string(): Use Generator.flatten() for better performance.

22 years agoUse absolute import paths for intrapackage imports.
Barry Warsaw [Sun, 2 Jun 2002 19:05:08 +0000 (19:05 +0000)]
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.

22 years agoflatten(): Renamed from __call__() which is (silently) deprecated.
Barry Warsaw [Sun, 2 Jun 2002 19:02:37 +0000 (19:02 +0000)]
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.