Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7767711

Browse files
committed
Merged revisions 58817-58861 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r58822 | brett.cannon | 2007-11-02 23:47:02 -0700 (Fri, 02 Nov 2007) | 2 lines Add a missing quotation mark. ........ r58840 | skip.montanaro | 2007-11-04 07:56:52 -0800 (Sun, 04 Nov 2007) | 2 lines Note change to get_dialect semantics in 2.5. Will backport to 2.5. ........ r58844 | georg.brandl | 2007-11-04 09:43:49 -0800 (Sun, 04 Nov 2007) | 2 lines Fix syntax for versionchanged markup. ........ r58850 | gregory.p.smith | 2007-11-04 18:32:26 -0800 (Sun, 04 Nov 2007) | 9 lines Fixes bug 477182 on pybsddb.sf.net. DB objects now load the flags and pay attention to them when opening an existing database. This means that d[] behaves properly even on databases previously created with DB_DUP or DB_DUPSORT flags to allow duplicate keys. http://sourceforge.net/tracker/index.php?func=detail&aid=477182&group_id=13900&atid=113900 Do not backport, this bugfix could be considered an API change. ........ r58851 | gregory.p.smith | 2007-11-04 18:56:31 -0800 (Sun, 04 Nov 2007) | 3 lines Add the bsddb.db.DBEnv.lock_id_free method. Improve test_lock's tempdir creation and cleanup. ........ r58852 | gregory.p.smith | 2007-11-05 01:06:28 -0800 (Mon, 05 Nov 2007) | 3 lines * db->get_types is only available in BerkeleyDB >= 4.2 * get compiling with older versions of python again for a stand alone release. ........ r58853 | gregory.p.smith | 2007-11-05 01:07:40 -0800 (Mon, 05 Nov 2007) | 2 lines * db->get_flags is only available in BerkeleyDB >= 4.2 ........ r58854 | mark.summerfield | 2007-11-05 01:22:48 -0800 (Mon, 05 Nov 2007) | 3 lines Added cross-references between the various archive file formats. ........ r58857 | mark.summerfield | 2007-11-05 06:38:50 -0800 (Mon, 05 Nov 2007) | 5 lines Clarified the fact that you can have comments for individual archive members even though comments to the archive itself aren't currently supported. ........
1 parent c4cb3b8 commit 7767711

9 files changed

Lines changed: 95 additions & 35 deletions

File tree

Doc/library/bz2.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ This module provides a comprehensive interface for the bz2 compression library.
1212
It implements a complete file interface, one-shot (de)compression functions, and
1313
types for sequential (de)compression.
1414

15-
Here is a resume of the features offered by the bz2 module:
15+
For other archive formats, see the :mod:`gzip`, :mod:`zipfile`, and
16+
:mod:`tarfile` modules.
17+
18+
Here is a summary of the features offered by the bz2 module:
1619

1720
* :class:`BZ2File` class implements a complete file interface, including
1821
:meth:`readline`, :meth:`readlines`, :meth:`writelines`, :meth:`seek`, etc;
@@ -30,9 +33,7 @@ Here is a resume of the features offered by the bz2 module:
3033
* One-shot (de)compression supported by :func:`compress` and :func:`decompress`
3134
functions;
3235

33-
* Thread safety uses individual locking mechanism;
34-
35-
* Complete inline documentation;
36+
* Thread safety uses individual locking mechanism.
3637

3738

3839
(De)compression of files

Doc/library/csv.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ The :mod:`csv` module defines the following functions:
124124
Return the dialect associated with *name*. An :exc:`Error` is raised if *name*
125125
is not a registered dialect name.
126126

127+
.. versionchanged:: 2.5
128+
This function now returns an immutable :class:`Dialect`. Previously an
129+
instance of the requested dialect was returned. Users could modify the
130+
underlying class, changing the behavior of active readers and writers.
127131

128132
.. function:: list_dialects()
129133

Doc/library/gzip.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ formats which can be decompressed by the :program:`gzip` and :program:`gunzip`
1515
programs, such as those produced by :program:`compress` and :program:`pack`,
1616
are not supported by this module.
1717

18+
For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and
19+
:mod:`tarfile` modules.
20+
1821
The module defines the following items:
1922

2023

