diff options
-rw-r--r-- | Doc/library/bz2.rst | 9 | ||||
-rw-r--r-- | Doc/library/csv.rst | 4 | ||||
-rw-r--r-- | Doc/library/gzip.rst | 3 | ||||
-rw-r--r-- | Doc/library/tarfile.rst | 7 | ||||
-rw-r--r-- | Doc/library/zipfile.rst | 20 | ||||
-rw-r--r-- | Doc/library/zlib.rst | 4 | ||||
-rw-r--r-- | Lib/bsddb/test/test_lock.py | 15 | ||||
-rw-r--r-- | Lib/bsddb/test/test_misc.py | 28 | ||||
-rw-r--r-- | Modules/_bsddb.c | 40 |
9 files changed, 95 insertions, 35 deletions
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index 73fd450..ff3c773 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -12,7 +12,10 @@ This module provides a comprehensive interface for the bz2 compression library. It implements a complete file interface, one-shot (de)compression functions, and types for sequential (de)compression. -Here is a resume of the features offered by the bz2 module: +For other archive formats, see the :mod:`gzip`, :mod:`zipfile`, and +:mod:`tarfile` modules. + +Here is a summary of the features offered by the bz2 module: * :class:`BZ2File` class implements a complete file interface, including :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: * One-shot (de)compression supported by :func:`compress` and :func:`decompress` functions; -* Thread safety uses individual locking mechanism; - -* Complete inline documentation; +* Thread safety uses individual locking mechanism. (De)compression of files diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 598dc50..5e1bd1e 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -124,6 +124,10 @@ The :mod:`csv` module defines the following functions: Return the dialect associated with *name*. An :exc:`Error` is raised if *name* is not a registered dialect name. + .. versionchanged:: 2.5 + This function now returns an immutable :class:`Dialect`. Previously an + instance of the requested dialect was returned. Users could modify the + underlying class, changing the behavior of active readers and writers. .. function:: list_dialects() diff --git a/Doc/library/gzip.rst b/Doc/library/gzip.rst index 5978031..d298f88 100644 --- a/Doc/library/gzip.rst +++ b/Doc/library/gzip.rst @@ -15,6 +15,9 @@ formats which can be decompressed by the :program:`gzip` and :program:`gunzip` programs, such as those produced by :program:`compress` and :program:`pack`, are not supported by this module. +For other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and +:mod:`tarfile` modules. + The module defines the following items: diff --git a/Doc/library/tarfile.rst b/Doc/library/tarfile.rst index 4aabd81..7893ccd 100644 --- a/Doc/library/tarfile.rst +++ b/Doc/library/tarfile.rst @@ -11,10 +11,13 @@ .. sectionauthor:: Lars Gustäbel <lars@gustaebel.de> -The :mod:`tarfile` module makes it possible to read and create tar archives. +The :mod:`tarfile` module makes it possible to read and write tar +archives, including those using gzip or bz2 compression. +(`.zip` files can be read and written using the :mod:`zipfile` module.) + Some facts and figures: -* reads and writes :mod:`gzip` and :mod:`bzip2` compressed archives. +* reads and writes :mod:`gzip` and :mod:`bz2` compressed archives. * read/write support for the POSIX.1-1988 (ustar) format. diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst index 92a4526..6c946f8 100644 --- a/Doc/library/zipfile.rst +++ b/Doc/library/zipfile.rst @@ -16,14 +16,18 @@ advanced use of this module will require an understanding of the format, as defined in `PKZIP Application Note <http://www.pkware.com/business_and_developers/developer/appnote/>`_. -This module does not currently handle ZIP files which have appended comments, or -multi-disk ZIP files. It can handle ZIP files that use the ZIP64 extensions -(that is ZIP files that are more than 4 GByte in size). It supports decryption -of encrypted files in ZIP archives, but it cannot currently create an encrypted -file. - -The available attributes of this module are: - +This module does not currently handle multi-disk ZIP files, or ZIP files +which have appended comments (although it correctly handles comments +added to individual archive members---for which see the :ref:`zipinfo-objects` +documentation). It can handle ZIP files that use the ZIP64 extensions +(that is ZIP files that are more than 4 GByte in size). It supports +decryption of encrypted files in ZIP archives, but it currently cannot +create an encrypted file. + +For other archive formats, see the :mod:`bz2`, :mod:`gzip`, and +:mod:`tarfile` modules. + +The module defines the following items: .. exception:: BadZipfile diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst index 3f051a7..449394c 100644 --- a/Doc/library/zlib.rst +++ b/Doc/library/zlib.rst @@ -19,6 +19,10 @@ order. This documentation doesn't attempt to cover all of the permutations; consult the zlib manual at http://www.zlib.net/manual.html for authoritative information. +For reading and writing ``.gz`` files see the :mod:`gzip` module. For +other archive formats, see the :mod:`bz2`, :mod:`zipfile`, and +:mod:`tarfile` modules. + The available exception and functions in this module are: diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py index fcab283..bbd88bd 100644 --- a/Lib/bsddb/test/test_lock.py +++ b/Lib/bsddb/test/test_lock.py @@ -2,11 +2,12 @@ TestCases for testing the locking sub-system. """ +import os +from pprint import pprint import shutil -import sys, os +import sys import tempfile import time -from pprint import pprint try: from threading import Thread, currentThread @@ -31,10 +32,10 @@ except ImportError: class LockingTestCase(unittest.TestCase): def setUp(self): - self.homeDir = tempfile.mkdtemp() + self.homeDir = tempfile.mkdtemp('.test_lock') self.env = db.DBEnv() self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL | - db.DB_INIT_LOCK | db.DB_CREATE) + db.DB_INIT_LOCK | db.DB_CREATE) def tearDown(self): @@ -57,8 +58,8 @@ class LockingTestCase(unittest.TestCase): self.env.lock_put(lock) if verbose: print("Released lock: %s" % lock) - - + if db.version() >= (4,0): + self.env.lock_id_free(anID) def test02_threaded(self): @@ -119,6 +120,8 @@ class LockingTestCase(unittest.TestCase): self.env.lock_put(lock) if verbose: print("%s: Released %s lock: %s" % (name, lt, lock)) + if db.version() >= (4,0): + self.env.lock_id_free(anID) #---------------------------------------------------------------------- diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py index b3248ce..b7a6710 100644 --- a/Lib/bsddb/test/test_misc.py +++ b/Lib/bsddb/test/test_misc.py @@ -85,6 +85,34 @@ class MiscTestCase(unittest.TestCase): db1.close() os.unlink(self.filename) + def test_DB_set_flags_persists(self): + if db.version() < (4,2): + # The get_flags API required for this to work is only available + # in BerkeleyDB >= 4.2 + return + try: + db1 = db.DB() + db1.set_flags(db.DB_DUPSORT) + db1.open(self.filename, db.DB_HASH, db.DB_CREATE) + db1[b'a'] = b'eh' + db1[b'a'] = b'A' + self.assertEqual([(b'a', b'A')], db1.items()) + db1.put(b'a', b'Aa') + self.assertEqual([(b'a', b'A'), (b'a', b'Aa')], db1.items()) + db1.close() + db1 = db.DB() + # no set_flags call, we're testing that it reads and obeys + # the flags on open. + db1.open(self.filename, db.DB_HASH) + self.assertEqual([(b'a', b'A'), (b'a', b'Aa')], db1.items()) + # if it read the flags right this will replace all values + # for key b'a' instead of adding a new one. (as a dict should) + db1[b'a'] = b'new A' + self.assertEqual([(b'a', b'new A')], db1.items()) + finally: + db1.close() + os.unlink(self.filename) + #---------------------------------------------------------------------- diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 8414618..bd1c271 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -1940,21 +1940,6 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs) return NULL; } -#if 0 && (DBVER >= 41) - if ((!txn) && (txnobj != Py_None) && self->myenvobj - && (self->myenvobj->flags & DB_INIT_TXN)) - { - /* If no 'txn' parameter was supplied (no DbTxn object and None was not - * explicitly passed) but we are in a transaction ready environment: - * add DB_AUTO_COMMIT to allow for older pybsddb apps using transactions - * to work on BerkeleyDB 4.1 without needing to modify their - * DBEnv or DB open calls. - * TODO make this behaviour of the library configurable. - */ - flags |= DB_AUTO_COMMIT; - } -#endif - MYDB_BEGIN_ALLOW_THREADS; #if (DBVER >= 41) err = self->db->open(self->db, txn, filename, dbname, type, flags, mode); @@ -1968,6 +1953,10 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs) return NULL; } +#if (DBVER >= 42) + self->db->get_flags(self->db, &self->setflags); +#endif + self->flags = flags; RETURN_NONE(); } @@ -4390,6 +4379,24 @@ DBEnv_lock_id(DBEnvObject* self, PyObject* args) return PyInt_FromLong((long)theID); } +#if (DBVER >= 40) +static PyObject* +DBEnv_lock_id_free(DBEnvObject* self, PyObject* args) +{ + int err; + u_int32_t theID; + + if (!PyArg_ParseTuple(args, "I:lock_id_free", &theID)) + return NULL; + + CHECK_ENV_NOT_CLOSED(self); + MYDB_BEGIN_ALLOW_THREADS; + err = self->db_env->lock_id_free(self->db_env, theID); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} +#endif static PyObject* DBEnv_lock_put(DBEnvObject* self, PyObject* args) @@ -5266,6 +5273,9 @@ static PyMethodDef DBEnv_methods[] = { {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS}, {"lock_get", (PyCFunction)DBEnv_lock_get, METH_VARARGS}, {"lock_id", (PyCFunction)DBEnv_lock_id, METH_VARARGS}, +#if (DBVER >= 40) + {"lock_id_free", (PyCFunction)DBEnv_lock_id_free, METH_VARARGS}, +#endif {"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS}, {"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS}, {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS}, |