Changed basicConfig() to add keyword arguments. Changes are backward-compatible.
Added error checking to log() to check that level is an integer, and raise a TypeError if not (as long as raiseExceptions is set).
Minor documentation corrections.
Work through several open todos:
* Added test for pickling contexts
* Renamed ExceptionList to Signals (to match wording in the spec)
* Simplified Context constructor by allowing flags=None to automatically
generate a zeroed-out flags dictionary.
* inlined _convertString() which was used only once
* _rounding_decision is private, so excluded its contants from __all__.
* added an XXX comment with concerns about subclassing signals results in
a deviation from the spec (maybe important, maybe not).
* Taught the test_suite to determine its own directory (modeled after code
in regrtest.py). Enables it to be run when the current directory is not
the test directory.
* Added a clear_flags() method to the Context API to make it easier to do
a common operation with flags.
* Fixed the trap_enablers defaults in BasicDefaultContext to match the spec.
threading.Thread objects will now print a traceback for an exception raised
during interpreter shutdown instead of masking it with another traceback about
accessing a NoneType when trying to print the exception out in the first place.
Mark Hammond [Fri, 2 Jul 2004 23:53:16 +0000 (23:53 +0000)]
Patch [ 983775 ] Allow bdist_wininst to install for non-admin users
to address bugs:
[ 555812 ] installing extension w/o admin rights
[ 555810 ] removing extensions without admin rights
* When enumerating the Python versions found, also remember the HKEY
they were found under.
* When installing, if Python was installed under HKCU, we will too.
If Python was installed under HKLM, we check the permissions of
the current user, and install where we can.
* The "root" key we use is a global variable - all registry setting and
delete functions use this global rather than a hardcoded HKLM.
* A new entry is written to the install log, indicating the key we used.
Uninstallation is based on this key.
* 'tempnam()' is used rather than 'tmpnam()' - 'tmpnam' creates a temp
file on the root of the current drive, and if this is readonly would
explain the 'freopen' errors occasionally reported. 'tempnam'
creates the temp file in the %TEMP% directory.
Fred Drake [Fri, 2 Jul 2004 18:57:45 +0000 (18:57 +0000)]
Make weak references subclassable:
- weakref.ref and weakref.ReferenceType will become aliases for each
other
- weakref.ref will be a modern, new-style class with proper __new__
and __init__ methods
- weakref.WeakValueDictionary will have a lighter memory footprint,
using a new weakref.ref subclass to associate the key with the
value, allowing us to have only a single object of overhead for each
dictionary entry (currently, there are 3 objects of overhead per
entry: a weakref to the value, a weakref to the dictionary, and a
function object used as a weakref callback; the weakref to the
dictionary could be avoided without this change)
- a new macro, PyWeakref_CheckRefExact(), will be added
- PyWeakref_CheckRef() will check for subclasses of weakref.ref
Thomas Heller [Fri, 2 Jul 2004 08:53:57 +0000 (08:53 +0000)]
When importing an extension on Windows, the code reads the PE 'import
table' of the dll, to make sure that the dll really was build for the
correct Python version. It does this by looking for an entry
'pythonXY.dll' (X.Y is the Python version number).
The code now checks the size of the dll's import table before reading
entries from it. Before this patch, the code crashed trying to read
the import table when the size was zero (as in Win2k's wmi.dll, for
example).
Look for imports of 'pythonXY_d.dll' in a debug build instead of
'pythonXY.dll'.
Fixes SF 951851: Crash when reading "import table" of certain windows dlls.
SF Bug #215126: Over restricted type checking on eval() function
The builtin eval() function now accepts any mapping for the locals argument.
Time sensitive steps guarded by PyDict_CheckExact() to keep from slowing
down the normal case. My timings so no measurable impact.
Change signatures for arguments to "s" and friends to be the proper ``const
char *`` instead of just ``char *``. Also added the mentioning of "const" in
some places where it was left out even when the signature already stated the
fact.
[ 924301 ] A leak case with cmd.py & readline & exception
by ensuring that the readline completion function is always reset
even in the case of an exception being raised. As a bonus, this
makes the documentation for pre & postloop accurate again.
[Bug #948970] Add PyExc_* symbols to index.
(I ran this through texcheck, but don't have LaTeX installed on this machine and therefore haven't
verified that the changes are accepted by LaTeX.)
[Bug #912845] urllib2 only checks for a 200 return code, but 206 is also legal if a Range: header was supplied.
(Actually, should the first 'if' statement be modified to allow any 2xx status code?)
Brett Cannon [Tue, 29 Jun 2004 03:48:23 +0000 (03:48 +0000)]
Changed applicable use of ``char *`` declarations that are passed into
PyArg_ParseTuple() to ``const char *`` to match the recommendation made in
section 1.3 and to support better coding habits.
Section 1.8 ("Keyword Parameters for Extension Functions") and it's coding
example were not touched since it is stems from an accredited source and thus
did not want to step on anyone's toes.
Gregory P. Smith [Sun, 27 Jun 2004 23:32:34 +0000 (23:32 +0000)]
SF patch / bug #967763
Fix memory leaks revealed by valgrind and ensuing code inspection.
In the existing test suite valgrind revealed two memory leaks (DB_get
and DBC_set_range). Code inspection revealed that there were many other
potential similar leaks (many on odd code error paths such as passing
something other than a DBTxn object for a txn= parameter or in the face
of an out of memory error). The most common case that would cause a
leak was when using recno or queue format databases with integer keys,
sometimes only with an exception exit.
Brett Cannon [Sun, 27 Jun 2004 23:17:35 +0000 (23:17 +0000)]
Add code for a range function that uses generators.
Cleaned up existing code by abstracting code to parse arguments. Also removed
any unneeded operations (such as calling 'int' on a division when using floor
division also works). Fixed a bug where the values returned by
OldStyleRange could be short by one value. Added more documentation.
Gregory P. Smith [Sun, 27 Jun 2004 22:56:42 +0000 (22:56 +0000)]
Fix SF bug # 897820 - we can no longer use the DB_TRUNCATE flag when
opening the DB to implement legacy interface flag='n' support as
BerkeleyDB 4.2.52 no longer allows it in transaction protected
environments. Do the os.unlink ourselves.
* Silence a test failure that resulted when test_site was run by
regrtest.py after it ran test_frozen. This test was really only
designed to be run immediately after startup. Afterwards, other
modules could be loaded when had not been fixed-up by site.py
Took the chicken way out and only tested those modules known to
be imported by site.py.
Brett Cannon [Sat, 26 Jun 2004 23:10:32 +0000 (23:10 +0000)]
Clarify sentence at end of Intermezzo section stating that PyMODINIT_FUNC will
be discussed later by saying it is the function return type of the sample code
to make spotting it easier.
Brett Cannon [Sat, 26 Jun 2004 04:03:06 +0000 (04:03 +0000)]
Modules/getpath.c now compiles properly under OS X when using the
--disable-framework build; header file was protected in an #if using the wrong
macro to check.
Fred Drake [Thu, 24 Jun 2004 06:03:59 +0000 (06:03 +0000)]
move the note about the bsddb185 module above the "See also" box; that
should always go last in the relevant section's main content, but
before child sections
Tim Peters [Sun, 20 Jun 2004 22:41:32 +0000 (22:41 +0000)]
SF patch 876130: add C API to datetime module, from Anthony Tuininga.
The LaTeX is untested (well, so is the new API, for that matter).
Note that I also changed NULL to get spelled consistently in concrete.tex.
If that was a wrong thing to do, Fred should yell at me.
Tim Peters [Sun, 20 Jun 2004 02:50:16 +0000 (02:50 +0000)]
Bug 975996: Add _PyTime_DoubleToTimet to C API
New include file timefuncs.h exports private API function
_PyTime_DoubleToTimet() from timemodule.c. timemodule should export
some other functions too (look for painful bits in datetimemodule.c).
Added insane-argument checking to datetime's assorted fromtimestamp()
and utcfromtimestamp() methods. Added insane-argument tests of these
to test_datetime, and insane-argument tests for ctime(), localtime()
and gmtime() to test_time.
Brett Cannon [Sat, 19 Jun 2004 20:48:43 +0000 (20:48 +0000)]
Raise ValueError when value being stored in a time_t variable will result in
more than a second of precision. Primarily affects ctime, localtime, and
gmtime.
Closes bug #919012 thanks to Tim Peters' code.
Tim suggests that the new funciton being introduced, _PyTime_DoubletoTimet(),
should be added to the internal C API and then used in datetime where
appropriate. Not being done now for lack of time.
Thomas Heller [Fri, 18 Jun 2004 17:03:38 +0000 (17:03 +0000)]
When loading the Python dll to run the postinstall script, try to load
it from the install directory (as reported by the registry) in case it
is not found on the default Loadlibrary search path.
Fixes SF 935091: bdist_winist post-install script fails on non-admin Python