Doc/library/tarfile.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
.. sectionauthor:: Lars Gustäbel <[email protected]>
1212

1313

14-
The :mod:`tarfile` module makes it possible to read and create tar archives.
14+
The :mod:`tarfile` module makes it possible to read and write tar
15+
archives, including those using gzip or bz2 compression.
16+
(`.zip` files can be read and written using the :mod:`zipfile` module.)
17+
1518
Some facts and figures:
1619

17-
* reads and writes :mod:`gzip` and :mod:`bzip2` compressed archives.
20+
* reads and writes :mod:`gzip` and :mod:`bz2` compressed archives.
1821

1922
* read/write support for the POSIX.1-1988 (ustar) format.
2023

Doc/library/zipfile.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ advanced use of this module will require an understanding of the format, as
1616
defined in `PKZIP Application Note
1717
<http://www.pkware.com/business_and_developers/developer/appnote/>`_.
1818

19-
This module does not currently handle ZIP files which have appended comments, or
20-
multi-disk ZIP files. It can handle ZIP files that use the ZIP64 extensions
21-
(that is ZIP files that are more than 4 GByte in size). It supports decryption
22-
of encrypted files in ZIP archives, but it cannot currently create an encrypted
23-
file.
24-
25-
The available attributes of this module are:
26-
19+
This module does not currently handle multi-disk ZIP files, or ZIP files
20+
which have appended comments (although it correctly handles comments
21+
added to individual archive members---for which see the :ref:`zipinfo-objects`
22+
documentation). It can handle ZIP files that use the ZIP64 extensions
23+
(that is ZIP files that are more than 4 GByte in size). It supports
24+
decryption of encrypted files in ZIP archives, but it currently cannot
25+
create an encrypted file.
26+
27+
For other archive formats, see the :mod:`bz2`, :mod:`gzip`, and
28+
:mod:`tarfile` modules.
29+
30+
The module defines the following items:
2731

2832
.. exception:: BadZipfile
2933

Doc/library/zlib.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ order. This documentation doesn't attempt to cover all of the permutations;
1919
consult the zlib manual at http://www.zlib.net/manual.html for authoritative
2020
information.
2121

22+
For reading and writing ``.gz`` files see the :mod:`gzip` module. For
23+
other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and
24+
:mod:`tarfile` modules.
25+
2226
The available exception and functions in this module are:
2327

2428

Lib/bsddb/test/test_lock.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
TestCases for testing the locking sub-system.
33
"""
44

5+
import os
6+
from pprint import pprint
57
import shutil
6-
import sys, os
8+
import sys
79
import tempfile
810
import time
9-
from pprint import pprint
1011

1112
try:
1213
from threading import Thread, currentThread
@@ -31,10 +32,10 @@
3132
class LockingTestCase(unittest.TestCase):
3233

3334
def setUp(self):
34-
self.homeDir = tempfile.mkdtemp()
35+
self.homeDir = tempfile.mkdtemp('.test_lock')
3536
self.env = db.DBEnv()
3637
self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL |
37-
db.DB_INIT_LOCK | db.DB_CREATE)
38+
db.DB_INIT_LOCK | db.DB_CREATE)
3839

3940

4041
def tearDown(self):
@@ -57,8 +58,8 @@ def test01_simple(self):
5758
self.env.lock_put(lock)
5859
if verbose:
5960
print("Released lock: %s" % lock)
60-
61-
61+
if db.version() >= (4,0):
62+
self.env.lock_id_free(anID)
6263

6364

6465
def test02_threaded(self):
@@ -119,6 +120,8 @@ def theThread(self, sleepTime, lockType):
119120
self.env.lock_put(lock)
120121
if verbose:
121122
print("%s: Released %s lock: %s" % (name, lt, lock))
123+
if db.version() >= (4,0):
124+
self.env.lock_id_free(anID)
122125

123126

124127
#----------------------------------------------------------------------

Lib/bsddb/test/test_misc.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,34 @@ def test05_key_with_null_bytes(self):
8585
db1.close()
8686
os.unlink(self.filename)
8787

88+
def test_DB_set_flags_persists(self):
89+
if db.version() < (4,2):
90+
# The get_flags API required for this to work is only available
91+
# in BerkeleyDB >= 4.2
92+
return
93+
try:
94+
db1 = db.DB()
95+
db1.set_flags(db.DB_DUPSORT)
96+
db1.open(self.filename, db.DB_HASH, db.DB_CREATE)
97+
db1[b'a'] = b'eh'
98+
db1[b'a'] = b'A'
99+
self.assertEqual([(b'a', b'A')], db1.items())
100+
db1.put(b'a', b'Aa')
101+
self.assertEqual([(b'a', b'A'), (b'a', b'Aa')], db1.items())
102+
db1.close()
103+
db1 = db.DB()
104+
# no set_flags call, we're testing that it reads and obeys
105+
# the flags on open.
106+
db1.open(self.filename, db.DB_HASH)
107+
self.assertEqual([(b'a', b'A'), (b'a', b'Aa')], db1.items())
108+
# if it read the flags right this will replace all values
109+
# for key b'a' instead of adding a new one. (as a dict should)
110+
db1[b'a'] = b'new A'
111+
self.assertEqual([(b'a', b'new A')], db1.items())
112+
finally:
113+
db1.close()
114+
os.unlink(self.filename)
115+
88116

89117
#----------------------------------------------------------------------
90118

Modules/_bsddb.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,21 +1940,6 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
19401940
return NULL;
19411941
}
19421942

1943-
#if 0 && (DBVER >= 41)
1944-
if ((!txn) && (txnobj != Py_None) && self->myenvobj
1945-
&& (self->myenvobj->flags & DB_INIT_TXN))
1946-
{
1947-
/* If no 'txn' parameter was supplied (no DbTxn object and None was not
1948-
* explicitly passed) but we are in a transaction ready environment:
1949-
* add DB_AUTO_COMMIT to allow for older pybsddb apps using transactions
1950-
* to work on BerkeleyDB 4.1 without needing to modify their
1951-
* DBEnv or DB open calls.
1952-
* TODO make this behaviour of the library configurable.
1953-
*/
1954-
flags |= DB_AUTO_COMMIT;
1955-
}
1956-
#endif
1957-
19581943
MYDB_BEGIN_ALLOW_THREADS;
19591944
#if (DBVER >= 41)
19601945
err = self->db->open(self->db, txn, filename, dbname, type, flags, mode);
@@ -1968,6 +1953,10 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
19681953
return NULL;
19691954
}
19701955

1956+
#if (DBVER >= 42)
1957+
self->db->get_flags(self->db, &self->setflags);
1958+
#endif
1959+
19711960
self->flags = flags;
19721961
RETURN_NONE();
19731962
}
@@ -4390,6 +4379,24 @@ DBEnv_lock_id(DBEnvObject* self, PyObject* args)
43904379
return PyInt_FromLong((long)theID);
43914380
}
43924381

4382+
#if (DBVER >= 40)
4383+
static PyObject*
4384+
DBEnv_lock_id_free(DBEnvObject* self, PyObject* args)
4385+
{
4386+
int err;
4387+
u_int32_t theID;
4388+
4389+
if (!PyArg_ParseTuple(args, "I:lock_id_free", &theID))
4390+
return NULL;
4391+
4392+
CHECK_ENV_NOT_CLOSED(self);
4393+
MYDB_BEGIN_ALLOW_THREADS;
4394+
err = self->db_env->lock_id_free(self->db_env, theID);
4395+
MYDB_END_ALLOW_THREADS;
4396+
RETURN_IF_ERR();
4397+
RETURN_NONE();
4398+
}
4399+
#endif
43934400

43944401
static PyObject*
43954402
DBEnv_lock_put(DBEnvObject* self, PyObject* args)
@@ -5266,6 +5273,9 @@ static PyMethodDef DBEnv_methods[] = {
52665273
{"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS},
52675274
{"lock_get", (PyCFunction)DBEnv_lock_get, METH_VARARGS},
52685275
{"lock_id", (PyCFunction)DBEnv_lock_id, METH_VARARGS},
5276+
#if (DBVER >= 40)
5277+
{"lock_id_free", (PyCFunction)DBEnv_lock_id_free, METH_VARARGS},
5278+
#endif
52695279
{"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS},
52705280
{"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS},
52715281
{"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS},

0 commit comments

Comments
 (0)