Update gdb to 7.11.
am: c62e49a490

* commit 'c62e49a4903f6369914ab440343b913448a89c99':
  Update gdb to 7.11.

Change-Id: Ica8e62e5ed1d434bd108e69e7f531e24b44152ac
diff --git a/NOTICE b/NOTICE
index 8a40de8..b1dcc02 100644
--- a/NOTICE
+++ b/NOTICE
@@ -339,6 +339,383 @@
 library.  If this is what you want to do, use the GNU Library General
 Public License instead of this License.
 
+Copyright (C) Lucent Technologies 1997
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name Lucent Technologies or any of
+its entities not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+Copyright (C) 2016 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          59 Temple Place - Suite 330, Boston, MA
+                          02111-1307, USA.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
 A. HISTORY OF THE SOFTWARE
 ==========================
 
@@ -618,3 +995,1450 @@
 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+Copyright (C) 2016 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Yasm is Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
+
+Yasm developers and/or contributors include:
+  Peter Johnson
+  Michael Urman
+  Brian Gladman (Visual Studio build files, other fixes)
+  Stanislav Karchebny (options parser)
+  Mathieu Monnier (SSE4 instruction patches, NASM preprocessor additions)
+  Anonymous "NASM64" developer (NASM preprocessor fixes)
+  Stephen Polkowski (x86 instruction patches)
+  Henryk Richter (Mach-O object format)
+  Ben Skeggs (patches, bug reports)
+  Alexei Svitkine (GAS preprocessor)
+  Samuel Thibault (TASM parser and frontend)
+
+-----------------------------------
+Yasm licensing overview and summary
+-----------------------------------
+
+Note: This document does not provide legal advice nor is it the actual
+license of any part of Yasm.  See the individual licenses for complete
+details.  Consult a lawyer for legal advice.
+
+The primary license of Yasm is the 2-clause BSD license.  Please use this
+license if you plan on submitting code to the project.
+
+Yasm has absolutely no warranty; not even for merchantibility or fitness
+for a particular purpose.
+
+-------
+Libyasm
+-------
+Libyasm is 2-clause or 3-clause BSD licensed, with the exception of
+bitvect, which is triple-licensed under the Artistic license, GPL, and
+LGPL.  Libyasm is thus GPL and LGPL compatible.  In addition, this also
+means that libyasm is free for binary-only distribution as long as the
+terms of the 3-clause BSD license and Artistic license (as it applies to
+bitvect) are fulfilled.
+
+-------
+Modules
+-------
+The modules are 2-clause or 3-clause BSD licensed.
+
+---------
+Frontends
+---------
+The frontends are 2-clause BSD licensed.
+
+-------------
+License Texts
+-------------
+The full text of all licenses are provided in separate files in the source
+distribution.  Each source file may include the entire license (in the case
+of the BSD and Artistic licenses), or may reference the GPL or LGPL license
+file.
+
+BSD.txt - 2-clause and 3-clause BSD licenses
+Artistic.txt - Artistic license
+GNU_GPL-2.0 - GNU General Public License
+GNU_LGPL-2.0 - GNU Library General Public License
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-------------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of other contributors
+   may be used to endorse or promote products derived from this
+   software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-------------------------------------------------------------------------------
+NASM is now licensed under the 2-clause BSD license, also known as the
+simplified BSD license.
+
+    Copyright 1996-2009 the NASM Authors - All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following
+    conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+      
+      THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+      CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+      INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+      MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+      DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+      CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+      SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+      NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+      LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+      HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+      CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+      OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+      EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
+			 The "Artistic License"
+
+				Preamble
+
+The intent of this document is to state the conditions under which a
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over the development of the package,
+while giving the users of the package the right to use and distribute
+the Package in a more-or-less customary fashion, plus the right to make
+reasonable modifications.
+
+Definitions:
+
+	"Package" refers to the collection of files distributed by the
+	Copyright Holder, and derivatives of that collection of files
+	created through textual modification.
+
+	"Standard Version" refers to such a Package if it has not been
+	modified, or has been modified in accordance with the wishes
+	of the Copyright Holder as specified below.
+
+	"Copyright Holder" is whoever is named in the copyright or
+	copyrights for the package.
+
+	"You" is you, if you're thinking about copying or distributing
+	this Package.
+
+	"Reasonable copying fee" is whatever you can justify on the
+	basis of media cost, duplication charges, time of people involved,
+	and so on.  (You will not be required to justify it to the
+	Copyright Holder, but only to the computing community at large
+	as a market that must bear the fee.)
+
+	"Freely Available" means that no fee is charged for the item
+	itself, though there may be fees involved in handling the item.
+	It also means that recipients of the item may redistribute it
+	under the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the
+Standard Version of this Package without restriction, provided that you
+duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications
+derived from the Public Domain or from the Copyright Holder.  A Package
+modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided
+that you insert a prominent notice in each changed file stating how and
+when you changed that file, and provided that you do at least ONE of the
+following:
+
+    a) place your modifications in the Public Domain or otherwise make them
+    Freely Available, such as by posting said modifications to Usenet or
+    an equivalent medium, or placing the modifications on a major archive
+    site such as uunet.uu.net, or by allowing the Copyright Holder to include
+    your modifications in the Standard Version of the Package.
+
+    b) use the modified Package only within your corporation or organization.
+
+    c) rename any non-standard executables so the names do not conflict
+    with standard executables, which must also be provided, and provide
+    a separate manual page for each non-standard executable that clearly
+    documents how it differs from the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or
+executable form, provided that you do at least ONE of the following:
+
+    a) distribute a Standard Version of the executables and library files,
+    together with instructions (in the manual page or equivalent) on where
+    to get the Standard Version.
+
+    b) accompany the distribution with the machine-readable source of
+    the Package with your modifications.
+
+    c) give non-standard executables non-standard names, and clearly
+    document the differences in manual pages (or equivalent), together
+    with instructions on where to get the Standard Version.
+
+    d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+Package.  You may charge any fee you choose for support of this
+Package.  You may not charge a fee for this Package itself.  However,
+you may distribute this Package in aggregate with other (possibly
+commercial) programs as part of a larger (possibly commercial) software
+distribution provided that you do not advertise this Package as a
+product of your own.  You may embed this Package's interpreter within
+an executable of yours (by linking); this shall be construed as a mere
+form of aggregation, provided that the complete Standard Version of the
+interpreter is so embedded.
+
+6. The scripts and library files supplied as input to or produced as
+output from the programs of this Package do not automatically fall
+under the copyright of this Package, but belong to whoever generated
+them, and may be sold commercially, and may be aggregated with this
+Package.  If such scripts or library files are aggregated with this
+Package via the so-called "undump" or "unexec" methods of producing a
+binary executable image, then distribution of such an image shall
+neither be construed as a distribution of this Package nor shall it
+fall under the restrictions of Paragraphs 3 and 4, provided that you do
+not represent such an executable image as a Standard Version of this
+Package.
+
+7. C subroutines (or comparably compiled subroutines in other
+languages) supplied by you and linked into this Package in order to
+emulate subroutines and variables of the language defined by this
+Package shall not be considered part of this Package, but are the
+equivalent of input as in Paragraph 6, provided these subroutines do
+not change the language in any way that would cause it to fail the
+regression tests for the language.
+
+8. Aggregation of this Package with a commercial distribution is always
+permitted provided that the use of this Package is embedded; that is,
+when no overt attempt is made to make this Package's interfaces visible
+to the end user of the commercial distribution.  Such use shall not be
+construed as a distribution of this Package.
+
+9. The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written permission.
+
+10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+				The End
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+    		      51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year> <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/bin/gdb-orig b/bin/gdb-orig
index c4ffe96..c5d26c6 100755
--- a/bin/gdb-orig
+++ b/bin/gdb-orig
Binary files differ
diff --git a/bin/python b/bin/python
deleted file mode 120000
index 551ab26..0000000
--- a/bin/python
+++ /dev/null
@@ -1 +0,0 @@
-python2
\ No newline at end of file
diff --git a/bin/python b/bin/python
new file mode 100755
index 0000000..db5fc67
--- /dev/null
+++ b/bin/python
Binary files differ
diff --git a/bin/python-config b/bin/python-config
deleted file mode 120000
index 758027f..0000000
--- a/bin/python-config
+++ /dev/null
@@ -1 +0,0 @@
-python2-config
\ No newline at end of file
diff --git a/bin/python-config b/bin/python-config
new file mode 100755
index 0000000..a8c1455
--- /dev/null
+++ b/bin/python-config
@@ -0,0 +1,57 @@
+#!/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/bin/python2.7
+
+import sys
+import os
+import getopt
+from distutils import sysconfig
+
+valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
+              'ldflags', 'help']
+
+def exit_with_usage(code=1):
+    print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
+                                            '|'.join('--'+opt for opt in valid_opts))
+    sys.exit(code)
+
+try:
+    opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
+except getopt.error:
+    exit_with_usage()
+
+if not opts:
+    exit_with_usage()
+
+pyver = sysconfig.get_config_var('VERSION')
+getvar = sysconfig.get_config_var
+
+opt_flags = [flag for (flag, val) in opts]
+
+if '--help' in opt_flags:
+    exit_with_usage(code=0)
+
+for opt in opt_flags:
+    if opt == '--prefix':
+        print sysconfig.PREFIX
+
+    elif opt == '--exec-prefix':
+        print sysconfig.EXEC_PREFIX
+
+    elif opt in ('--includes', '--cflags'):
+        flags = ['-I' + sysconfig.get_python_inc(),
+                 '-I' + sysconfig.get_python_inc(plat_specific=True)]
+        if opt == '--cflags':
+            flags.extend(getvar('CFLAGS').split())
+        print ' '.join(flags)
+
+    elif opt in ('--libs', '--ldflags'):
+        libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
+        libs.append('-lpython'+pyver)
+        # add the prefix/lib/pythonX.Y/config dir, but only if there is no
+        # shared library in prefix/lib/.
+        if opt == '--ldflags':
+            if not getvar('Py_ENABLE_SHARED'):
+                libs.insert(0, '-L' + getvar('LIBPL'))
+            if not getvar('PYTHONFRAMEWORK'):
+                libs.extend(getvar('LINKFORSHARED').split())
+        print ' '.join(libs)
+
diff --git a/bin/python-config.sh b/bin/python-config.sh
index 0fc1293..313b99f 100755
--- a/bin/python-config.sh
+++ b/bin/python-config.sh
@@ -31,7 +31,7 @@
     echo $RESULT
 }
 
-prefix_build="/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64"
+prefix_build="/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools"
 prefix_real=$(installed_prefix "$0")
 
 exec_prefix_build="${prefix}"
diff --git a/bin/python2 b/bin/python2
deleted file mode 120000
index 8f7a3c1..0000000
--- a/bin/python2
+++ /dev/null
@@ -1 +0,0 @@
-python2.7
\ No newline at end of file
diff --git a/bin/python2 b/bin/python2
new file mode 100755
index 0000000..db5fc67
--- /dev/null
+++ b/bin/python2
Binary files differ
diff --git a/bin/python2-config b/bin/python2-config
deleted file mode 120000
index 785f36f..0000000
--- a/bin/python2-config
+++ /dev/null
@@ -1 +0,0 @@
-python2.7-config
\ No newline at end of file
diff --git a/bin/python2-config b/bin/python2-config
new file mode 100755
index 0000000..a8c1455
--- /dev/null
+++ b/bin/python2-config
@@ -0,0 +1,57 @@
+#!/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/bin/python2.7
+
+import sys
+import os
+import getopt
+from distutils import sysconfig
+
+valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
+              'ldflags', 'help']
+
+def exit_with_usage(code=1):
+    print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
+                                            '|'.join('--'+opt for opt in valid_opts))
+    sys.exit(code)
+
+try:
+    opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
+except getopt.error:
+    exit_with_usage()
+
+if not opts:
+    exit_with_usage()
+
+pyver = sysconfig.get_config_var('VERSION')
+getvar = sysconfig.get_config_var
+
+opt_flags = [flag for (flag, val) in opts]
+
+if '--help' in opt_flags:
+    exit_with_usage(code=0)
+
+for opt in opt_flags:
+    if opt == '--prefix':
+        print sysconfig.PREFIX
+
+    elif opt == '--exec-prefix':
+        print sysconfig.EXEC_PREFIX
+
+    elif opt in ('--includes', '--cflags'):
+        flags = ['-I' + sysconfig.get_python_inc(),
+                 '-I' + sysconfig.get_python_inc(plat_specific=True)]
+        if opt == '--cflags':
+            flags.extend(getvar('CFLAGS').split())
+        print ' '.join(flags)
+
+    elif opt in ('--libs', '--ldflags'):
+        libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
+        libs.append('-lpython'+pyver)
+        # add the prefix/lib/pythonX.Y/config dir, but only if there is no
+        # shared library in prefix/lib/.
+        if opt == '--ldflags':
+            if not getvar('Py_ENABLE_SHARED'):
+                libs.insert(0, '-L' + getvar('LIBPL'))
+            if not getvar('PYTHONFRAMEWORK'):
+                libs.extend(getvar('LINKFORSHARED').split())
+        print ' '.join(libs)
+
diff --git a/bin/python2.7 b/bin/python2.7
index f7d793e..db5fc67 100755
--- a/bin/python2.7
+++ b/bin/python2.7
Binary files differ
diff --git a/bin/python2.7-config b/bin/python2.7-config
index c9d5f77..a8c1455 100755
--- a/bin/python2.7-config
+++ b/bin/python2.7-config
@@ -1,4 +1,4 @@
-#!/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/bin/python2.7
+#!/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/bin/python2.7
 
 import sys
 import os
diff --git a/lib/libpython2.7.a b/lib/libpython2.7.a
index 320d6df..ac93ce5 100755
--- a/lib/libpython2.7.a
+++ b/lib/libpython2.7.a
Binary files differ
diff --git a/lib/pkgconfig/python-2.7.pc b/lib/pkgconfig/python-2.7.pc
index 45efc3c..6003c18 100644
--- a/lib/pkgconfig/python-2.7.pc
+++ b/lib/pkgconfig/python-2.7.pc
@@ -1,4 +1,4 @@
-prefix=/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64
+prefix=/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools
 exec_prefix=${prefix}
 libdir=${exec_prefix}/lib
 includedir=${prefix}/include
diff --git a/lib/pkgconfig/python.pc b/lib/pkgconfig/python.pc
deleted file mode 120000
index b7dff7f..0000000
--- a/lib/pkgconfig/python.pc
+++ /dev/null
@@ -1 +0,0 @@
-python2.pc
\ No newline at end of file
diff --git a/lib/pkgconfig/python.pc b/lib/pkgconfig/python.pc
new file mode 100644
index 0000000..6003c18
--- /dev/null
+++ b/lib/pkgconfig/python.pc
@@ -0,0 +1,13 @@
+prefix=/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Python
+Description: Python library
+Requires: 
+Version: 2.7
+Libs.private: -ldl  -framework CoreFoundation
+Libs: -L${libdir} -lpython2.7
+Cflags: -I${includedir}/python2.7 
+
diff --git a/lib/pkgconfig/python2.pc b/lib/pkgconfig/python2.pc
deleted file mode 120000
index b5ac60c..0000000
--- a/lib/pkgconfig/python2.pc
+++ /dev/null
@@ -1 +0,0 @@
-python-2.7.pc
\ No newline at end of file
diff --git a/lib/pkgconfig/python2.pc b/lib/pkgconfig/python2.pc
new file mode 100644
index 0000000..6003c18
--- /dev/null
+++ b/lib/pkgconfig/python2.pc
@@ -0,0 +1,13 @@
+prefix=/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Python
+Description: Python library
+Requires: 
+Version: 2.7
+Libs.private: -ldl  -framework CoreFoundation
+Libs: -L${libdir} -lpython2.7
+Cflags: -I${includedir}/python2.7 
+
diff --git a/lib/python2.7/_sysconfigdata.py b/lib/python2.7/_sysconfigdata.py
index 0e70024..c230598 100644
--- a/lib/python2.7/_sysconfigdata.py
+++ b/lib/python2.7/_sysconfigdata.py
@@ -3,9 +3,9 @@
  'AIX_GENUINE_CPLUSPLUS': 0,
  'AR': 'x86_64-apple-darwin-ar',
  'ARFLAGS': 'rc',
- 'ASDLGEN': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl_c.py',
- 'ASDLGEN_FILES': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl.py /Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl_c.py',
- 'AST_ASDL': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Parser/Python.asdl',
+ 'ASDLGEN': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl_c.py',
+ 'ASDLGEN_FILES': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl.py /Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Parser/asdl_c.py',
+ 'AST_ASDL': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Parser/Python.asdl',
  'AST_C': 'Python/Python-ast.c',
  'AST_C_DIR': 'Python',
  'AST_H': 'Include/Python-ast.h',
@@ -14,8 +14,8 @@
  'BASECFLAGS': '-fno-strict-aliasing',
  'BASEMODLIBS': '',
  'BEOS_THREADS': 0,
- 'BINDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/bin',
- 'BINLIBDEST': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7',
+ 'BINDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/bin',
+ 'BINLIBDEST': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7',
  'BLDLIBRARY': 'libpython2.7.a',
  'BLDSHARED': 'x86_64-apple-darwin-gcc -bundle -undefined dynamic_lookup',
  'BUILDEXE': '',
@@ -25,18 +25,18 @@
  'CFLAGS': '-fno-strict-aliasing -O2 -Os -fomit-frame-pointer -s -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes',
  'CFLAGSFORSHARED': '',
  'CONFIGFILES': 'configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in',
- 'CONFIG_ARGS': "'--prefix=/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64' '--build=x86_64-apple-darwin' '--host=x86_64-apple-darwin' '--with-build-sysroot' '--disable-ipv6' 'build_alias=x86_64-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=x86_64-apple-darwin-gcc' 'CFLAGS=-O2 -Os -fomit-frame-pointer -s' 'LDFLAGS='",
- 'CONFINCLUDEDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include',
- 'CONFINCLUDEPY': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include/python2.7',
+ 'CONFIG_ARGS': "'--prefix=/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools' '--build=x86_64-apple-darwin' '--host=x86_64-apple-darwin' '--with-build-sysroot' '--disable-ipv6' 'build_alias=x86_64-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=x86_64-apple-darwin-gcc' 'CFLAGS=-O2 -Os -fomit-frame-pointer -s' 'LDFLAGS='",
+ 'CONFINCLUDEDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include',
+ 'CONFINCLUDEPY': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include/python2.7',
  'COREPYTHONPATH': ':plat-darwin:plat-mac:plat-mac/lib-scriptpackages:lib-tk:lib-old',
- 'CPPFLAGS': '-I. -IInclude -I/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Include',
+ 'CPPFLAGS': '-I. -IInclude -I/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Include',
  'CXX': 'x86_64-apple-darwin-g++',
  'C_THREADS': 0,
  'DELIM': ':',
- 'DESTDIRS': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64 /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7 /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload',
- 'DESTLIB': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7',
+ 'DESTDIRS': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7 /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7/lib-dynload',
+ 'DESTLIB': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7',
  'DESTPATH': '',
- 'DESTSHARED': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/lib-dynload',
+ 'DESTSHARED': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7/lib-dynload',
  'DIRMODE': 755,
  'DIST': 'README ChangeLog configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in Include Lib Misc Demo Ext-dummy',
  'DISTDIRS': 'Include Lib Misc Demo Ext-dummy',
@@ -62,7 +62,7 @@
  'GNULD': 'no',
  'GRAMMAR_C': 'Python/graminit.c',
  'GRAMMAR_H': 'Include/graminit.h',
- 'GRAMMAR_INPUT': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Grammar/Grammar',
+ 'GRAMMAR_INPUT': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Grammar/Grammar',
  'HAVE_ACOSH': 1,
  'HAVE_ADDRINFO': 1,
  'HAVE_ALARM': 1,
@@ -351,9 +351,9 @@
  'HGVERSION': '',
  'HOST_GNU_TYPE': 'x86_64-apple-darwin',
  'HURD_C_THREADS': 0,
- 'INCLDIRSTOMAKE': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include/python2.7 /buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include/python2.7',
- 'INCLUDEDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include',
- 'INCLUDEPY': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/include/python2.7',
+ 'INCLDIRSTOMAKE': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include/python2.7 /Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include/python2.7',
+ 'INCLUDEDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include',
+ 'INCLUDEPY': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/include/python2.7',
  'INSTALL': '/usr/bin/install -c',
  'INSTALL_DATA': '/usr/bin/install -c -m 644',
  'INSTALL_PROGRAM': '/usr/bin/install -c',
@@ -367,15 +367,15 @@
  'LDLIBRARYDIR': '',
  'LDSHARED': 'x86_64-apple-darwin-gcc -bundle -undefined dynamic_lookup',
  'LIBC': '',
- 'LIBDEST': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7',
- 'LIBDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib',
+ 'LIBDEST': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7',
+ 'LIBDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib',
  'LIBFFI_INCLUDEDIR': '',
  'LIBM': '',
  'LIBOBJDIR': 'Python/',
  'LIBOBJS': '',
- 'LIBP': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7',
- 'LIBPC': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/pkgconfig',
- 'LIBPL': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/config',
+ 'LIBP': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7',
+ 'LIBPC': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/pkgconfig',
+ 'LIBPL': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7/config',
  'LIBRARY': 'libpython2.7.a',
  'LIBRARY_OBJS': '\\',
  'LIBS': '-ldl  -framework CoreFoundation',
@@ -388,20 +388,20 @@
  'MACHDEPPATH': ':plat-darwin',
  'MACHDEPS': 'plat-darwin plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \\',
  'MACHDEP_OBJS': 'Python/mactoolboxglue.o',
- 'MACHDESTLIB': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7',
+ 'MACHDESTLIB': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib/python2.7',
  'MACH_C_THREADS': 0,
  'MACOSX_DEPLOYMENT_TARGET': '10.8',
  'MAINCC': 'x86_64-apple-darwin-gcc',
  'MAJOR_IN_MKDEV': 0,
  'MAJOR_IN_SYSMACROS': 0,
- 'MAKESETUP': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Modules/makesetup',
- 'MANDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/share/man',
+ 'MAKESETUP': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Modules/makesetup',
+ 'MANDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/share/man',
  'MEMTESTOPTS': '-l -x test_subprocess test_io test_lib2to3 \\ -x test_dl test___all__ test_fork1 \\',
- 'MKDIR_P': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/install-sh -c -d',
+ 'MKDIR_P': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/install-sh -c -d',
  'MODLIBS': '',
  'MODOBJS': 'Modules/posixmodule.o  Modules/threadmodule.o  Modules/signalmodule.o  Modules/errnomodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/xxsubtype.o',
  'MODULE_OBJS': '\\',
- 'MSYSVPATH': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5',
+ 'MSYSVPATH': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5',
  'MULTIARCH': '',
  'MVWDELCH_IS_EXPRESSION': 1,
  'NT_THREADS': 0,
@@ -427,7 +427,7 @@
  'PLATMACPATH': ':plat-mac:plat-mac/lib-scriptpackages',
  'POBJS': '\\',
  'POSIX_SEMAPHORES_NOT_ENABLED': 0,
- 'PROFILE_TASK': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck',
+ 'PROFILE_TASK': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck',
  'PSRCS': '\\',
  'PTHREAD_SYSTEM_SCHED_SUPPORTED': 1,
  'PURIFY': '',
@@ -441,7 +441,7 @@
  'PYTHON_FOR_BUILD': './python -E',
  'PYTHON_HEADERS': '\\',
  'PYTHON_OBJS': '\\',
- 'PY_CFLAGS': '-fno-strict-aliasing -O2 -Os -fomit-frame-pointer -s -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Include  -DPy_BUILD_CORE',
+ 'PY_CFLAGS': '-fno-strict-aliasing -O2 -Os -fomit-frame-pointer -s -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Include  -DPy_BUILD_CORE',
  'PY_FORMAT_LONG_LONG': '"ll"',
  'PY_FORMAT_SIZE_T': '"z"',
  'PY_UNICODE_TYPE': 'unsigned short',
@@ -455,7 +455,7 @@
  'RESSRCDIR': 'Mac/Resources/framework',
  'RETSIGTYPE': 'void',
  'RUNSHARED': '',
- 'SCRIPTDIR': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/lib',
+ 'SCRIPTDIR': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/lib',
  'SETPGRP_HAVE_ARG': 0,
  'SGI_ABI': '',
  'SHELL': '/bin/sh',
@@ -483,19 +483,19 @@
  'SIZEOF__BOOL': 1,
  'SO': '.so',
  'SRCDIRS': 'Parser Grammar Objects Python Modules Mac',
- 'SRC_GDB_HOOKS': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Tools/gdb/libpython.py',
+ 'SRC_GDB_HOOKS': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Tools/gdb/libpython.py',
  'STDC_HEADERS': 1,
  'STRICT_SYSV_CURSES': "/* Don't use ncurses extensions */",
  'STRINGLIB_HEADERS': '\\',
  'SUBDIRS': '',
  'SUBDIRSTOO': 'Include Lib Misc Demo',
- 'SVNVERSION': 'svnversion /Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5',
+ 'SVNVERSION': 'svnversion /Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5',
  'SYSLIBS': '',
  'SYS_SELECT_WITH_SYS_TIME': 1,
  'TANH_PRESERVES_ZERO_SIGN': 1,
  'TESTOPTS': '-l',
  'TESTPATH': '',
- 'TESTPROG': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Lib/test/regrtest.py',
+ 'TESTPROG': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Lib/test/regrtest.py',
  'TESTPYTHON': './python -Wd -3 -E -tt',
  'TESTPYTHONOPTS': '',
  'THREADOBJ': 'Python/thread.o',
@@ -507,7 +507,7 @@
  'USE_TOOLBOX_OBJECT_GLUE': 1,
  'VA_LIST_IS_ARRAY': 1,
  'VERSION': '2.7',
- 'VPATH': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5',
+ 'VPATH': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5',
  'WANT_SIGFPE_HANDLER': 0,
  'WANT_WCTYPE_FUNCTIONS': 0,
  'WINDOW_HAS_FLAGS': 0,
@@ -522,11 +522,11 @@
  'WITH_VALGRIND': 0,
  'X87_DOUBLE_ROUNDING': 0,
  'XMLLIBSUBDIRS': 'xml xml/dom xml/etree xml/parsers xml/sax',
- 'abs_builddir': '/buildbot/tmp/buildhost/build-python-darwin-x86_64-2.7.5',
- 'abs_srcdir': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5',
+ 'abs_builddir': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/build-python-darwin-x86_64-2.7.5',
+ 'abs_srcdir': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5',
  'build': 'x86_64-apple-darwin',
- 'datarootdir': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64/share',
- 'exec_prefix': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64',
+ 'datarootdir': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools/share',
+ 'exec_prefix': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools',
  'host': 'x86_64-apple-darwin',
- 'prefix': '/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64',
- 'srcdir': '/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5'}
+ 'prefix': '/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools',
+ 'srcdir': '/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5'}
diff --git a/lib/python2.7/lib2to3/tests/data/fixers/myfixes/__init__.py b/lib/python2.7/bsddb/test/__init__.py
similarity index 100%
copy from lib/python2.7/lib2to3/tests/data/fixers/myfixes/__init__.py
copy to lib/python2.7/bsddb/test/__init__.py
diff --git a/lib/python2.7/bsddb/test/test_all.py b/lib/python2.7/bsddb/test/test_all.py
new file mode 100644
index 0000000..caef1ac
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_all.py
@@ -0,0 +1,623 @@
+"""Run all test cases.
+"""
+
+import sys
+import os
+import unittest
+try:
+    # For Pythons w/distutils pybsddb
+    import bsddb3 as bsddb
+except ImportError:
+    # For Python 2.3
+    import bsddb
+
+
+if sys.version_info[0] >= 3 :
+    charset = "iso8859-1"  # Full 8 bit
+
+    class logcursor_py3k(object) :
+        def __init__(self, env) :
+            self._logcursor = env.log_cursor()
+
+        def __getattr__(self, v) :
+            return getattr(self._logcursor, v)
+
+        def __next__(self) :
+            v = getattr(self._logcursor, "next")()
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+        next = __next__
+
+        def first(self) :
+            v = self._logcursor.first()
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+        def last(self) :
+            v = self._logcursor.last()
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+        def prev(self) :
+            v = self._logcursor.prev()
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+        def current(self) :
+            v = self._logcursor.current()
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+        def set(self, lsn) :
+            v = self._logcursor.set(lsn)
+            if v is not None :
+                v = (v[0], v[1].decode(charset))
+            return v
+
+    class cursor_py3k(object) :
+        def __init__(self, db, *args, **kwargs) :
+            self._dbcursor = db.cursor(*args, **kwargs)
+
+        def __getattr__(self, v) :
+            return getattr(self._dbcursor, v)
+
+        def _fix(self, v) :
+            if v is None : return None
+            key, value = v
+            if isinstance(key, bytes) :
+                key = key.decode(charset)
+            return (key, value.decode(charset))
+
+        def __next__(self) :
+            v = getattr(self._dbcursor, "next")()
+            return self._fix(v)
+
+        next = __next__
+
+        def previous(self) :
+            v = self._dbcursor.previous()
+            return self._fix(v)
+
+        def last(self) :
+            v = self._dbcursor.last()
+            return self._fix(v)
+
+        def set(self, k) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            v = self._dbcursor.set(k)
+            return self._fix(v)
+
+        def set_recno(self, num) :
+            v = self._dbcursor.set_recno(num)
+            return self._fix(v)
+
+        def set_range(self, k, dlen=-1, doff=-1) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            v = self._dbcursor.set_range(k, dlen=dlen, doff=doff)
+            return self._fix(v)
+
+        def dup(self, flags=0) :
+            cursor = self._dbcursor.dup(flags)
+            return dup_cursor_py3k(cursor)
+
+        def next_dup(self) :
+            v = self._dbcursor.next_dup()
+            return self._fix(v)
+
+        def next_nodup(self) :
+            v = self._dbcursor.next_nodup()
+            return self._fix(v)
+
+        def put(self, key, data, flags=0, dlen=-1, doff=-1) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if isinstance(data, str) :
+                value = bytes(data, charset)
+            return self._dbcursor.put(key, data, flags=flags, dlen=dlen,
+                    doff=doff)
+
+        def current(self, flags=0, dlen=-1, doff=-1) :
+            v = self._dbcursor.current(flags=flags, dlen=dlen, doff=doff)
+            return self._fix(v)
+
+        def first(self) :
+            v = self._dbcursor.first()
+            return self._fix(v)
+
+        def pget(self, key=None, data=None, flags=0) :
+            # Incorrect because key can be a bare number,
+            # but enough to pass testsuite
+            if isinstance(key, int) and (data is None) and (flags == 0) :
+                flags = key
+                key = None
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if isinstance(data, int) and (flags==0) :
+                flags = data
+                data = None
+            if isinstance(data, str) :
+                data = bytes(data, charset)
+            v=self._dbcursor.pget(key=key, data=data, flags=flags)
+            if v is not None :
+                v1, v2, v3 = v
+                if isinstance(v1, bytes) :
+                    v1 = v1.decode(charset)
+                if isinstance(v2, bytes) :
+                    v2 = v2.decode(charset)
+
+                v = (v1, v2, v3.decode(charset))
+
+            return v
+
+        def join_item(self) :
+            v = self._dbcursor.join_item()
+            if v is not None :
+                v = v.decode(charset)
+            return v
+
+        def get(self, *args, **kwargs) :
+            l = len(args)
+            if l == 2 :
+                k, f = args
+                if isinstance(k, str) :
+                    k = bytes(k, "iso8859-1")
+                args = (k, f)
+            elif l == 3 :
+                k, d, f = args
+                if isinstance(k, str) :
+                    k = bytes(k, charset)
+                if isinstance(d, str) :
+                    d = bytes(d, charset)
+                args =(k, d, f)
+
+            v = self._dbcursor.get(*args, **kwargs)
+            if v is not None :
+                k, v = v
+                if isinstance(k, bytes) :
+                    k = k.decode(charset)
+                v = (k, v.decode(charset))
+            return v
+
+        def get_both(self, key, value) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if isinstance(value, str) :
+                value = bytes(value, charset)
+            v=self._dbcursor.get_both(key, value)
+            return self._fix(v)
+
+    class dup_cursor_py3k(cursor_py3k) :
+        def __init__(self, dbcursor) :
+            self._dbcursor = dbcursor
+
+    class DB_py3k(object) :
+        def __init__(self, *args, **kwargs) :
+            args2=[]
+            for i in args :
+                if isinstance(i, DBEnv_py3k) :
+                    i = i._dbenv
+                args2.append(i)
+            args = tuple(args2)
+            for k, v in kwargs.items() :
+                if isinstance(v, DBEnv_py3k) :
+                    kwargs[k] = v._dbenv
+
+            self._db = bsddb._db.DB_orig(*args, **kwargs)
+
+        def __contains__(self, k) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            return getattr(self._db, "has_key")(k)
+
+        def __getitem__(self, k) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            v = self._db[k]
+            if v is not None :
+                v = v.decode(charset)
+            return v
+
+        def __setitem__(self, k, v) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            if isinstance(v, str) :
+                v = bytes(v, charset)
+            self._db[k] = v
+
+        def __delitem__(self, k) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            del self._db[k]
+
+        def __getattr__(self, v) :
+            return getattr(self._db, v)
+
+        def __len__(self) :
+            return len(self._db)
+
+        def has_key(self, k, txn=None) :
+            if isinstance(k, str) :
+                k = bytes(k, charset)
+            return self._db.has_key(k, txn=txn)
+
+        def set_re_delim(self, c) :
+            if isinstance(c, str) :  # We can use a numeric value byte too
+                c = bytes(c, charset)
+            return self._db.set_re_delim(c)
+
+        def set_re_pad(self, c) :
+            if isinstance(c, str) :  # We can use a numeric value byte too
+                c = bytes(c, charset)
+            return self._db.set_re_pad(c)
+
+        def get_re_source(self) :
+            source = self._db.get_re_source()
+            return source.decode(charset)
+
+        def put(self, key, data, txn=None, flags=0, dlen=-1, doff=-1) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if isinstance(data, str) :
+                value = bytes(data, charset)
+            return self._db.put(key, data, flags=flags, txn=txn, dlen=dlen,
+                    doff=doff)
+
+        def append(self, value, txn=None) :
+            if isinstance(value, str) :
+                value = bytes(value, charset)
+            return self._db.append(value, txn=txn)
+
+        def get_size(self, key) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            return self._db.get_size(key)
+
+        def exists(self, key, *args, **kwargs) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            return self._db.exists(key, *args, **kwargs)
+
+        def get(self, key, default="MagicCookie", txn=None, flags=0, dlen=-1, doff=-1) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if default != "MagicCookie" :  # Magic for 'test_get_none.py'
+                v=self._db.get(key, default=default, txn=txn, flags=flags,
+                        dlen=dlen, doff=doff)
+            else :
+                v=self._db.get(key, txn=txn, flags=flags,
+                        dlen=dlen, doff=doff)
+            if (v is not None) and isinstance(v, bytes) :
+                v = v.decode(charset)
+            return v
+
+        def pget(self, key, txn=None) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            v=self._db.pget(key, txn=txn)
+            if v is not None :
+                v1, v2 = v
+                if isinstance(v1, bytes) :
+                    v1 = v1.decode(charset)
+
+                v = (v1, v2.decode(charset))
+            return v
+
+        def get_both(self, key, value, txn=None, flags=0) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            if isinstance(value, str) :
+                value = bytes(value, charset)
+            v=self._db.get_both(key, value, txn=txn, flags=flags)
+            if v is not None :
+                v = v.decode(charset)
+            return v
+
+        def delete(self, key, txn=None) :
+            if isinstance(key, str) :
+                key = bytes(key, charset)
+            return self._db.delete(key, txn=txn)
+
+        def keys(self) :
+            k = self._db.keys()
+            if len(k) and isinstance(k[0], bytes) :
+                return [i.decode(charset) for i in self._db.keys()]
+            else :
+                return k
+
+        def items(self) :
+            data = self._db.items()
+            if not len(data) : return data
+            data2 = []
+            for k, v in data :
+                if isinstance(k, bytes) :
+                    k = k.decode(charset)
+                data2.append((k, v.decode(charset)))
+            return data2
+
+        def associate(self, secondarydb, callback, flags=0, txn=None) :
+            class associate_callback(object) :
+                def __init__(self, callback) :
+                    self._callback = callback
+
+                def callback(self, key, data) :
+                    if isinstance(key, str) :
+                        key = key.decode(charset)
+                    data = data.decode(charset)
+                    key = self._callback(key, data)
+                    if (key != bsddb._db.DB_DONOTINDEX) :
+                        if isinstance(key, str) :
+                            key = bytes(key, charset)
+                        elif isinstance(key, list) :
+                            key2 = []
+                            for i in key :
+                                if isinstance(i, str) :
+                                    i = bytes(i, charset)
+                                key2.append(i)
+                            key = key2
+                    return key
+
+            return self._db.associate(secondarydb._db,
+                    associate_callback(callback).callback, flags=flags,
+                    txn=txn)
+
+        def cursor(self, txn=None, flags=0) :
+            return cursor_py3k(self._db, txn=txn, flags=flags)
+
+        def join(self, cursor_list) :
+            cursor_list = [i._dbcursor for i in cursor_list]
+            return dup_cursor_py3k(self._db.join(cursor_list))
+
+    class DBEnv_py3k(object) :
+        def __init__(self, *args, **kwargs) :
+            self._dbenv = bsddb._db.DBEnv_orig(*args, **kwargs)
+
+        def __getattr__(self, v) :
+            return getattr(self._dbenv, v)
+
+        def log_cursor(self, flags=0) :
+            return logcursor_py3k(self._dbenv)
+
+        def get_lg_dir(self) :
+            return self._dbenv.get_lg_dir().decode(charset)
+
+        def get_tmp_dir(self) :
+            return self._dbenv.get_tmp_dir().decode(charset)
+
+        def get_data_dirs(self) :
+            return tuple(
+                (i.decode(charset) for i in self._dbenv.get_data_dirs()))
+
+    class DBSequence_py3k(object) :
+        def __init__(self, db, *args, **kwargs) :
+            self._db=db
+            self._dbsequence = bsddb._db.DBSequence_orig(db._db, *args, **kwargs)
+
+        def __getattr__(self, v) :
+            return getattr(self._dbsequence, v)
+
+        def open(self, key, *args, **kwargs) :
+            return self._dbsequence.open(bytes(key, charset), *args, **kwargs)
+
+        def get_key(self) :
+            return  self._dbsequence.get_key().decode(charset)
+
+        def get_dbp(self) :
+            return self._db
+
+    import string
+    string.letters=[chr(i) for i in xrange(65,91)]
+
+    bsddb._db.DBEnv_orig = bsddb._db.DBEnv
+    bsddb._db.DB_orig = bsddb._db.DB
+    if bsddb.db.version() <= (4, 3) :
+        bsddb._db.DBSequence_orig = None
+    else :
+        bsddb._db.DBSequence_orig = bsddb._db.DBSequence
+
+    def do_proxy_db_py3k(flag) :
+        flag2 = do_proxy_db_py3k.flag
+        do_proxy_db_py3k.flag = flag
+        if flag :
+            bsddb.DBEnv = bsddb.db.DBEnv = bsddb._db.DBEnv = DBEnv_py3k
+            bsddb.DB = bsddb.db.DB = bsddb._db.DB = DB_py3k
+            bsddb._db.DBSequence = DBSequence_py3k
+        else :
+            bsddb.DBEnv = bsddb.db.DBEnv = bsddb._db.DBEnv = bsddb._db.DBEnv_orig
+            bsddb.DB = bsddb.db.DB = bsddb._db.DB = bsddb._db.DB_orig
+            bsddb._db.DBSequence = bsddb._db.DBSequence_orig
+        return flag2
+
+    do_proxy_db_py3k.flag = False
+    do_proxy_db_py3k(True)
+
+try:
+    # For Pythons w/distutils pybsddb
+    from bsddb3 import db, dbtables, dbutils, dbshelve, \
+            hashopen, btopen, rnopen, dbobj
+except ImportError:
+    # For Python 2.3
+    from bsddb import db, dbtables, dbutils, dbshelve, \
+            hashopen, btopen, rnopen, dbobj
+
+try:
+    from bsddb3 import test_support
+except ImportError:
+    if sys.version_info[0] < 3 :
+        from test import test_support
+    else :
+        from test import support as test_support
+
+
+try:
+    if sys.version_info[0] < 3 :
+        from threading import Thread, currentThread
+        del Thread, currentThread
+    else :
+        from threading import Thread, current_thread
+        del Thread, current_thread
+    have_threads = True
+except ImportError:
+    have_threads = False
+
+verbose = 0
+if 'verbose' in sys.argv:
+    verbose = 1
+    sys.argv.remove('verbose')
+
+if 'silent' in sys.argv:  # take care of old flag, just in case
+    verbose = 0
+    sys.argv.remove('silent')
+
+
+def print_versions():
+    print
+    print '-=' * 38
+    print db.DB_VERSION_STRING
+    print 'bsddb.db.version():   %s' % (db.version(), )
+    if db.version() >= (5, 0) :
+        print 'bsddb.db.full_version(): %s' %repr(db.full_version())
+    print 'bsddb.db.__version__: %s' % db.__version__
+    print 'bsddb.db.cvsid:       %s' % db.cvsid
+
+    # Workaround for allowing generating an EGGs as a ZIP files.
+    suffix="__"
+    print 'py module:            %s' % getattr(bsddb, "__file"+suffix)
+    print 'extension module:     %s' % getattr(bsddb, "__file"+suffix)
+
+    print 'python version:       %s' % sys.version
+    print 'My pid:               %s' % os.getpid()
+    print '-=' * 38
+
+
+def get_new_path(name) :
+    get_new_path.mutex.acquire()
+    try :
+        import os
+        path=os.path.join(get_new_path.prefix,
+                name+"_"+str(os.getpid())+"_"+str(get_new_path.num))
+        get_new_path.num+=1
+    finally :
+        get_new_path.mutex.release()
+    return path
+
+def get_new_environment_path() :
+    path=get_new_path("environment")
+    import os
+    try:
+        os.makedirs(path,mode=0700)
+    except os.error:
+        test_support.rmtree(path)
+        os.makedirs(path)
+    return path
+
+def get_new_database_path() :
+    path=get_new_path("database")
+    import os
+    if os.path.exists(path) :
+        os.remove(path)
+    return path
+
+
+# This path can be overriden via "set_test_path_prefix()".
+import os, os.path
+get_new_path.prefix=os.path.join(os.environ.get("TMPDIR",
+    os.path.join(os.sep,"tmp")), "z-Berkeley_DB")
+get_new_path.num=0
+
+def get_test_path_prefix() :
+    return get_new_path.prefix
+
+def set_test_path_prefix(path) :
+    get_new_path.prefix=path
+
+def remove_test_path_directory() :
+    test_support.rmtree(get_new_path.prefix)
+
+if have_threads :
+    import threading
+    get_new_path.mutex=threading.Lock()
+    del threading
+else :
+    class Lock(object) :
+        def acquire(self) :
+            pass
+        def release(self) :
+            pass
+    get_new_path.mutex=Lock()
+    del Lock
+
+
+
+class PrintInfoFakeTest(unittest.TestCase):
+    def testPrintVersions(self):
+        print_versions()
+
+
+# This little hack is for when this module is run as main and all the
+# other modules import it so they will still be able to get the right
+# verbose setting.  It's confusing but it works.
+if sys.version_info[0] < 3 :
+    import test_all
+    test_all.verbose = verbose
+else :
+    import sys
+    print >>sys.stderr, "Work to do!"
+
+
+def suite(module_prefix='', timing_check=None):
+    test_modules = [
+        'test_associate',
+        'test_basics',
+        'test_dbenv',
+        'test_db',
+        'test_compare',
+        'test_compat',
+        'test_cursor_pget_bug',
+        'test_dbobj',
+        'test_dbshelve',
+        'test_dbtables',
+        'test_distributed_transactions',
+        'test_early_close',
+        'test_fileid',
+        'test_get_none',
+        'test_join',
+        'test_lock',
+        'test_misc',
+        'test_pickle',
+        'test_queue',
+        'test_recno',
+        'test_replication',
+        'test_sequence',
+        'test_thread',
+        ]
+
+    alltests = unittest.TestSuite()
+    for name in test_modules:
+        #module = __import__(name)
+        # Do it this way so that suite may be called externally via
+        # python's Lib/test/test_bsddb3.
+        module = __import__(module_prefix+name, globals(), locals(), name)
+
+        alltests.addTest(module.test_suite())
+        if timing_check:
+            alltests.addTest(unittest.makeSuite(timing_check))
+    return alltests
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(PrintInfoFakeTest))
+    return suite
+
+
+if __name__ == '__main__':
+    print_versions()
+    unittest.main(defaultTest='suite')
diff --git a/lib/python2.7/bsddb/test/test_associate.py b/lib/python2.7/bsddb/test/test_associate.py
new file mode 100644
index 0000000..7a49e11
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_associate.py
@@ -0,0 +1,465 @@
+"""
+TestCases for DB.associate.
+"""
+
+import sys, os, string
+import time
+from pprint import pprint
+
+import unittest
+from test_all import db, dbshelve, test_support, verbose, have_threads, \
+        get_new_environment_path
+
+
+#----------------------------------------------------------------------
+
+
+musicdata = {
+1 : ("Bad English", "The Price Of Love", "Rock"),
+2 : ("DNA featuring Suzanne Vega", "Tom's Diner", "Rock"),
+3 : ("George Michael", "Praying For Time", "Rock"),
+4 : ("Gloria Estefan", "Here We Are", "Rock"),
+5 : ("Linda Ronstadt", "Don't Know Much", "Rock"),
+6 : ("Michael Bolton", "How Am I Supposed To Live Without You", "Blues"),
+7 : ("Paul Young", "Oh Girl", "Rock"),
+8 : ("Paula Abdul", "Opposites Attract", "Rock"),
+9 : ("Richard Marx", "Should've Known Better", "Rock"),
+10: ("Rod Stewart", "Forever Young", "Rock"),
+11: ("Roxette", "Dangerous", "Rock"),
+12: ("Sheena Easton", "The Lover In Me", "Rock"),
+13: ("Sinead O'Connor", "Nothing Compares 2 U", "Rock"),
+14: ("Stevie B.", "Because I Love You", "Rock"),
+15: ("Taylor Dayne", "Love Will Lead You Back", "Rock"),
+16: ("The Bangles", "Eternal Flame", "Rock"),
+17: ("Wilson Phillips", "Release Me", "Rock"),
+18: ("Billy Joel", "Blonde Over Blue", "Rock"),
+19: ("Billy Joel", "Famous Last Words", "Rock"),
+20: ("Billy Joel", "Lullabye (Goodnight, My Angel)", "Rock"),
+21: ("Billy Joel", "The River Of Dreams", "Rock"),
+22: ("Billy Joel", "Two Thousand Years", "Rock"),
+23: ("Janet Jackson", "Alright", "Rock"),
+24: ("Janet Jackson", "Black Cat", "Rock"),
+25: ("Janet Jackson", "Come Back To Me", "Rock"),
+26: ("Janet Jackson", "Escapade", "Rock"),
+27: ("Janet Jackson", "Love Will Never Do (Without You)", "Rock"),
+28: ("Janet Jackson", "Miss You Much", "Rock"),
+29: ("Janet Jackson", "Rhythm Nation", "Rock"),
+30: ("Janet Jackson", "State Of The World", "Rock"),
+31: ("Janet Jackson", "The Knowledge", "Rock"),
+32: ("Spyro Gyra", "End of Romanticism", "Jazz"),
+33: ("Spyro Gyra", "Heliopolis", "Jazz"),
+34: ("Spyro Gyra", "Jubilee", "Jazz"),
+35: ("Spyro Gyra", "Little Linda", "Jazz"),
+36: ("Spyro Gyra", "Morning Dance", "Jazz"),
+37: ("Spyro Gyra", "Song for Lorraine", "Jazz"),
+38: ("Yes", "Owner Of A Lonely Heart", "Rock"),
+39: ("Yes", "Rhythm Of Love", "Rock"),
+40: ("Cusco", "Dream Catcher", "New Age"),
+41: ("Cusco", "Geronimos Laughter", "New Age"),
+42: ("Cusco", "Ghost Dance", "New Age"),
+43: ("Blue Man Group", "Drumbone", "New Age"),
+44: ("Blue Man Group", "Endless Column", "New Age"),
+45: ("Blue Man Group", "Klein Mandelbrot", "New Age"),
+46: ("Kenny G", "Silhouette", "Jazz"),
+47: ("Sade", "Smooth Operator", "Jazz"),
+48: ("David Arkenstone", "Papillon (On The Wings Of The Butterfly)",
+     "New Age"),
+49: ("David Arkenstone", "Stepping Stars", "New Age"),
+50: ("David Arkenstone", "Carnation Lily Lily Rose", "New Age"),
+51: ("David Lanz", "Behind The Waterfall", "New Age"),
+52: ("David Lanz", "Cristofori's Dream", "New Age"),
+53: ("David Lanz", "Heartsounds", "New Age"),
+54: ("David Lanz", "Leaves on the Seine", "New Age"),
+99: ("unknown artist", "Unnamed song", "Unknown"),
+}
+
+#----------------------------------------------------------------------
+
+class AssociateErrorTestCase(unittest.TestCase):
+    def setUp(self):
+        self.filename = self.__class__.__name__ + '.db'
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+
+    def tearDown(self):
+        self.env.close()
+        self.env = None
+        test_support.rmtree(self.homeDir)
+
+    def test00_associateDBError(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test00_associateDBError..." % \
+                  self.__class__.__name__
+
+        dupDB = db.DB(self.env)
+        dupDB.set_flags(db.DB_DUP)
+        dupDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE)
+
+        secDB = db.DB(self.env)
+        secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
+
+        # dupDB has been configured to allow duplicates, it can't
+        # associate with a secondary.  Berkeley DB will return an error.
+        try:
+            def f(a,b): return a+b
+            dupDB.associate(secDB, f)
+        except db.DBError:
+            # good
+            secDB.close()
+            dupDB.close()
+        else:
+            secDB.close()
+            dupDB.close()
+            self.fail("DBError exception was expected")
+
+
+
+#----------------------------------------------------------------------
+
+
+class AssociateTestCase(unittest.TestCase):
+    keytype = ''
+    envFlags = 0
+    dbFlags = 0
+
+    def setUp(self):
+        self.filename = self.__class__.__name__ + '.db'
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+                               db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
+
+    def tearDown(self):
+        self.closeDB()
+        self.env.close()
+        self.env = None
+        test_support.rmtree(self.homeDir)
+
+    def addDataToDB(self, d, txn=None):
+        for key, value in musicdata.items():
+            if type(self.keytype) == type(''):
+                key = "%02d" % key
+            d.put(key, '|'.join(value), txn=txn)
+
+    def createDB(self, txn=None):
+        self.cur = None
+        self.secDB = None
+        self.primary = db.DB(self.env)
+        self.primary.set_get_returns_none(2)
+        self.primary.open(self.filename, "primary", self.dbtype,
+                      db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn)
+
+    def closeDB(self):
+        if self.cur:
+            self.cur.close()
+            self.cur = None
+        if self.secDB:
+            self.secDB.close()
+            self.secDB = None
+        self.primary.close()
+        self.primary = None
+
+    def getDB(self):
+        return self.primary
+
+
+    def _associateWithDB(self, getGenre):
+        self.createDB()
+
+        self.secDB = db.DB(self.env)
+        self.secDB.set_flags(db.DB_DUP)
+        self.secDB.set_get_returns_none(2)
+        self.secDB.open(self.filename, "secondary", db.DB_BTREE,
+                   db.DB_CREATE | db.DB_THREAD | self.dbFlags)
+        self.getDB().associate(self.secDB, getGenre)
+
+        self.addDataToDB(self.getDB())
+
+        self.finish_test(self.secDB)
+
+    def test01_associateWithDB(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_associateWithDB..." % \
+                  self.__class__.__name__
+
+        return self._associateWithDB(self.getGenre)
+
+    def _associateAfterDB(self, getGenre) :
+        self.createDB()
+        self.addDataToDB(self.getDB())
+
+        self.secDB = db.DB(self.env)
+        self.secDB.set_flags(db.DB_DUP)
+        self.secDB.open(self.filename, "secondary", db.DB_BTREE,
+                   db.DB_CREATE | db.DB_THREAD | self.dbFlags)
+
+        # adding the DB_CREATE flag will cause it to index existing records
+        self.getDB().associate(self.secDB, getGenre, db.DB_CREATE)
+
+        self.finish_test(self.secDB)
+
+    def test02_associateAfterDB(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_associateAfterDB..." % \
+                  self.__class__.__name__
+
+        return self._associateAfterDB(self.getGenre)
+
+    if db.version() >= (4, 6):
+        def test03_associateWithDB(self):
+            if verbose:
+                print '\n', '-=' * 30
+                print "Running %s.test03_associateWithDB..." % \
+                      self.__class__.__name__
+
+            return self._associateWithDB(self.getGenreList)
+
+        def test04_associateAfterDB(self):
+            if verbose:
+                print '\n', '-=' * 30
+                print "Running %s.test04_associateAfterDB..." % \
+                      self.__class__.__name__
+
+            return self._associateAfterDB(self.getGenreList)
+
+
+    def finish_test(self, secDB, txn=None):
+        # 'Blues' should not be in the secondary database
+        vals = secDB.pget('Blues', txn=txn)
+        self.assertEqual(vals, None, vals)
+
+        vals = secDB.pget('Unknown', txn=txn)
+        self.assertTrue(vals[0] == 99 or vals[0] == '99', vals)
+        vals[1].index('Unknown')
+        vals[1].index('Unnamed')
+        vals[1].index('unknown')
+
+        if verbose:
+            print "Primary key traversal:"
+        self.cur = self.getDB().cursor(txn)
+        count = 0
+        rec = self.cur.first()
+        while rec is not None:
+            if type(self.keytype) == type(''):
+                self.assertTrue(int(rec[0]))  # for primary db, key is a number
+            else:
+                self.assertTrue(rec[0] and type(rec[0]) == type(0))
+            count = count + 1
+            if verbose:
+                print rec
+            rec = getattr(self.cur, "next")()
+        self.assertEqual(count, len(musicdata))  # all items accounted for
+
+
+        if verbose:
+            print "Secondary key traversal:"
+        self.cur = secDB.cursor(txn)
+        count = 0
+
+        # test cursor pget
+        vals = self.cur.pget('Unknown', flags=db.DB_LAST)
+        self.assertTrue(vals[1] == 99 or vals[1] == '99', vals)
+        self.assertEqual(vals[0], 'Unknown')
+        vals[2].index('Unknown')
+        vals[2].index('Unnamed')
+        vals[2].index('unknown')
+
+        vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
+        self.assertEqual(vals, None, vals)
+
+        rec = self.cur.first()
+        self.assertEqual(rec[0], "Jazz")
+        while rec is not None:
+            count = count + 1
+            if verbose:
+                print rec
+            rec = getattr(self.cur, "next")()
+        # all items accounted for EXCEPT for 1 with "Blues" genre
+        self.assertEqual(count, len(musicdata)-1)
+
+        self.cur = None
+
+    def getGenre(self, priKey, priData):
+        self.assertEqual(type(priData), type(""))
+        genre = priData.split('|')[2]
+
+        if verbose:
+            print 'getGenre key: %r data: %r' % (priKey, priData)
+
+        if genre == 'Blues':
+            return db.DB_DONOTINDEX
+        else:
+            return genre
+
+    def getGenreList(self, priKey, PriData) :
+        v = self.getGenre(priKey, PriData)
+        if type(v) == type("") :
+            v = [v]
+        return v
+
+
+#----------------------------------------------------------------------
+
+
+class AssociateHashTestCase(AssociateTestCase):
+    dbtype = db.DB_HASH
+
+class AssociateBTreeTestCase(AssociateTestCase):
+    dbtype = db.DB_BTREE
+
+class AssociateRecnoTestCase(AssociateTestCase):
+    dbtype = db.DB_RECNO
+    keytype = 0
+
+#----------------------------------------------------------------------
+
+class AssociateBTreeTxnTestCase(AssociateBTreeTestCase):
+    envFlags = db.DB_INIT_TXN
+    dbFlags = 0
+
+    def txn_finish_test(self, sDB, txn):
+        try:
+            self.finish_test(sDB, txn=txn)
+        finally:
+            if self.cur:
+                self.cur.close()
+                self.cur = None
+            if txn:
+                txn.commit()
+
+    def test13_associate_in_transaction(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test13_associateAutoCommit..." % \
+                  self.__class__.__name__
+
+        txn = self.env.txn_begin()
+        try:
+            self.createDB(txn=txn)
+
+            self.secDB = db.DB(self.env)
+            self.secDB.set_flags(db.DB_DUP)
+            self.secDB.set_get_returns_none(2)
+            self.secDB.open(self.filename, "secondary", db.DB_BTREE,
+                       db.DB_CREATE | db.DB_THREAD, txn=txn)
+            self.getDB().associate(self.secDB, self.getGenre, txn=txn)
+
+            self.addDataToDB(self.getDB(), txn=txn)
+        except:
+            txn.abort()
+            raise
+
+        self.txn_finish_test(self.secDB, txn=txn)
+
+
+#----------------------------------------------------------------------
+
+class ShelveAssociateTestCase(AssociateTestCase):
+
+    def createDB(self):
+        self.primary = dbshelve.open(self.filename,
+                                     dbname="primary",
+                                     dbenv=self.env,
+                                     filetype=self.dbtype)
+
+    def addDataToDB(self, d):
+        for key, value in musicdata.items():
+            if type(self.keytype) == type(''):
+                key = "%02d" % key
+            d.put(key, value)    # save the value as is this time
+
+
+    def getGenre(self, priKey, priData):
+        self.assertEqual(type(priData), type(()))
+        if verbose:
+            print 'getGenre key: %r data: %r' % (priKey, priData)
+        genre = priData[2]
+        if genre == 'Blues':
+            return db.DB_DONOTINDEX
+        else:
+            return genre
+
+
+class ShelveAssociateHashTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_HASH
+
+class ShelveAssociateBTreeTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_BTREE
+
+class ShelveAssociateRecnoTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_RECNO
+    keytype = 0
+
+
+#----------------------------------------------------------------------
+
+class ThreadedAssociateTestCase(AssociateTestCase):
+
+    def addDataToDB(self, d):
+        t1 = Thread(target = self.writer1,
+                    args = (d, ))
+        t2 = Thread(target = self.writer2,
+                    args = (d, ))
+
+        t1.setDaemon(True)
+        t2.setDaemon(True)
+        t1.start()
+        t2.start()
+        t1.join()
+        t2.join()
+
+    def writer1(self, d):
+        for key, value in musicdata.items():
+            if type(self.keytype) == type(''):
+                key = "%02d" % key
+            d.put(key, '|'.join(value))
+
+    def writer2(self, d):
+        for x in range(100, 600):
+            key = 'z%2d' % x
+            value = [key] * 4
+            d.put(key, '|'.join(value))
+
+
+class ThreadedAssociateHashTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_HASH
+
+class ThreadedAssociateBTreeTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_BTREE
+
+class ThreadedAssociateRecnoTestCase(ShelveAssociateTestCase):
+    dbtype = db.DB_RECNO
+    keytype = 0
+
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(AssociateErrorTestCase))
+
+    suite.addTest(unittest.makeSuite(AssociateHashTestCase))
+    suite.addTest(unittest.makeSuite(AssociateBTreeTestCase))
+    suite.addTest(unittest.makeSuite(AssociateRecnoTestCase))
+
+    suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
+
+    suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase))
+    suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase))
+    suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase))
+
+    if have_threads:
+        suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase))
+        suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase))
+        suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase))
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_basics.py b/lib/python2.7/bsddb/test/test_basics.py
new file mode 100644
index 0000000..3c57be4
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_basics.py
@@ -0,0 +1,1158 @@
+"""
+Basic TestCases for BTree and hash DBs, with and without a DBEnv, with
+various DB flags, etc.
+"""
+
+import os
+import errno
+import string
+from pprint import pprint
+import unittest
+import time
+import sys
+
+from test_all import db, test_support, verbose, get_new_environment_path, \
+        get_new_database_path
+
+DASH = '-'
+
+
+#----------------------------------------------------------------------
+
+class VersionTestCase(unittest.TestCase):
+    def test00_version(self):
+        info = db.version()
+        if verbose:
+            print '\n', '-=' * 20
+            print 'bsddb.db.version(): %s' % (info, )
+            print db.DB_VERSION_STRING
+            print '-=' * 20
+        self.assertEqual(info, (db.DB_VERSION_MAJOR, db.DB_VERSION_MINOR,
+                        db.DB_VERSION_PATCH))
+
+#----------------------------------------------------------------------
+
+class BasicTestCase(unittest.TestCase):
+    dbtype       = db.DB_UNKNOWN  # must be set in derived class
+    cachesize    = (0, 1024*1024, 1)
+    dbopenflags  = 0
+    dbsetflags   = 0
+    dbmode       = 0660
+    dbname       = None
+    useEnv       = 0
+    envflags     = 0
+    envsetflags  = 0
+
+    _numKeys      = 1002    # PRIVATE.  NOTE: must be an even value
+
+    def setUp(self):
+        if self.useEnv:
+            self.homeDir=get_new_environment_path()
+            try:
+                self.env = db.DBEnv()
+                self.env.set_lg_max(1024*1024)
+                self.env.set_tx_max(30)
+                self._t = int(time.time())
+                self.env.set_tx_timestamp(self._t)
+                self.env.set_flags(self.envsetflags, 1)
+                self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
+                self.filename = "test"
+            # Yes, a bare except is intended, since we're re-raising the exc.
+            except:
+                test_support.rmtree(self.homeDir)
+                raise
+        else:
+            self.env = None
+            self.filename = get_new_database_path()
+
+        # create and open the DB
+        self.d = db.DB(self.env)
+        if not self.useEnv :
+            self.d.set_cachesize(*self.cachesize)
+            cachesize = self.d.get_cachesize()
+            self.assertEqual(cachesize[0], self.cachesize[0])
+            self.assertEqual(cachesize[2], self.cachesize[2])
+            # Berkeley DB expands the cache 25% accounting overhead,
+            # if the cache is small.
+            self.assertEqual(125, int(100.0*cachesize[1]/self.cachesize[1]))
+        self.d.set_flags(self.dbsetflags)
+        if self.dbname:
+            self.d.open(self.filename, self.dbname, self.dbtype,
+                        self.dbopenflags|db.DB_CREATE, self.dbmode)
+        else:
+            self.d.open(self.filename,   # try out keyword args
+                        mode = self.dbmode,
+                        dbtype = self.dbtype,
+                        flags = self.dbopenflags|db.DB_CREATE)
+
+        if not self.useEnv:
+            self.assertRaises(db.DBInvalidArgError,
+                    self.d.set_cachesize, *self.cachesize)
+
+        self.populateDB()
+
+
+    def tearDown(self):
+        self.d.close()
+        if self.env is not None:
+            self.env.close()
+            test_support.rmtree(self.homeDir)
+        else:
+            os.remove(self.filename)
+
+
+
+    def populateDB(self, _txn=None):
+        d = self.d
+
+        for x in range(self._numKeys//2):
+            key = '%04d' % (self._numKeys - x)  # insert keys in reverse order
+            data = self.makeData(key)
+            d.put(key, data, _txn)
+
+        d.put('empty value', '', _txn)
+
+        for x in range(self._numKeys//2-1):
+            key = '%04d' % x  # and now some in forward order
+            data = self.makeData(key)
+            d.put(key, data, _txn)
+
+        if _txn:
+            _txn.commit()
+
+        num = len(d)
+        if verbose:
+            print "created %d records" % num
+
+
+    def makeData(self, key):
+        return DASH.join([key] * 5)
+
+
+
+    #----------------------------------------
+
+    def test01_GetsAndPuts(self):
+        d = self.d
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_GetsAndPuts..." % self.__class__.__name__
+
+        for key in ['0001', '0100', '0400', '0700', '0999']:
+            data = d.get(key)
+            if verbose:
+                print data
+
+        self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
+
+        # By default non-existent keys return None...
+        self.assertEqual(d.get('abcd'), None)
+
+        # ...but they raise exceptions in other situations.  Call
+        # set_get_returns_none() to change it.
+        try:
+            d.delete('abcd')
+        except db.DBNotFoundError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.DB_NOTFOUND)
+            else :
+                self.assertEqual(val.args[0], db.DB_NOTFOUND)
+            if verbose: print val
+        else:
+            self.fail("expected exception")
+
+
+        d.put('abcd', 'a new record')
+        self.assertEqual(d.get('abcd'), 'a new record')
+
+        d.put('abcd', 'same key')
+        if self.dbsetflags & db.DB_DUP:
+            self.assertEqual(d.get('abcd'), 'a new record')
+        else:
+            self.assertEqual(d.get('abcd'), 'same key')
+
+
+        try:
+            d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
+        except db.DBKeyExistError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.DB_KEYEXIST)
+            else :
+                self.assertEqual(val.args[0], db.DB_KEYEXIST)
+            if verbose: print val
+        else:
+            self.fail("expected exception")
+
+        if self.dbsetflags & db.DB_DUP:
+            self.assertEqual(d.get('abcd'), 'a new record')
+        else:
+            self.assertEqual(d.get('abcd'), 'same key')
+
+
+        d.sync()
+        d.close()
+        del d
+
+        self.d = db.DB(self.env)
+        if self.dbname:
+            self.d.open(self.filename, self.dbname)
+        else:
+            self.d.open(self.filename)
+        d = self.d
+
+        self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
+        if self.dbsetflags & db.DB_DUP:
+            self.assertEqual(d.get('abcd'), 'a new record')
+        else:
+            self.assertEqual(d.get('abcd'), 'same key')
+
+        rec = d.get_both('0555', '0555-0555-0555-0555-0555')
+        if verbose:
+            print rec
+
+        self.assertEqual(d.get_both('0555', 'bad data'), None)
+
+        # test default value
+        data = d.get('bad key', 'bad data')
+        self.assertEqual(data, 'bad data')
+
+        # any object can pass through
+        data = d.get('bad key', self)
+        self.assertEqual(data, self)
+
+        s = d.stat()
+        self.assertEqual(type(s), type({}))
+        if verbose:
+            print 'd.stat() returned this dictionary:'
+            pprint(s)
+
+
+    #----------------------------------------
+
+    def test02_DictionaryMethods(self):
+        d = self.d
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_DictionaryMethods..." % \
+                  self.__class__.__name__
+
+        for key in ['0002', '0101', '0401', '0701', '0998']:
+            data = d[key]
+            self.assertEqual(data, self.makeData(key))
+            if verbose:
+                print data
+
+        self.assertEqual(len(d), self._numKeys)
+        keys = d.keys()
+        self.assertEqual(len(keys), self._numKeys)
+        self.assertEqual(type(keys), type([]))
+
+        d['new record'] = 'a new record'
+        self.assertEqual(len(d), self._numKeys+1)
+        keys = d.keys()
+        self.assertEqual(len(keys), self._numKeys+1)
+
+        d['new record'] = 'a replacement record'
+        self.assertEqual(len(d), self._numKeys+1)
+        keys = d.keys()
+        self.assertEqual(len(keys), self._numKeys+1)
+
+        if verbose:
+            print "the first 10 keys are:"
+            pprint(keys[:10])
+
+        self.assertEqual(d['new record'], 'a replacement record')
+
+# We check also the positional parameter
+        self.assertEqual(d.has_key('0001', None), 1)
+# We check also the keyword parameter
+        self.assertEqual(d.has_key('spam', txn=None), 0)
+
+        items = d.items()
+        self.assertEqual(len(items), self._numKeys+1)
+        self.assertEqual(type(items), type([]))
+        self.assertEqual(type(items[0]), type(()))
+        self.assertEqual(len(items[0]), 2)
+
+        if verbose:
+            print "the first 10 items are:"
+            pprint(items[:10])
+
+        values = d.values()
+        self.assertEqual(len(values), self._numKeys+1)
+        self.assertEqual(type(values), type([]))
+
+        if verbose:
+            print "the first 10 values are:"
+            pprint(values[:10])
+
+
+    #----------------------------------------
+
+    def test02b_SequenceMethods(self):
+        d = self.d
+
+        for key in ['0002', '0101', '0401', '0701', '0998']:
+            data = d[key]
+            self.assertEqual(data, self.makeData(key))
+            if verbose:
+                print data
+
+        self.assertTrue(hasattr(d, "__contains__"))
+        self.assertTrue("0401" in d)
+        self.assertFalse("1234" in d)
+
+
+    #----------------------------------------
+
+    def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_SimpleCursorStuff (get_error %s, set_error %s)..." % \
+                  (self.__class__.__name__, get_raises_error, set_raises_error)
+
+        if self.env and self.dbopenflags & db.DB_AUTO_COMMIT:
+            txn = self.env.txn_begin()
+        else:
+            txn = None
+        c = self.d.cursor(txn=txn)
+
+        rec = c.first()
+        count = 0
+        while rec is not None:
+            count = count + 1
+            if verbose and count % 100 == 0:
+                print rec
+            try:
+                rec = c.next()
+            except db.DBNotFoundError, val:
+                if get_raises_error:
+                    if sys.version_info < (2, 6) :
+                        self.assertEqual(val[0], db.DB_NOTFOUND)
+                    else :
+                        self.assertEqual(val.args[0], db.DB_NOTFOUND)
+                    if verbose: print val
+                    rec = None
+                else:
+                    self.fail("unexpected DBNotFoundError")
+            self.assertEqual(c.get_current_size(), len(c.current()[1]),
+                    "%s != len(%r)" % (c.get_current_size(), c.current()[1]))
+
+        self.assertEqual(count, self._numKeys)
+
+
+        rec = c.last()
+        count = 0
+        while rec is not None:
+            count = count + 1
+            if verbose and count % 100 == 0:
+                print rec
+            try:
+                rec = c.prev()
+            except db.DBNotFoundError, val:
+                if get_raises_error:
+                    if sys.version_info < (2, 6) :
+                        self.assertEqual(val[0], db.DB_NOTFOUND)
+                    else :
+                        self.assertEqual(val.args[0], db.DB_NOTFOUND)
+                    if verbose: print val
+                    rec = None
+                else:
+                    self.fail("unexpected DBNotFoundError")
+
+        self.assertEqual(count, self._numKeys)
+
+        rec = c.set('0505')
+        rec2 = c.current()
+        self.assertEqual(rec, rec2)
+        self.assertEqual(rec[0], '0505')
+        self.assertEqual(rec[1], self.makeData('0505'))
+        self.assertEqual(c.get_current_size(), len(rec[1]))
+
+        # make sure we get empty values properly
+        rec = c.set('empty value')
+        self.assertEqual(rec[1], '')
+        self.assertEqual(c.get_current_size(), 0)
+
+        try:
+            n = c.set('bad key')
+        except db.DBNotFoundError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.DB_NOTFOUND)
+            else :
+                self.assertEqual(val.args[0], db.DB_NOTFOUND)
+            if verbose: print val
+        else:
+            if set_raises_error:
+                self.fail("expected exception")
+            if n is not None:
+                self.fail("expected None: %r" % (n,))
+
+        rec = c.get_both('0404', self.makeData('0404'))
+        self.assertEqual(rec, ('0404', self.makeData('0404')))
+
+        try:
+            n = c.get_both('0404', 'bad data')
+        except db.DBNotFoundError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.DB_NOTFOUND)
+            else :
+                self.assertEqual(val.args[0], db.DB_NOTFOUND)
+            if verbose: print val
+        else:
+            if get_raises_error:
+                self.fail("expected exception")
+            if n is not None:
+                self.fail("expected None: %r" % (n,))
+
+        if self.d.get_type() == db.DB_BTREE:
+            rec = c.set_range('011')
+            if verbose:
+                print "searched for '011', found: ", rec
+
+            rec = c.set_range('011',dlen=0,doff=0)
+            if verbose:
+                print "searched (partial) for '011', found: ", rec
+            if rec[1] != '': self.fail('expected empty data portion')
+
+            ev = c.set_range('empty value')
+            if verbose:
+                print "search for 'empty value' returned", ev
+            if ev[1] != '': self.fail('empty value lookup failed')
+
+        c.set('0499')
+        c.delete()
+        try:
+            rec = c.current()
+        except db.DBKeyEmptyError, val:
+            if get_raises_error:
+                if sys.version_info < (2, 6) :
+                    self.assertEqual(val[0], db.DB_KEYEMPTY)
+                else :
+                    self.assertEqual(val.args[0], db.DB_KEYEMPTY)
+                if verbose: print val
+            else:
+                self.fail("unexpected DBKeyEmptyError")
+        else:
+            if get_raises_error:
+                self.fail('DBKeyEmptyError exception expected')
+
+        c.next()
+        c2 = c.dup(db.DB_POSITION)
+        self.assertEqual(c.current(), c2.current())
+
+        c2.put('', 'a new value', db.DB_CURRENT)
+        self.assertEqual(c.current(), c2.current())
+        self.assertEqual(c.current()[1], 'a new value')
+
+        c2.put('', 'er', db.DB_CURRENT, dlen=0, doff=5)
+        self.assertEqual(c2.current()[1], 'a newer value')
+
+        c.close()
+        c2.close()
+        if txn:
+            txn.commit()
+
+        # time to abuse the closed cursors and hope we don't crash
+        methods_to_test = {
+            'current': (),
+            'delete': (),
+            'dup': (db.DB_POSITION,),
+            'first': (),
+            'get': (0,),
+            'next': (),
+            'prev': (),
+            'last': (),
+            'put':('', 'spam', db.DB_CURRENT),
+            'set': ("0505",),
+        }
+        for method, args in methods_to_test.items():
+            try:
+                if verbose:
+                    print "attempting to use a closed cursor's %s method" % \
+                          method
+                # a bug may cause a NULL pointer dereference...
+                getattr(c, method)(*args)
+            except db.DBError, val:
+                if sys.version_info < (2, 6) :
+                    self.assertEqual(val[0], 0)
+                else :
+                    self.assertEqual(val.args[0], 0)
+                if verbose: print val
+            else:
+                self.fail("no exception raised when using a buggy cursor's"
+                          "%s method" % method)
+
+        #
+        # free cursor referencing a closed database, it should not barf:
+        #
+        oldcursor = self.d.cursor(txn=txn)
+        self.d.close()
+
+        # this would originally cause a segfault when the cursor for a
+        # closed database was cleaned up.  it should not anymore.
+        # SF pybsddb bug id 667343
+        del oldcursor
+
+    def test03b_SimpleCursorWithoutGetReturnsNone0(self):
+        # same test but raise exceptions instead of returning None
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03b_SimpleCursorStuffWithoutGetReturnsNone..." % \
+                  self.__class__.__name__
+
+        old = self.d.set_get_returns_none(0)
+        self.assertEqual(old, 2)
+        self.test03_SimpleCursorStuff(get_raises_error=1, set_raises_error=1)
+
+    def test03b_SimpleCursorWithGetReturnsNone1(self):
+        # same test but raise exceptions instead of returning None
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03b_SimpleCursorStuffWithoutGetReturnsNone..." % \
+                  self.__class__.__name__
+
+        old = self.d.set_get_returns_none(1)
+        self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=1)
+
+
+    def test03c_SimpleCursorGetReturnsNone2(self):
+        # same test but raise exceptions instead of returning None
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03c_SimpleCursorStuffWithoutSetReturnsNone..." % \
+                  self.__class__.__name__
+
+        old = self.d.set_get_returns_none(1)
+        self.assertEqual(old, 2)
+        old = self.d.set_get_returns_none(2)
+        self.assertEqual(old, 1)
+        self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=0)
+
+    if db.version() >= (4, 6):
+        def test03d_SimpleCursorPriority(self) :
+            c = self.d.cursor()
+            c.set_priority(db.DB_PRIORITY_VERY_LOW)  # Positional
+            self.assertEqual(db.DB_PRIORITY_VERY_LOW, c.get_priority())
+            c.set_priority(priority=db.DB_PRIORITY_HIGH)  # Keyword
+            self.assertEqual(db.DB_PRIORITY_HIGH, c.get_priority())
+            c.close()
+
+    #----------------------------------------
+
+    def test04_PartialGetAndPut(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test04_PartialGetAndPut..." % \
+                  self.__class__.__name__
+
+        key = "partialTest"
+        data = "1" * 1000 + "2" * 1000
+        d.put(key, data)
+        self.assertEqual(d.get(key), data)
+        self.assertEqual(d.get(key, dlen=20, doff=990),
+                ("1" * 10) + ("2" * 10))
+
+        d.put("partialtest2", ("1" * 30000) + "robin" )
+        self.assertEqual(d.get("partialtest2", dlen=5, doff=30000), "robin")
+
+        # There seems to be a bug in DB here...  Commented out the test for
+        # now.
+        ##self.assertEqual(d.get("partialtest2", dlen=5, doff=30010), "")
+
+        if self.dbsetflags != db.DB_DUP:
+            # Partial put with duplicate records requires a cursor
+            d.put(key, "0000", dlen=2000, doff=0)
+            self.assertEqual(d.get(key), "0000")
+
+            d.put(key, "1111", dlen=1, doff=2)
+            self.assertEqual(d.get(key), "0011110")
+
+    #----------------------------------------
+
+    def test05_GetSize(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test05_GetSize..." % self.__class__.__name__
+
+        for i in range(1, 50000, 500):
+            key = "size%s" % i
+            #print "before ", i,
+            d.put(key, "1" * i)
+            #print "after",
+            self.assertEqual(d.get_size(key), i)
+            #print "done"
+
+    #----------------------------------------
+
+    def test06_Truncate(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test06_Truncate..." % self.__class__.__name__
+
+        d.put("abcde", "ABCDE");
+        num = d.truncate()
+        self.assertTrue(num >= 1, "truncate returned <= 0 on non-empty database")
+        num = d.truncate()
+        self.assertEqual(num, 0,
+                "truncate on empty DB returned nonzero (%r)" % (num,))
+
+    #----------------------------------------
+
+    def test07_verify(self):
+        # Verify bug solved in 4.7.3pre8
+        self.d.close()
+        d = db.DB(self.env)
+        d.verify(self.filename)
+
+
+    #----------------------------------------
+
+    if db.version() >= (4, 6):
+        def test08_exists(self) :
+            self.d.put("abcde", "ABCDE")
+            self.assertTrue(self.d.exists("abcde") == True,
+                    "DB->exists() returns wrong value")
+            self.assertTrue(self.d.exists("x") == False,
+                    "DB->exists() returns wrong value")
+
+    #----------------------------------------
+
+    if db.version() >= (4, 7):
+        def test_compact(self) :
+            d = self.d
+            self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
+            self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
+            d.put("abcde", "ABCDE");
+            d.put("bcde", "BCDE");
+            d.put("abc", "ABC");
+            d.put("monty", "python");
+            d.delete("abc")
+            d.delete("bcde")
+            d.compact(start='abcde', stop='monty', txn=None,
+                    compact_fillpercent=42, compact_pages=1,
+                    compact_timeout=50000000,
+                    flags=db.DB_FREELIST_ONLY|db.DB_FREE_SPACE)
+
+    #----------------------------------------
+
+#----------------------------------------------------------------------
+
+
+class BasicBTreeTestCase(BasicTestCase):
+    dbtype = db.DB_BTREE
+
+
+class BasicHashTestCase(BasicTestCase):
+    dbtype = db.DB_HASH
+
+
+class BasicBTreeWithThreadFlagTestCase(BasicTestCase):
+    dbtype = db.DB_BTREE
+    dbopenflags = db.DB_THREAD
+
+
+class BasicHashWithThreadFlagTestCase(BasicTestCase):
+    dbtype = db.DB_HASH
+    dbopenflags = db.DB_THREAD
+
+
+class BasicWithEnvTestCase(BasicTestCase):
+    dbopenflags = db.DB_THREAD
+    useEnv = 1
+    envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
+
+    #----------------------------------------
+
+    def test09_EnvRemoveAndRename(self):
+        if not self.env:
+            return
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test09_EnvRemoveAndRename..." % self.__class__.__name__
+
+        # can't rename or remove an open DB
+        self.d.close()
+
+        newname = self.filename + '.renamed'
+        self.env.dbrename(self.filename, None, newname)
+        self.env.dbremove(newname)
+
+    #----------------------------------------
+
+class BasicBTreeWithEnvTestCase(BasicWithEnvTestCase):
+    dbtype = db.DB_BTREE
+
+
+class BasicHashWithEnvTestCase(BasicWithEnvTestCase):
+    dbtype = db.DB_HASH
+
+
+#----------------------------------------------------------------------
+
+class BasicTransactionTestCase(BasicTestCase):
+    if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
+            (sys.version_info < (3, 2))) :
+        def assertIn(self, a, b, msg=None) :
+            return self.assertTrue(a in b, msg=msg)
+
+    dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT
+    useEnv = 1
+    envflags = (db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
+                db.DB_INIT_TXN)
+    envsetflags = db.DB_AUTO_COMMIT
+
+
+    def tearDown(self):
+        self.txn.commit()
+        BasicTestCase.tearDown(self)
+
+
+    def populateDB(self):
+        txn = self.env.txn_begin()
+        BasicTestCase.populateDB(self, _txn=txn)
+
+        self.txn = self.env.txn_begin()
+
+
+    def test06_Transactions(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test06_Transactions..." % self.__class__.__name__
+
+        self.assertEqual(d.get('new rec', txn=self.txn), None)
+        d.put('new rec', 'this is a new record', self.txn)
+        self.assertEqual(d.get('new rec', txn=self.txn),
+                'this is a new record')
+        self.txn.abort()
+        self.assertEqual(d.get('new rec'), None)
+
+        self.txn = self.env.txn_begin()
+
+        self.assertEqual(d.get('new rec', txn=self.txn), None)
+        d.put('new rec', 'this is a new record', self.txn)
+        self.assertEqual(d.get('new rec', txn=self.txn),
+                'this is a new record')
+        self.txn.commit()
+        self.assertEqual(d.get('new rec'), 'this is a new record')
+
+        self.txn = self.env.txn_begin()
+        c = d.cursor(self.txn)
+        rec = c.first()
+        count = 0
+        while rec is not None:
+            count = count + 1
+            if verbose and count % 100 == 0:
+                print rec
+            rec = c.next()
+        self.assertEqual(count, self._numKeys+1)
+
+        c.close()                # Cursors *MUST* be closed before commit!
+        self.txn.commit()
+
+        # flush pending updates
+        self.env.txn_checkpoint (0, 0, 0)
+
+        statDict = self.env.log_stat(0);
+        self.assertIn('magic', statDict)
+        self.assertIn('version', statDict)
+        self.assertIn('cur_file', statDict)
+        self.assertIn('region_nowait', statDict)
+
+        # must have at least one log file present:
+        logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
+        self.assertNotEqual(logs, None)
+        for log in logs:
+            if verbose:
+                print 'log file: ' + log
+            logs = self.env.log_archive(db.DB_ARCH_REMOVE)
+            self.assertTrue(not logs)
+
+        self.txn = self.env.txn_begin()
+
+    #----------------------------------------
+
+    if db.version() >= (4, 6):
+        def test08_exists(self) :
+            txn = self.env.txn_begin()
+            self.d.put("abcde", "ABCDE", txn=txn)
+            txn.commit()
+            txn = self.env.txn_begin()
+            self.assertTrue(self.d.exists("abcde", txn=txn) == True,
+                    "DB->exists() returns wrong value")
+            self.assertTrue(self.d.exists("x", txn=txn) == False,
+                    "DB->exists() returns wrong value")
+            txn.abort()
+
+    #----------------------------------------
+
+    def test09_TxnTruncate(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test09_TxnTruncate..." % self.__class__.__name__
+
+        d.put("abcde", "ABCDE");
+        txn = self.env.txn_begin()
+        num = d.truncate(txn)
+        self.assertTrue(num >= 1, "truncate returned <= 0 on non-empty database")
+        num = d.truncate(txn)
+        self.assertEqual(num, 0,
+                "truncate on empty DB returned nonzero (%r)" % (num,))
+        txn.commit()
+
+    #----------------------------------------
+
+    def test10_TxnLateUse(self):
+        txn = self.env.txn_begin()
+        txn.abort()
+        try:
+            txn.abort()
+        except db.DBError, e:
+            pass
+        else:
+            raise RuntimeError, "DBTxn.abort() called after DB_TXN no longer valid w/o an exception"
+
+        txn = self.env.txn_begin()
+        txn.commit()
+        try:
+            txn.commit()
+        except db.DBError, e:
+            pass
+        else:
+            raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
+
+
+    #----------------------------------------
+
+
+    if db.version() >= (4, 4):
+        def test_txn_name(self) :
+            txn=self.env.txn_begin()
+            self.assertEqual(txn.get_name(), "")
+            txn.set_name("XXYY")
+            self.assertEqual(txn.get_name(), "XXYY")
+            txn.set_name("")
+            self.assertEqual(txn.get_name(), "")
+            txn.abort()
+
+    #----------------------------------------
+
+
+        def test_txn_set_timeout(self) :
+            txn=self.env.txn_begin()
+            txn.set_timeout(1234567, db.DB_SET_LOCK_TIMEOUT)
+            txn.set_timeout(2345678, flags=db.DB_SET_TXN_TIMEOUT)
+            txn.abort()
+
+    #----------------------------------------
+
+        def test_get_tx_max(self) :
+            self.assertEqual(self.env.get_tx_max(), 30)
+
+        def test_get_tx_timestamp(self) :
+            self.assertEqual(self.env.get_tx_timestamp(), self._t)
+
+
+
+class BTreeTransactionTestCase(BasicTransactionTestCase):
+    dbtype = db.DB_BTREE
+
+class HashTransactionTestCase(BasicTransactionTestCase):
+    dbtype = db.DB_HASH
+
+
+
+#----------------------------------------------------------------------
+
+class BTreeRecnoTestCase(BasicTestCase):
+    dbtype     = db.DB_BTREE
+    dbsetflags = db.DB_RECNUM
+
+    def test09_RecnoInBTree(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test09_RecnoInBTree..." % self.__class__.__name__
+
+        rec = d.get(200)
+        self.assertEqual(type(rec), type(()))
+        self.assertEqual(len(rec), 2)
+        if verbose:
+            print "Record #200 is ", rec
+
+        c = d.cursor()
+        c.set('0200')
+        num = c.get_recno()
+        self.assertEqual(type(num), type(1))
+        if verbose:
+            print "recno of d['0200'] is ", num
+
+        rec = c.current()
+        self.assertEqual(c.set_recno(num), rec)
+
+        c.close()
+
+
+
+class BTreeRecnoWithThreadFlagTestCase(BTreeRecnoTestCase):
+    dbopenflags = db.DB_THREAD
+
+#----------------------------------------------------------------------
+
+class BasicDUPTestCase(BasicTestCase):
+    dbsetflags = db.DB_DUP
+
+    def test10_DuplicateKeys(self):
+        d = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test10_DuplicateKeys..." % \
+                  self.__class__.__name__
+
+        d.put("dup0", "before")
+        for x in "The quick brown fox jumped over the lazy dog.".split():
+            d.put("dup1", x)
+        d.put("dup2", "after")
+
+        data = d.get("dup1")
+        self.assertEqual(data, "The")
+        if verbose:
+            print data
+
+        c = d.cursor()
+        rec = c.set("dup1")
+        self.assertEqual(rec, ('dup1', 'The'))
+
+        next_reg = c.next()
+        self.assertEqual(next_reg, ('dup1', 'quick'))
+
+        rec = c.set("dup1")
+        count = c.count()
+        self.assertEqual(count, 9)
+
+        next_dup = c.next_dup()
+        self.assertEqual(next_dup, ('dup1', 'quick'))
+
+        rec = c.set('dup1')
+        while rec is not None:
+            if verbose:
+                print rec
+            rec = c.next_dup()
+
+        c.set('dup1')
+        rec = c.next_nodup()
+        self.assertNotEqual(rec[0], 'dup1')
+        if verbose:
+            print rec
+
+        c.close()
+
+
+
+class BTreeDUPTestCase(BasicDUPTestCase):
+    dbtype = db.DB_BTREE
+
+class HashDUPTestCase(BasicDUPTestCase):
+    dbtype = db.DB_HASH
+
+class BTreeDUPWithThreadTestCase(BasicDUPTestCase):
+    dbtype = db.DB_BTREE
+    dbopenflags = db.DB_THREAD
+
+class HashDUPWithThreadTestCase(BasicDUPTestCase):
+    dbtype = db.DB_HASH
+    dbopenflags = db.DB_THREAD
+
+
+#----------------------------------------------------------------------
+
+class BasicMultiDBTestCase(BasicTestCase):
+    dbname = 'first'
+
+    def otherType(self):
+        if self.dbtype == db.DB_BTREE:
+            return db.DB_HASH
+        else:
+            return db.DB_BTREE
+
+    def test11_MultiDB(self):
+        d1 = self.d
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test11_MultiDB..." % self.__class__.__name__
+
+        d2 = db.DB(self.env)
+        d2.open(self.filename, "second", self.dbtype,
+                self.dbopenflags|db.DB_CREATE)
+        d3 = db.DB(self.env)
+        d3.open(self.filename, "third", self.otherType(),
+                self.dbopenflags|db.DB_CREATE)
+
+        for x in "The quick brown fox jumped over the lazy dog".split():
+            d2.put(x, self.makeData(x))
+
+        for x in string.letters:
+            d3.put(x, x*70)
+
+        d1.sync()
+        d2.sync()
+        d3.sync()
+        d1.close()
+        d2.close()
+        d3.close()
+
+        self.d = d1 = d2 = d3 = None
+
+        self.d = d1 = db.DB(self.env)
+        d1.open(self.filename, self.dbname, flags = self.dbopenflags)
+        d2 = db.DB(self.env)
+        d2.open(self.filename, "second",  flags = self.dbopenflags)
+        d3 = db.DB(self.env)
+        d3.open(self.filename, "third", flags = self.dbopenflags)
+
+        c1 = d1.cursor()
+        c2 = d2.cursor()
+        c3 = d3.cursor()
+
+        count = 0
+        rec = c1.first()
+        while rec is not None:
+            count = count + 1
+            if verbose and (count % 50) == 0:
+                print rec
+            rec = c1.next()
+        self.assertEqual(count, self._numKeys)
+
+        count = 0
+        rec = c2.first()
+        while rec is not None:
+            count = count + 1
+            if verbose:
+                print rec
+            rec = c2.next()
+        self.assertEqual(count, 9)
+
+        count = 0
+        rec = c3.first()
+        while rec is not None:
+            count = count + 1
+            if verbose:
+                print rec
+            rec = c3.next()
+        self.assertEqual(count, len(string.letters))
+
+
+        c1.close()
+        c2.close()
+        c3.close()
+
+        d2.close()
+        d3.close()
+
+
+
+# Strange things happen if you try to use Multiple DBs per file without a
+# DBEnv with MPOOL and LOCKing...
+
+class BTreeMultiDBTestCase(BasicMultiDBTestCase):
+    dbtype = db.DB_BTREE
+    dbopenflags = db.DB_THREAD
+    useEnv = 1
+    envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
+
+class HashMultiDBTestCase(BasicMultiDBTestCase):
+    dbtype = db.DB_HASH
+    dbopenflags = db.DB_THREAD
+    useEnv = 1
+    envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
+
+
+class PrivateObject(unittest.TestCase) :
+    def tearDown(self) :
+        del self.obj
+
+    def test01_DefaultIsNone(self) :
+        self.assertEqual(self.obj.get_private(), None)
+
+    def test02_assignment(self) :
+        a = "example of private object"
+        self.obj.set_private(a)
+        b = self.obj.get_private()
+        self.assertTrue(a is b)  # Object identity
+
+    def test03_leak_assignment(self) :
+        a = "example of private object"
+        refcount = sys.getrefcount(a)
+        self.obj.set_private(a)
+        self.assertEqual(refcount+1, sys.getrefcount(a))
+        self.obj.set_private(None)
+        self.assertEqual(refcount, sys.getrefcount(a))
+
+    def test04_leak_GC(self) :
+        a = "example of private object"
+        refcount = sys.getrefcount(a)
+        self.obj.set_private(a)
+        self.obj = None
+        self.assertEqual(refcount, sys.getrefcount(a))
+
+class DBEnvPrivateObject(PrivateObject) :
+    def setUp(self) :
+        self.obj = db.DBEnv()
+
+class DBPrivateObject(PrivateObject) :
+    def setUp(self) :
+        self.obj = db.DB()
+
+class CrashAndBurn(unittest.TestCase) :
+    #def test01_OpenCrash(self) :
+    #    # See http://bugs.python.org/issue3307
+    #    self.assertRaises(db.DBInvalidArgError, db.DB, None, 65535)
+
+    if db.version() < (4, 8) :
+        def test02_DBEnv_dealloc(self):
+            # http://bugs.python.org/issue3885
+            import gc
+            self.assertRaises(db.DBInvalidArgError, db.DBEnv, ~db.DB_RPCCLIENT)
+            gc.collect()
+
+
+#----------------------------------------------------------------------
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(VersionTestCase))
+    suite.addTest(unittest.makeSuite(BasicBTreeTestCase))
+    suite.addTest(unittest.makeSuite(BasicHashTestCase))
+    suite.addTest(unittest.makeSuite(BasicBTreeWithThreadFlagTestCase))
+    suite.addTest(unittest.makeSuite(BasicHashWithThreadFlagTestCase))
+    suite.addTest(unittest.makeSuite(BasicBTreeWithEnvTestCase))
+    suite.addTest(unittest.makeSuite(BasicHashWithEnvTestCase))
+    suite.addTest(unittest.makeSuite(BTreeTransactionTestCase))
+    suite.addTest(unittest.makeSuite(HashTransactionTestCase))
+    suite.addTest(unittest.makeSuite(BTreeRecnoTestCase))
+    suite.addTest(unittest.makeSuite(BTreeRecnoWithThreadFlagTestCase))
+    suite.addTest(unittest.makeSuite(BTreeDUPTestCase))
+    suite.addTest(unittest.makeSuite(HashDUPTestCase))
+    suite.addTest(unittest.makeSuite(BTreeDUPWithThreadTestCase))
+    suite.addTest(unittest.makeSuite(HashDUPWithThreadTestCase))
+    suite.addTest(unittest.makeSuite(BTreeMultiDBTestCase))
+    suite.addTest(unittest.makeSuite(HashMultiDBTestCase))
+    suite.addTest(unittest.makeSuite(DBEnvPrivateObject))
+    suite.addTest(unittest.makeSuite(DBPrivateObject))
+    suite.addTest(unittest.makeSuite(CrashAndBurn))
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_compare.py b/lib/python2.7/bsddb/test/test_compare.py
new file mode 100644
index 0000000..cb3b463
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_compare.py
@@ -0,0 +1,447 @@
+"""
+TestCases for python DB duplicate and Btree key comparison function.
+"""
+
+import sys, os, re
+import test_all
+from cStringIO import StringIO
+
+import unittest
+
+from test_all import db, dbshelve, test_support, \
+        get_new_environment_path, get_new_database_path
+
+
+# Needed for python 3. "cmp" vanished in 3.0.1
+def cmp(a, b) :
+    if a==b : return 0
+    if a<b : return -1
+    return 1
+
+lexical_cmp = cmp
+
+def lowercase_cmp(left, right) :
+    return cmp(left.lower(), right.lower())
+
+def make_reverse_comparator(cmp) :
+    def reverse(left, right, delegate=cmp) :
+        return - delegate(left, right)
+    return reverse
+
+_expected_lexical_test_data = ['', 'CCCP', 'a', 'aaa', 'b', 'c', 'cccce', 'ccccf']
+_expected_lowercase_test_data = ['', 'a', 'aaa', 'b', 'c', 'CC', 'cccce', 'ccccf', 'CCCP']
+
+class ComparatorTests(unittest.TestCase) :
+    def comparator_test_helper(self, comparator, expected_data) :
+        data = expected_data[:]
+
+        import sys
+        if sys.version_info < (2, 6) :
+            data.sort(cmp=comparator)
+        else :  # Insertion Sort. Please, improve
+            data2 = []
+            for i in data :
+                for j, k in enumerate(data2) :
+                    r = comparator(k, i)
+                    if r == 1 :
+                        data2.insert(j, i)
+                        break
+                else :
+                    data2.append(i)
+            data = data2
+
+        self.assertEqual(data, expected_data,
+                         "comparator `%s' is not right: %s vs. %s"
+                         % (comparator, expected_data, data))
+    def test_lexical_comparator(self) :
+        self.comparator_test_helper(lexical_cmp, _expected_lexical_test_data)
+    def test_reverse_lexical_comparator(self) :
+        rev = _expected_lexical_test_data[:]
+        rev.reverse()
+        self.comparator_test_helper(make_reverse_comparator(lexical_cmp),
+                                     rev)
+    def test_lowercase_comparator(self) :
+        self.comparator_test_helper(lowercase_cmp,
+                                     _expected_lowercase_test_data)
+
+class AbstractBtreeKeyCompareTestCase(unittest.TestCase) :
+    env = None
+    db = None
+
+    if (sys.version_info < (2, 7)) or ((sys.version_info >= (3,0)) and
+            (sys.version_info < (3, 2))) :
+        def assertLess(self, a, b, msg=None) :
+            return self.assertTrue(a<b, msg=msg)
+
+    def setUp(self) :
+        self.filename = self.__class__.__name__ + '.db'
+        self.homeDir = get_new_environment_path()
+        env = db.DBEnv()
+        env.open(self.homeDir,
+                  db.DB_CREATE | db.DB_INIT_MPOOL
+                  | db.DB_INIT_LOCK | db.DB_THREAD)
+        self.env = env
+
+    def tearDown(self) :
+        self.closeDB()
+        if self.env is not None:
+            self.env.close()
+            self.env = None
+        test_support.rmtree(self.homeDir)
+
+    def addDataToDB(self, data) :
+        i = 0
+        for item in data:
+            self.db.put(item, str(i))
+            i = i + 1
+
+    def createDB(self, key_comparator) :
+        self.db = db.DB(self.env)
+        self.setupDB(key_comparator)
+        self.db.open(self.filename, "test", db.DB_BTREE, db.DB_CREATE)
+
+    def setupDB(self, key_comparator) :
+        self.db.set_bt_compare(key_comparator)
+
+    def closeDB(self) :
+        if self.db is not None:
+            self.db.close()
+            self.db = None
+
+    def startTest(self) :
+        pass
+
+    def finishTest(self, expected = None) :
+        if expected is not None:
+            self.check_results(expected)
+        self.closeDB()
+
+    def check_results(self, expected) :
+        curs = self.db.cursor()
+        try:
+            index = 0
+            rec = curs.first()
+            while rec:
+                key, ignore = rec
+                self.assertLess(index, len(expected),
+                                 "to many values returned from cursor")
+                self.assertEqual(expected[index], key,
+                                 "expected value `%s' at %d but got `%s'"
+                                 % (expected[index], index, key))
+                index = index + 1
+                rec = curs.next()
+            self.assertEqual(index, len(expected),
+                             "not enough values returned from cursor")
+        finally:
+            curs.close()
+
+class BtreeKeyCompareTestCase(AbstractBtreeKeyCompareTestCase) :
+    def runCompareTest(self, comparator, data) :
+        self.startTest()
+        self.createDB(comparator)
+        self.addDataToDB(data)
+        self.finishTest(data)
+
+    def test_lexical_ordering(self) :
+        self.runCompareTest(lexical_cmp, _expected_lexical_test_data)
+
+    def test_reverse_lexical_ordering(self) :
+        expected_rev_data = _expected_lexical_test_data[:]
+        expected_rev_data.reverse()
+        self.runCompareTest(make_reverse_comparator(lexical_cmp),
+                             expected_rev_data)
+
+    def test_compare_function_useless(self) :
+        self.startTest()
+        def socialist_comparator(l, r) :
+            return 0
+        self.createDB(socialist_comparator)
+        self.addDataToDB(['b', 'a', 'd'])
+        # all things being equal the first key will be the only key
+        # in the database...  (with the last key's value fwiw)
+        self.finishTest(['b'])
+
+
+class BtreeExceptionsTestCase(AbstractBtreeKeyCompareTestCase) :
+    def test_raises_non_callable(self) :
+        self.startTest()
+        self.assertRaises(TypeError, self.createDB, 'abc')
+        self.assertRaises(TypeError, self.createDB, None)
+        self.finishTest()
+
+    def test_set_bt_compare_with_function(self) :
+        self.startTest()
+        self.createDB(lexical_cmp)
+        self.finishTest()
+
+    def check_results(self, results) :
+        pass
+
+    def test_compare_function_incorrect(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            return 1
+        # verify that set_bt_compare checks that comparator('', '') == 0
+        self.assertRaises(TypeError, self.createDB, bad_comparator)
+        self.finishTest()
+
+    def verifyStderr(self, method, successRe) :
+        """
+        Call method() while capturing sys.stderr output internally and
+        call self.fail() if successRe.search() does not match the stderr
+        output.  This is used to test for uncatchable exceptions.
+        """
+        stdErr = sys.stderr
+        sys.stderr = StringIO()
+        try:
+            method()
+        finally:
+            temp = sys.stderr
+            sys.stderr = stdErr
+            errorOut = temp.getvalue()
+            if not successRe.search(errorOut) :
+                self.fail("unexpected stderr output:\n"+errorOut)
+        if sys.version_info < (3, 0) :  # XXX: How to do this in Py3k ???
+            sys.exc_traceback = sys.last_traceback = None
+
+    def _test_compare_function_exception(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            if l == r:
+                # pass the set_bt_compare test
+                return 0
+            raise RuntimeError, "i'm a naughty comparison function"
+        self.createDB(bad_comparator)
+        #print "\n*** test should print 2 uncatchable tracebacks ***"
+        self.addDataToDB(['a', 'b', 'c'])  # this should raise, but...
+        self.finishTest()
+
+    def test_compare_function_exception(self) :
+        self.verifyStderr(
+                self._test_compare_function_exception,
+                re.compile('(^RuntimeError:.* naughty.*){2}', re.M|re.S)
+        )
+
+    def _test_compare_function_bad_return(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            if l == r:
+                # pass the set_bt_compare test
+                return 0
+            return l
+        self.createDB(bad_comparator)
+        #print "\n*** test should print 2 errors about returning an int ***"
+        self.addDataToDB(['a', 'b', 'c'])  # this should raise, but...
+        self.finishTest()
+
+    def test_compare_function_bad_return(self) :
+        self.verifyStderr(
+                self._test_compare_function_bad_return,
+                re.compile('(^TypeError:.* return an int.*){2}', re.M|re.S)
+        )
+
+
+    def test_cannot_assign_twice(self) :
+
+        def my_compare(a, b) :
+            return 0
+
+        self.startTest()
+        self.createDB(my_compare)
+        self.assertRaises(RuntimeError, self.db.set_bt_compare, my_compare)
+
+class AbstractDuplicateCompareTestCase(unittest.TestCase) :
+    env = None
+    db = None
+
+    if (sys.version_info < (2, 7)) or ((sys.version_info >= (3,0)) and
+            (sys.version_info < (3, 2))) :
+        def assertLess(self, a, b, msg=None) :
+            return self.assertTrue(a<b, msg=msg)
+
+    def setUp(self) :
+        self.filename = self.__class__.__name__ + '.db'
+        self.homeDir = get_new_environment_path()
+        env = db.DBEnv()
+        env.open(self.homeDir,
+                  db.DB_CREATE | db.DB_INIT_MPOOL
+                  | db.DB_INIT_LOCK | db.DB_THREAD)
+        self.env = env
+
+    def tearDown(self) :
+        self.closeDB()
+        if self.env is not None:
+            self.env.close()
+            self.env = None
+        test_support.rmtree(self.homeDir)
+
+    def addDataToDB(self, data) :
+        for item in data:
+            self.db.put("key", item)
+
+    def createDB(self, dup_comparator) :
+        self.db = db.DB(self.env)
+        self.setupDB(dup_comparator)
+        self.db.open(self.filename, "test", db.DB_BTREE, db.DB_CREATE)
+
+    def setupDB(self, dup_comparator) :
+        self.db.set_flags(db.DB_DUPSORT)
+        self.db.set_dup_compare(dup_comparator)
+
+    def closeDB(self) :
+        if self.db is not None:
+            self.db.close()
+            self.db = None
+
+    def startTest(self) :
+        pass
+
+    def finishTest(self, expected = None) :
+        if expected is not None:
+            self.check_results(expected)
+        self.closeDB()
+
+    def check_results(self, expected) :
+        curs = self.db.cursor()
+        try:
+            index = 0
+            rec = curs.first()
+            while rec:
+                ignore, data = rec
+                self.assertLess(index, len(expected),
+                                 "to many values returned from cursor")
+                self.assertEqual(expected[index], data,
+                                 "expected value `%s' at %d but got `%s'"
+                                 % (expected[index], index, data))
+                index = index + 1
+                rec = curs.next()
+            self.assertEqual(index, len(expected),
+                             "not enough values returned from cursor")
+        finally:
+            curs.close()
+
+class DuplicateCompareTestCase(AbstractDuplicateCompareTestCase) :
+    def runCompareTest(self, comparator, data) :
+        self.startTest()
+        self.createDB(comparator)
+        self.addDataToDB(data)
+        self.finishTest(data)
+
+    def test_lexical_ordering(self) :
+        self.runCompareTest(lexical_cmp, _expected_lexical_test_data)
+
+    def test_reverse_lexical_ordering(self) :
+        expected_rev_data = _expected_lexical_test_data[:]
+        expected_rev_data.reverse()
+        self.runCompareTest(make_reverse_comparator(lexical_cmp),
+                             expected_rev_data)
+
+class DuplicateExceptionsTestCase(AbstractDuplicateCompareTestCase) :
+    def test_raises_non_callable(self) :
+        self.startTest()
+        self.assertRaises(TypeError, self.createDB, 'abc')
+        self.assertRaises(TypeError, self.createDB, None)
+        self.finishTest()
+
+    def test_set_dup_compare_with_function(self) :
+        self.startTest()
+        self.createDB(lexical_cmp)
+        self.finishTest()
+
+    def check_results(self, results) :
+        pass
+
+    def test_compare_function_incorrect(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            return 1
+        # verify that set_dup_compare checks that comparator('', '') == 0
+        self.assertRaises(TypeError, self.createDB, bad_comparator)
+        self.finishTest()
+
+    def test_compare_function_useless(self) :
+        self.startTest()
+        def socialist_comparator(l, r) :
+            return 0
+        self.createDB(socialist_comparator)
+        # DUPSORT does not allow "duplicate duplicates"
+        self.assertRaises(db.DBKeyExistError, self.addDataToDB, ['b', 'a', 'd'])
+        self.finishTest()
+
+    def verifyStderr(self, method, successRe) :
+        """
+        Call method() while capturing sys.stderr output internally and
+        call self.fail() if successRe.search() does not match the stderr
+        output.  This is used to test for uncatchable exceptions.
+        """
+        stdErr = sys.stderr
+        sys.stderr = StringIO()
+        try:
+            method()
+        finally:
+            temp = sys.stderr
+            sys.stderr = stdErr
+            errorOut = temp.getvalue()
+            if not successRe.search(errorOut) :
+                self.fail("unexpected stderr output:\n"+errorOut)
+        if sys.version_info < (3, 0) :  # XXX: How to do this in Py3k ???
+            sys.exc_traceback = sys.last_traceback = None
+
+    def _test_compare_function_exception(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            if l == r:
+                # pass the set_dup_compare test
+                return 0
+            raise RuntimeError, "i'm a naughty comparison function"
+        self.createDB(bad_comparator)
+        #print "\n*** test should print 2 uncatchable tracebacks ***"
+        self.addDataToDB(['a', 'b', 'c'])  # this should raise, but...
+        self.finishTest()
+
+    def test_compare_function_exception(self) :
+        self.verifyStderr(
+                self._test_compare_function_exception,
+                re.compile('(^RuntimeError:.* naughty.*){2}', re.M|re.S)
+        )
+
+    def _test_compare_function_bad_return(self) :
+        self.startTest()
+        def bad_comparator(l, r) :
+            if l == r:
+                # pass the set_dup_compare test
+                return 0
+            return l
+        self.createDB(bad_comparator)
+        #print "\n*** test should print 2 errors about returning an int ***"
+        self.addDataToDB(['a', 'b', 'c'])  # this should raise, but...
+        self.finishTest()
+
+    def test_compare_function_bad_return(self) :
+        self.verifyStderr(
+                self._test_compare_function_bad_return,
+                re.compile('(^TypeError:.* return an int.*){2}', re.M|re.S)
+        )
+
+
+    def test_cannot_assign_twice(self) :
+
+        def my_compare(a, b) :
+            return 0
+
+        self.startTest()
+        self.createDB(my_compare)
+        self.assertRaises(RuntimeError, self.db.set_dup_compare, my_compare)
+
+def test_suite() :
+    res = unittest.TestSuite()
+
+    res.addTest(unittest.makeSuite(ComparatorTests))
+    res.addTest(unittest.makeSuite(BtreeExceptionsTestCase))
+    res.addTest(unittest.makeSuite(BtreeKeyCompareTestCase))
+    res.addTest(unittest.makeSuite(DuplicateExceptionsTestCase))
+    res.addTest(unittest.makeSuite(DuplicateCompareTestCase))
+    return res
+
+if __name__ == '__main__':
+    unittest.main(defaultTest = 'suite')
diff --git a/lib/python2.7/bsddb/test/test_compat.py b/lib/python2.7/bsddb/test/test_compat.py
new file mode 100644
index 0000000..7679f19
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_compat.py
@@ -0,0 +1,184 @@
+"""
+Test cases adapted from the test_bsddb.py module in Python's
+regression test suite.
+"""
+
+import os, string
+import unittest
+
+from test_all import db, hashopen, btopen, rnopen, verbose, \
+        get_new_database_path
+
+
+class CompatibilityTestCase(unittest.TestCase):
+    def setUp(self):
+        self.filename = get_new_database_path()
+
+    def tearDown(self):
+        try:
+            os.remove(self.filename)
+        except os.error:
+            pass
+
+
+    def test01_btopen(self):
+        self.do_bthash_test(btopen, 'btopen')
+
+    def test02_hashopen(self):
+        self.do_bthash_test(hashopen, 'hashopen')
+
+    def test03_rnopen(self):
+        data = "The quick brown fox jumped over the lazy dog.".split()
+        if verbose:
+            print "\nTesting: rnopen"
+
+        f = rnopen(self.filename, 'c')
+        for x in range(len(data)):
+            f[x+1] = data[x]
+
+        getTest = (f[1], f[2], f[3])
+        if verbose:
+            print '%s %s %s' % getTest
+
+        self.assertEqual(getTest[1], 'quick', 'data mismatch!')
+
+        rv = f.set_location(3)
+        if rv != (3, 'brown'):
+            self.fail('recno database set_location failed: '+repr(rv))
+
+        f[25] = 'twenty-five'
+        f.close()
+        del f
+
+        f = rnopen(self.filename, 'w')
+        f[20] = 'twenty'
+
+        def noRec(f):
+            rec = f[15]
+        self.assertRaises(KeyError, noRec, f)
+
+        def badKey(f):
+            rec = f['a string']
+        self.assertRaises(TypeError, badKey, f)
+
+        del f[3]
+
+        rec = f.first()
+        while rec:
+            if verbose:
+                print rec
+            try:
+                rec = f.next()
+            except KeyError:
+                break
+
+        f.close()
+
+
+    def test04_n_flag(self):
+        f = hashopen(self.filename, 'n')
+        f.close()
+
+
+    def do_bthash_test(self, factory, what):
+        if verbose:
+            print '\nTesting: ', what
+
+        f = factory(self.filename, 'c')
+        if verbose:
+            print 'creation...'
+
+        # truth test
+        if f:
+            if verbose: print "truth test: true"
+        else:
+            if verbose: print "truth test: false"
+
+        f['0'] = ''
+        f['a'] = 'Guido'
+        f['b'] = 'van'
+        f['c'] = 'Rossum'
+        f['d'] = 'invented'
+        # 'e' intentionally left out
+        f['f'] = 'Python'
+        if verbose:
+            print '%s %s %s' % (f['a'], f['b'], f['c'])
+
+        if verbose:
+            print 'key ordering...'
+        start = f.set_location(f.first()[0])
+        if start != ('0', ''):
+            self.fail("incorrect first() result: "+repr(start))
+        while 1:
+            try:
+                rec = f.next()
+            except KeyError:
+                self.assertEqual(rec, f.last(), 'Error, last <> last!')
+                f.previous()
+                break
+            if verbose:
+                print rec
+
+        self.assertTrue(f.has_key('f'), 'Error, missing key!')
+
+        # test that set_location() returns the next nearest key, value
+        # on btree databases and raises KeyError on others.
+        if factory == btopen:
+            e = f.set_location('e')
+            if e != ('f', 'Python'):
+                self.fail('wrong key,value returned: '+repr(e))
+        else:
+            try:
+                e = f.set_location('e')
+            except KeyError:
+                pass
+            else:
+                self.fail("set_location on non-existent key did not raise KeyError")
+
+        f.sync()
+        f.close()
+        # truth test
+        try:
+            if f:
+                if verbose: print "truth test: true"
+            else:
+                if verbose: print "truth test: false"
+        except db.DBError:
+            pass
+        else:
+            self.fail("Exception expected")
+
+        del f
+
+        if verbose:
+            print 'modification...'
+        f = factory(self.filename, 'w')
+        f['d'] = 'discovered'
+
+        if verbose:
+            print 'access...'
+        for key in f.keys():
+            word = f[key]
+            if verbose:
+                print word
+
+        def noRec(f):
+            rec = f['no such key']
+        self.assertRaises(KeyError, noRec, f)
+
+        def badKey(f):
+            rec = f[15]
+        self.assertRaises(TypeError, badKey, f)
+
+        f.close()
+
+
+#----------------------------------------------------------------------
+
+
+def test_suite():
+    return unittest.makeSuite(CompatibilityTestCase)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_cursor_pget_bug.py b/lib/python2.7/bsddb/test/test_cursor_pget_bug.py
new file mode 100644
index 0000000..22d3dc1
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_cursor_pget_bug.py
@@ -0,0 +1,54 @@
+import unittest
+import os, glob
+
+from test_all import db, test_support, get_new_environment_path, \
+        get_new_database_path
+
+#----------------------------------------------------------------------
+
+class pget_bugTestCase(unittest.TestCase):
+    """Verify that cursor.pget works properly"""
+    db_name = 'test-cursor_pget.db'
+
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+        self.primary_db = db.DB(self.env)
+        self.primary_db.open(self.db_name, 'primary', db.DB_BTREE, db.DB_CREATE)
+        self.secondary_db = db.DB(self.env)
+        self.secondary_db.set_flags(db.DB_DUP)
+        self.secondary_db.open(self.db_name, 'secondary', db.DB_BTREE, db.DB_CREATE)
+        self.primary_db.associate(self.secondary_db, lambda key, data: data)
+        self.primary_db.put('salad', 'eggs')
+        self.primary_db.put('spam', 'ham')
+        self.primary_db.put('omelet', 'eggs')
+
+
+    def tearDown(self):
+        self.secondary_db.close()
+        self.primary_db.close()
+        self.env.close()
+        del self.secondary_db
+        del self.primary_db
+        del self.env
+        test_support.rmtree(self.homeDir)
+
+    def test_pget(self):
+        cursor = self.secondary_db.cursor()
+
+        self.assertEqual(('eggs', 'salad', 'eggs'), cursor.pget(key='eggs', flags=db.DB_SET))
+        self.assertEqual(('eggs', 'omelet', 'eggs'), cursor.pget(db.DB_NEXT_DUP))
+        self.assertEqual(None, cursor.pget(db.DB_NEXT_DUP))
+
+        self.assertEqual(('ham', 'spam', 'ham'), cursor.pget('ham', 'spam', flags=db.DB_SET))
+        self.assertEqual(None, cursor.pget(db.DB_NEXT_DUP))
+
+        cursor.close()
+
+
+def test_suite():
+    return unittest.makeSuite(pget_bugTestCase)
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_db.py b/lib/python2.7/bsddb/test/test_db.py
new file mode 100644
index 0000000..2bc109f
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_db.py
@@ -0,0 +1,163 @@
+import unittest
+import os, glob
+
+from test_all import db, test_support, get_new_environment_path, \
+        get_new_database_path
+
+#----------------------------------------------------------------------
+
+class DB(unittest.TestCase):
+    def setUp(self):
+        self.path = get_new_database_path()
+        self.db = db.DB()
+
+    def tearDown(self):
+        self.db.close()
+        del self.db
+        test_support.unlink(self.path)
+
+class DB_general(DB) :
+    def test_get_open_flags(self) :
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
+        self.assertEqual(db.DB_CREATE, self.db.get_open_flags())
+
+    def test_get_open_flags2(self) :
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE |
+                db.DB_THREAD)
+        self.assertEqual(db.DB_CREATE | db.DB_THREAD, self.db.get_open_flags())
+
+    def test_get_dbname_filename(self) :
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
+        self.assertEqual((self.path, None), self.db.get_dbname())
+
+    def test_get_dbname_filename_database(self) :
+        name = "jcea-random-name"
+        self.db.open(self.path, dbname=name, dbtype=db.DB_HASH,
+                flags = db.DB_CREATE)
+        self.assertEqual((self.path, name), self.db.get_dbname())
+
+        def test_bt_minkey(self) :
+            for i in [17, 108, 1030] :
+                self.db.set_bt_minkey(i)
+                self.assertEqual(i, self.db.get_bt_minkey())
+
+        def test_lorder(self) :
+            self.db.set_lorder(1234)
+            self.assertEqual(1234, self.db.get_lorder())
+            self.db.set_lorder(4321)
+            self.assertEqual(4321, self.db.get_lorder())
+            self.assertRaises(db.DBInvalidArgError, self.db.set_lorder, 9182)
+
+    if db.version() >= (4, 6) :
+        def test_priority(self) :
+            flags = [db.DB_PRIORITY_VERY_LOW, db.DB_PRIORITY_LOW,
+                    db.DB_PRIORITY_DEFAULT, db.DB_PRIORITY_HIGH,
+                    db.DB_PRIORITY_VERY_HIGH]
+            for flag in flags :
+                self.db.set_priority(flag)
+                self.assertEqual(flag, self.db.get_priority())
+
+    def test_get_transactional(self) :
+        self.assertFalse(self.db.get_transactional())
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
+        self.assertFalse(self.db.get_transactional())
+
+class DB_hash(DB) :
+    def test_h_ffactor(self) :
+        for ffactor in [4, 16, 256] :
+            self.db.set_h_ffactor(ffactor)
+            self.assertEqual(ffactor, self.db.get_h_ffactor())
+
+    def test_h_nelem(self) :
+        for nelem in [1, 2, 4] :
+            nelem = nelem*1024*1024  # Millions
+            self.db.set_h_nelem(nelem)
+            self.assertEqual(nelem, self.db.get_h_nelem())
+
+    def test_pagesize(self) :
+        for i in xrange(9, 17) :  # From 512 to 65536
+            i = 1<<i
+            self.db.set_pagesize(i)
+            self.assertEqual(i, self.db.get_pagesize())
+
+        # The valid values goes from 512 to 65536
+        # Test 131072 bytes...
+        self.assertRaises(db.DBInvalidArgError, self.db.set_pagesize, 1<<17)
+        # Test 256 bytes...
+        self.assertRaises(db.DBInvalidArgError, self.db.set_pagesize, 1<<8)
+
+class DB_txn(DB) :
+    def setUp(self) :
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+                db.DB_INIT_LOG | db.DB_INIT_TXN)
+        self.db = db.DB(self.env)
+
+    def tearDown(self) :
+        self.db.close()
+        del self.db
+        self.env.close()
+        del self.env
+        test_support.rmtree(self.homeDir)
+
+        def test_flags(self) :
+            self.db.set_flags(db.DB_CHKSUM)
+            self.assertEqual(db.DB_CHKSUM, self.db.get_flags())
+            self.db.set_flags(db.DB_TXN_NOT_DURABLE)
+            self.assertEqual(db.DB_TXN_NOT_DURABLE | db.DB_CHKSUM,
+                    self.db.get_flags())
+
+    def test_get_transactional(self) :
+        self.assertFalse(self.db.get_transactional())
+        # DB_AUTO_COMMIT = Implicit transaction
+        self.db.open("XXX", dbtype=db.DB_HASH,
+                flags = db.DB_CREATE | db.DB_AUTO_COMMIT)
+        self.assertTrue(self.db.get_transactional())
+
+class DB_recno(DB) :
+    def test_re_pad(self) :
+        for i in [' ', '*'] :  # Check chars
+            self.db.set_re_pad(i)
+            self.assertEqual(ord(i), self.db.get_re_pad())
+        for i in [97, 65] :  # Check integers
+            self.db.set_re_pad(i)
+            self.assertEqual(i, self.db.get_re_pad())
+
+    def test_re_delim(self) :
+        for i in [' ', '*'] :  # Check chars
+            self.db.set_re_delim(i)
+            self.assertEqual(ord(i), self.db.get_re_delim())
+        for i in [97, 65] :  # Check integers
+            self.db.set_re_delim(i)
+            self.assertEqual(i, self.db.get_re_delim())
+
+    def test_re_source(self) :
+        for i in ["test", "test2", "test3"] :
+            self.db.set_re_source(i)
+            self.assertEqual(i, self.db.get_re_source())
+
+class DB_queue(DB) :
+    def test_re_len(self) :
+        for i in [33, 65, 300, 2000] :
+            self.db.set_re_len(i)
+            self.assertEqual(i, self.db.get_re_len())
+
+    def test_q_extentsize(self) :
+        for i in [1, 60, 100] :
+            self.db.set_q_extentsize(i)
+            self.assertEqual(i, self.db.get_q_extentsize())
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(DB_general))
+    suite.addTest(unittest.makeSuite(DB_txn))
+    suite.addTest(unittest.makeSuite(DB_hash))
+    suite.addTest(unittest.makeSuite(DB_recno))
+    suite.addTest(unittest.makeSuite(DB_queue))
+
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_dbenv.py b/lib/python2.7/bsddb/test/test_dbenv.py
new file mode 100644
index 0000000..76ef7db
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_dbenv.py
@@ -0,0 +1,525 @@
+import unittest
+import os, glob
+
+from test_all import db, test_support, get_new_environment_path, \
+        get_new_database_path
+
+#----------------------------------------------------------------------
+
+class DBEnv(unittest.TestCase):
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+
+    def tearDown(self):
+        self.env.close()
+        del self.env
+        test_support.rmtree(self.homeDir)
+
+class DBEnv_general(DBEnv) :
+    def test_get_open_flags(self) :
+        flags = db.DB_CREATE | db.DB_INIT_MPOOL
+        self.env.open(self.homeDir, flags)
+        self.assertEqual(flags, self.env.get_open_flags())
+
+    def test_get_open_flags2(self) :
+        flags = db.DB_CREATE | db.DB_INIT_MPOOL | \
+                db.DB_INIT_LOCK | db.DB_THREAD
+        self.env.open(self.homeDir, flags)
+        self.assertEqual(flags, self.env.get_open_flags())
+
+    if db.version() >= (4, 7) :
+        def test_lk_partitions(self) :
+            for i in [10, 20, 40] :
+                self.env.set_lk_partitions(i)
+                self.assertEqual(i, self.env.get_lk_partitions())
+
+        def test_getset_intermediate_dir_mode(self) :
+            self.assertEqual(None, self.env.get_intermediate_dir_mode())
+            for mode in ["rwx------", "rw-rw-rw-", "rw-r--r--"] :
+                self.env.set_intermediate_dir_mode(mode)
+                self.assertEqual(mode, self.env.get_intermediate_dir_mode())
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.set_intermediate_dir_mode, "abcde")
+
+    if db.version() >= (4, 6) :
+        def test_thread(self) :
+            for i in [16, 100, 1000] :
+                self.env.set_thread_count(i)
+                self.assertEqual(i, self.env.get_thread_count())
+
+        def test_cache_max(self) :
+            for size in [64, 128] :
+                size = size*1024*1024  # Megabytes
+                self.env.set_cache_max(0, size)
+                size2 = self.env.get_cache_max()
+                self.assertEqual(0, size2[0])
+                self.assertTrue(size <= size2[1])
+                self.assertTrue(2*size > size2[1])
+
+    if db.version() >= (4, 4) :
+        def test_mutex_stat(self) :
+            self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+                    db.DB_INIT_LOCK)
+            stat = self.env.mutex_stat()
+            self.assertTrue("mutex_inuse_max" in stat)
+
+        def test_lg_filemode(self) :
+            for i in [0600, 0660, 0666] :
+                self.env.set_lg_filemode(i)
+                self.assertEqual(i, self.env.get_lg_filemode())
+
+    def test_mp_max_openfd(self) :
+        for i in [17, 31, 42] :
+            self.env.set_mp_max_openfd(i)
+            self.assertEqual(i, self.env.get_mp_max_openfd())
+
+    def test_mp_max_write(self) :
+        for i in [100, 200, 300] :
+            for j in [1, 2, 3] :
+                j *= 1000000
+                self.env.set_mp_max_write(i, j)
+                v=self.env.get_mp_max_write()
+                self.assertEqual((i, j), v)
+
+        def test_invalid_txn(self) :
+            # This environment doesn't support transactions
+            self.assertRaises(db.DBInvalidArgError, self.env.txn_begin)
+
+        def test_mp_mmapsize(self) :
+            for i in [16, 32, 64] :
+                i *= 1024*1024
+                self.env.set_mp_mmapsize(i)
+                self.assertEqual(i, self.env.get_mp_mmapsize())
+
+        def test_tmp_dir(self) :
+            for i in ["a", "bb", "ccc"] :
+                self.env.set_tmp_dir(i)
+                self.assertEqual(i, self.env.get_tmp_dir())
+
+        def test_flags(self) :
+            self.env.set_flags(db.DB_AUTO_COMMIT, 1)
+            self.assertEqual(db.DB_AUTO_COMMIT, self.env.get_flags())
+            self.env.set_flags(db.DB_TXN_NOSYNC, 1)
+            self.assertEqual(db.DB_AUTO_COMMIT | db.DB_TXN_NOSYNC,
+                    self.env.get_flags())
+            self.env.set_flags(db.DB_AUTO_COMMIT, 0)
+            self.assertEqual(db.DB_TXN_NOSYNC, self.env.get_flags())
+            self.env.set_flags(db.DB_TXN_NOSYNC, 0)
+            self.assertEqual(0, self.env.get_flags())
+
+        def test_lk_max_objects(self) :
+            for i in [1000, 2000, 3000] :
+                self.env.set_lk_max_objects(i)
+                self.assertEqual(i, self.env.get_lk_max_objects())
+
+        def test_lk_max_locks(self) :
+            for i in [1000, 2000, 3000] :
+                self.env.set_lk_max_locks(i)
+                self.assertEqual(i, self.env.get_lk_max_locks())
+
+        def test_lk_max_lockers(self) :
+            for i in [1000, 2000, 3000] :
+                self.env.set_lk_max_lockers(i)
+                self.assertEqual(i, self.env.get_lk_max_lockers())
+
+        def test_lg_regionmax(self) :
+            for i in [128, 256, 1000] :
+                i = i*1024*1024
+                self.env.set_lg_regionmax(i)
+                j = self.env.get_lg_regionmax()
+                self.assertTrue(i <= j)
+                self.assertTrue(2*i > j)
+
+        def test_lk_detect(self) :
+            flags= [db.DB_LOCK_DEFAULT, db.DB_LOCK_EXPIRE, db.DB_LOCK_MAXLOCKS,
+                    db.DB_LOCK_MINLOCKS, db.DB_LOCK_MINWRITE,
+                    db.DB_LOCK_OLDEST, db.DB_LOCK_RANDOM, db.DB_LOCK_YOUNGEST]
+
+            flags.append(db.DB_LOCK_MAXWRITE)
+
+            for i in flags :
+                self.env.set_lk_detect(i)
+                self.assertEqual(i, self.env.get_lk_detect())
+
+        def test_lg_dir(self) :
+            for i in ["a", "bb", "ccc", "dddd"] :
+                self.env.set_lg_dir(i)
+                self.assertEqual(i, self.env.get_lg_dir())
+
+        def test_lg_bsize(self) :
+            log_size = 70*1024
+            self.env.set_lg_bsize(log_size)
+            self.assertTrue(self.env.get_lg_bsize() >= log_size)
+            self.assertTrue(self.env.get_lg_bsize() < 4*log_size)
+            self.env.set_lg_bsize(4*log_size)
+            self.assertTrue(self.env.get_lg_bsize() >= 4*log_size)
+
+        def test_setget_data_dirs(self) :
+            dirs = ("a", "b", "c", "d")
+            for i in dirs :
+                self.env.set_data_dir(i)
+            self.assertEqual(dirs, self.env.get_data_dirs())
+
+        def test_setget_cachesize(self) :
+            cachesize = (0, 512*1024*1024, 3)
+            self.env.set_cachesize(*cachesize)
+            self.assertEqual(cachesize, self.env.get_cachesize())
+
+            cachesize = (0, 1*1024*1024, 5)
+            self.env.set_cachesize(*cachesize)
+            cachesize2 = self.env.get_cachesize()
+            self.assertEqual(cachesize[0], cachesize2[0])
+            self.assertEqual(cachesize[2], cachesize2[2])
+            # Berkeley DB expands the cache 25% accounting overhead,
+            # if the cache is small.
+            self.assertEqual(125, int(100.0*cachesize2[1]/cachesize[1]))
+
+            # You can not change configuration after opening
+            # the environment.
+            self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+            cachesize = (0, 2*1024*1024, 1)
+            self.assertRaises(db.DBInvalidArgError,
+                              self.env.set_cachesize, *cachesize)
+            cachesize3 = self.env.get_cachesize()
+            self.assertEqual(cachesize2[0], cachesize3[0])
+            self.assertEqual(cachesize2[2], cachesize3[2])
+            # In Berkeley DB 5.1, the cachesize can change when opening the Env
+            self.assertTrue(cachesize2[1] <= cachesize3[1])
+
+        def test_set_cachesize_dbenv_db(self) :
+            # You can not configure the cachesize using
+            # the database handle, if you are using an environment.
+            d = db.DB(self.env)
+            self.assertRaises(db.DBInvalidArgError,
+                d.set_cachesize, 0, 1024*1024, 1)
+
+        def test_setget_shm_key(self) :
+            shm_key=137
+            self.env.set_shm_key(shm_key)
+            self.assertEqual(shm_key, self.env.get_shm_key())
+            self.env.set_shm_key(shm_key+1)
+            self.assertEqual(shm_key+1, self.env.get_shm_key())
+
+            # You can not change configuration after opening
+            # the environment.
+            self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+            # If we try to reconfigure cache after opening the
+            # environment, core dump.
+            self.assertRaises(db.DBInvalidArgError,
+                self.env.set_shm_key, shm_key)
+            self.assertEqual(shm_key+1, self.env.get_shm_key())
+
+    if db.version() >= (4, 4) :
+        def test_mutex_setget_max(self) :
+            v = self.env.mutex_get_max()
+            v2 = v*2+1
+
+            self.env.mutex_set_max(v2)
+            self.assertEqual(v2, self.env.mutex_get_max())
+
+            self.env.mutex_set_max(v)
+            self.assertEqual(v, self.env.mutex_get_max())
+
+            # You can not change configuration after opening
+            # the environment.
+            self.env.open(self.homeDir, db.DB_CREATE)
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.mutex_set_max, v2)
+
+        def test_mutex_setget_increment(self) :
+            v = self.env.mutex_get_increment()
+            v2 = 127
+
+            self.env.mutex_set_increment(v2)
+            self.assertEqual(v2, self.env.mutex_get_increment())
+
+            self.env.mutex_set_increment(v)
+            self.assertEqual(v, self.env.mutex_get_increment())
+
+            # You can not change configuration after opening
+            # the environment.
+            self.env.open(self.homeDir, db.DB_CREATE)
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.mutex_set_increment, v2)
+
+        def test_mutex_setget_tas_spins(self) :
+            self.env.mutex_set_tas_spins(0)  # Default = BDB decides
+            v = self.env.mutex_get_tas_spins()
+            v2 = v*2+1
+
+            self.env.mutex_set_tas_spins(v2)
+            self.assertEqual(v2, self.env.mutex_get_tas_spins())
+
+            self.env.mutex_set_tas_spins(v)
+            self.assertEqual(v, self.env.mutex_get_tas_spins())
+
+            # In this case, you can change configuration
+            # after opening the environment.
+            self.env.open(self.homeDir, db.DB_CREATE)
+            self.env.mutex_set_tas_spins(v2)
+
+        def test_mutex_setget_align(self) :
+            v = self.env.mutex_get_align()
+            v2 = 64
+            if v == 64 :
+                v2 = 128
+
+            self.env.mutex_set_align(v2)
+            self.assertEqual(v2, self.env.mutex_get_align())
+
+            # Requires a nonzero power of two
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.mutex_set_align, 0)
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.mutex_set_align, 17)
+
+            self.env.mutex_set_align(2*v2)
+            self.assertEqual(2*v2, self.env.mutex_get_align())
+
+            # You can not change configuration after opening
+            # the environment.
+            self.env.open(self.homeDir, db.DB_CREATE)
+            self.assertRaises(db.DBInvalidArgError,
+                    self.env.mutex_set_align, v2)
+
+
+class DBEnv_log(DBEnv) :
+    def setUp(self):
+        DBEnv.setUp(self)
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOG)
+
+    def test_log_file(self) :
+        log_file = self.env.log_file((1, 1))
+        self.assertEqual("log.0000000001", log_file[-14:])
+
+    if db.version() >= (4, 4) :
+        # The version with transactions is checked in other test object
+        def test_log_printf(self) :
+            msg = "This is a test..."
+            self.env.log_printf(msg)
+            logc = self.env.log_cursor()
+            self.assertTrue(msg in (logc.last()[1]))
+
+    if db.version() >= (4, 7) :
+        def test_log_config(self) :
+            self.env.log_set_config(db.DB_LOG_DSYNC | db.DB_LOG_ZERO, 1)
+            self.assertTrue(self.env.log_get_config(db.DB_LOG_DSYNC))
+            self.assertTrue(self.env.log_get_config(db.DB_LOG_ZERO))
+            self.env.log_set_config(db.DB_LOG_ZERO, 0)
+            self.assertTrue(self.env.log_get_config(db.DB_LOG_DSYNC))
+            self.assertFalse(self.env.log_get_config(db.DB_LOG_ZERO))
+
+
+class DBEnv_log_txn(DBEnv) :
+    def setUp(self):
+        DBEnv.setUp(self)
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+                db.DB_INIT_LOG | db.DB_INIT_TXN)
+
+    if (db.version() >= (4, 5)) and (db.version() < (5, 2)) :
+        def test_tx_max(self) :
+            txns=[]
+            def tx() :
+                for i in xrange(self.env.get_tx_max()) :
+                    txns.append(self.env.txn_begin())
+
+            tx()
+            self.assertRaises(MemoryError, tx)
+
+            # Abort the transactions before garbage collection,
+            # to avoid "warnings".
+            for i in txns :
+                i.abort()
+
+    if db.version() >= (4, 4) :
+        # The version without transactions is checked in other test object
+        def test_log_printf(self) :
+            msg = "This is a test..."
+            txn = self.env.txn_begin()
+            self.env.log_printf(msg, txn=txn)
+            txn.commit()
+            logc = self.env.log_cursor()
+            logc.last()  # Skip the commit
+            self.assertTrue(msg in (logc.prev()[1]))
+
+            msg = "This is another test..."
+            txn = self.env.txn_begin()
+            self.env.log_printf(msg, txn=txn)
+            txn.abort()  # Do not store the new message
+            logc.last()  # Skip the abort
+            self.assertTrue(msg not in (logc.prev()[1]))
+
+            msg = "This is a third test..."
+            txn = self.env.txn_begin()
+            self.env.log_printf(msg, txn=txn)
+            txn.commit()  # Do not store the new message
+            logc.last()  # Skip the commit
+            self.assertTrue(msg in (logc.prev()[1]))
+
+
+class DBEnv_memp(DBEnv):
+    def setUp(self):
+        DBEnv.setUp(self)
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOG)
+        self.db = db.DB(self.env)
+        self.db.open("test", db.DB_HASH, db.DB_CREATE, 0660)
+
+    def tearDown(self):
+        self.db.close()
+        del self.db
+        DBEnv.tearDown(self)
+
+    def test_memp_1_trickle(self) :
+        self.db.put("hi", "bye")
+        self.assertTrue(self.env.memp_trickle(100) > 0)
+
+# Preserve the order, do "memp_trickle" test first
+    def test_memp_2_sync(self) :
+        self.db.put("hi", "bye")
+        self.env.memp_sync()  # Full flush
+        # Nothing to do...
+        self.assertTrue(self.env.memp_trickle(100) == 0)
+
+        self.db.put("hi", "bye2")
+        self.env.memp_sync((1, 0))  # NOP, probably
+        # Something to do... or not
+        self.assertTrue(self.env.memp_trickle(100) >= 0)
+
+        self.db.put("hi", "bye3")
+        self.env.memp_sync((123, 99))  # Full flush
+        # Nothing to do...
+        self.assertTrue(self.env.memp_trickle(100) == 0)
+
+    def test_memp_stat_1(self) :
+        stats = self.env.memp_stat()  # No param
+        self.assertTrue(len(stats)==2)
+        self.assertTrue("cache_miss" in stats[0])
+        stats = self.env.memp_stat(db.DB_STAT_CLEAR)  # Positional param
+        self.assertTrue("cache_miss" in stats[0])
+        stats = self.env.memp_stat(flags=0)  # Keyword param
+        self.assertTrue("cache_miss" in stats[0])
+
+    def test_memp_stat_2(self) :
+        stats=self.env.memp_stat()[1]
+        self.assertTrue(len(stats))==1
+        self.assertTrue("test" in stats)
+        self.assertTrue("page_in" in stats["test"])
+
+class DBEnv_logcursor(DBEnv):
+    def setUp(self):
+        DBEnv.setUp(self)
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
+                db.DB_INIT_LOG | db.DB_INIT_TXN)
+        txn = self.env.txn_begin()
+        self.db = db.DB(self.env)
+        self.db.open("test", db.DB_HASH, db.DB_CREATE, 0660, txn=txn)
+        txn.commit()
+        for i in ["2", "8", "20"] :
+            txn = self.env.txn_begin()
+            self.db.put(key = i, data = i*int(i), txn=txn)
+            txn.commit()
+
+    def tearDown(self):
+        self.db.close()
+        del self.db
+        DBEnv.tearDown(self)
+
+    def _check_return(self, value) :
+        self.assertTrue(isinstance(value, tuple))
+        self.assertEqual(len(value), 2)
+        self.assertTrue(isinstance(value[0], tuple))
+        self.assertEqual(len(value[0]), 2)
+        self.assertTrue(isinstance(value[0][0], int))
+        self.assertTrue(isinstance(value[0][1], int))
+        self.assertTrue(isinstance(value[1], str))
+
+    # Preserve test order
+    def test_1_first(self) :
+        logc = self.env.log_cursor()
+        v = logc.first()
+        self._check_return(v)
+        self.assertTrue((1, 1) < v[0])
+        self.assertTrue(len(v[1])>0)
+
+    def test_2_last(self) :
+        logc = self.env.log_cursor()
+        lsn_first = logc.first()[0]
+        v = logc.last()
+        self._check_return(v)
+        self.assertTrue(lsn_first < v[0])
+
+    def test_3_next(self) :
+        logc = self.env.log_cursor()
+        lsn_last = logc.last()[0]
+        self.assertEqual(logc.next(), None)
+        lsn_first = logc.first()[0]
+        v = logc.next()
+        self._check_return(v)
+        self.assertTrue(lsn_first < v[0])
+        self.assertTrue(lsn_last > v[0])
+
+        v2 = logc.next()
+        self.assertTrue(v2[0] > v[0])
+        self.assertTrue(lsn_last > v2[0])
+
+        v3 = logc.next()
+        self.assertTrue(v3[0] > v2[0])
+        self.assertTrue(lsn_last > v3[0])
+
+    def test_4_prev(self) :
+        logc = self.env.log_cursor()
+        lsn_first = logc.first()[0]
+        self.assertEqual(logc.prev(), None)
+        lsn_last = logc.last()[0]
+        v = logc.prev()
+        self._check_return(v)
+        self.assertTrue(lsn_first < v[0])
+        self.assertTrue(lsn_last > v[0])
+
+        v2 = logc.prev()
+        self.assertTrue(v2[0] < v[0])
+        self.assertTrue(lsn_first < v2[0])
+
+        v3 = logc.prev()
+        self.assertTrue(v3[0] < v2[0])
+        self.assertTrue(lsn_first < v3[0])
+
+    def test_5_current(self) :
+        logc = self.env.log_cursor()
+        logc.first()
+        v = logc.next()
+        self.assertEqual(v, logc.current())
+
+    def test_6_set(self) :
+        logc = self.env.log_cursor()
+        logc.first()
+        v = logc.next()
+        self.assertNotEqual(v, logc.next())
+        self.assertNotEqual(v, logc.next())
+        self.assertEqual(v, logc.set(v[0]))
+
+    def test_explicit_close(self) :
+        logc = self.env.log_cursor()
+        logc.close()
+        self.assertRaises(db.DBCursorClosedError, logc.next)
+
+    def test_implicit_close(self) :
+        logc =  [self.env.log_cursor() for i in xrange(10)]
+        self.env.close()  # This close should close too all its tree
+        for i in logc :
+            self.assertRaises(db.DBCursorClosedError, i.next)
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(DBEnv_general))
+    suite.addTest(unittest.makeSuite(DBEnv_memp))
+    suite.addTest(unittest.makeSuite(DBEnv_logcursor))
+    suite.addTest(unittest.makeSuite(DBEnv_log))
+    suite.addTest(unittest.makeSuite(DBEnv_log_txn))
+
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_dbobj.py b/lib/python2.7/bsddb/test/test_dbobj.py
new file mode 100644
index 0000000..e301a5a
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_dbobj.py
@@ -0,0 +1,70 @@
+
+import os, string
+import unittest
+
+from test_all import db, dbobj, test_support, get_new_environment_path, \
+        get_new_database_path
+
+#----------------------------------------------------------------------
+
+class dbobjTestCase(unittest.TestCase):
+    """Verify that dbobj.DB and dbobj.DBEnv work properly"""
+    db_name = 'test-dbobj.db'
+
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+
+    def tearDown(self):
+        if hasattr(self, 'db'):
+            del self.db
+        if hasattr(self, 'env'):
+            del self.env
+        test_support.rmtree(self.homeDir)
+
+    def test01_both(self):
+        class TestDBEnv(dbobj.DBEnv): pass
+        class TestDB(dbobj.DB):
+            def put(self, key, *args, **kwargs):
+                key = key.upper()
+                # call our parent classes put method with an upper case key
+                return dbobj.DB.put(self, key, *args, **kwargs)
+        self.env = TestDBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+        self.db = TestDB(self.env)
+        self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
+        self.db.put('spam', 'eggs')
+        self.assertEqual(self.db.get('spam'), None,
+               "overridden dbobj.DB.put() method failed [1]")
+        self.assertEqual(self.db.get('SPAM'), 'eggs',
+               "overridden dbobj.DB.put() method failed [2]")
+        self.db.close()
+        self.env.close()
+
+    def test02_dbobj_dict_interface(self):
+        self.env = dbobj.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+        self.db = dbobj.DB(self.env)
+        self.db.open(self.db_name+'02', db.DB_HASH, db.DB_CREATE)
+        # __setitem__
+        self.db['spam'] = 'eggs'
+        # __len__
+        self.assertEqual(len(self.db), 1)
+        # __getitem__
+        self.assertEqual(self.db['spam'], 'eggs')
+        # __del__
+        del self.db['spam']
+        self.assertEqual(self.db.get('spam'), None, "dbobj __del__ failed")
+        self.db.close()
+        self.env.close()
+
+    def test03_dbobj_type_before_open(self):
+        # Ensure this doesn't cause a segfault.
+        self.assertRaises(db.DBInvalidArgError, db.DB().type)
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    return unittest.makeSuite(dbobjTestCase)
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_dbshelve.py b/lib/python2.7/bsddb/test/test_dbshelve.py
new file mode 100644
index 0000000..c3701e1
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_dbshelve.py
@@ -0,0 +1,398 @@
+"""
+TestCases for checking dbShelve objects.
+"""
+
+import os, string, sys
+import random
+import unittest
+
+
+from test_all import db, dbshelve, test_support, verbose, \
+        get_new_environment_path, get_new_database_path
+
+
+
+
+
+#----------------------------------------------------------------------
+
+# We want the objects to be comparable so we can test dbshelve.values
+# later on.
+class DataClass:
+    def __init__(self):
+        self.value = random.random()
+
+    def __repr__(self) :  # For Python 3.0 comparison
+        return "DataClass %f" %self.value
+
+    def __cmp__(self, other):  # For Python 2.x comparison
+        return cmp(self.value, other)
+
+
+class DBShelveTestCase(unittest.TestCase):
+    if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
+            (sys.version_info < (3, 2))) :
+        def assertIn(self, a, b, msg=None) :
+            return self.assertTrue(a in b, msg=msg)
+
+
+    def setUp(self):
+        if sys.version_info[0] >= 3 :
+            from test_all import do_proxy_db_py3k
+            self._flag_proxy_db_py3k = do_proxy_db_py3k(False)
+        self.filename = get_new_database_path()
+        self.do_open()
+
+    def tearDown(self):
+        if sys.version_info[0] >= 3 :
+            from test_all import do_proxy_db_py3k
+            do_proxy_db_py3k(self._flag_proxy_db_py3k)
+        self.do_close()
+        test_support.unlink(self.filename)
+
+    def mk(self, key):
+        """Turn key into an appropriate key type for this db"""
+        # override in child class for RECNO
+        if sys.version_info[0] < 3 :
+            return key
+        else :
+            return bytes(key, "iso8859-1")  # 8 bits
+
+    def populateDB(self, d):
+        for x in string.letters:
+            d[self.mk('S' + x)] = 10 * x           # add a string
+            d[self.mk('I' + x)] = ord(x)           # add an integer
+            d[self.mk('L' + x)] = [x] * 10         # add a list
+
+            inst = DataClass()            # add an instance
+            inst.S = 10 * x
+            inst.I = ord(x)
+            inst.L = [x] * 10
+            d[self.mk('O' + x)] = inst
+
+
+    # overridable in derived classes to affect how the shelf is created/opened
+    def do_open(self):
+        self.d = dbshelve.open(self.filename)
+
+    # and closed...
+    def do_close(self):
+        self.d.close()
+
+
+
+    def test01_basics(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_basics..." % self.__class__.__name__
+
+        self.populateDB(self.d)
+        self.d.sync()
+        self.do_close()
+        self.do_open()
+        d = self.d
+
+        l = len(d)
+        k = d.keys()
+        s = d.stat()
+        f = d.fd()
+
+        if verbose:
+            print "length:", l
+            print "keys:", k
+            print "stats:", s
+
+        self.assertEqual(0, d.has_key(self.mk('bad key')))
+        self.assertEqual(1, d.has_key(self.mk('IA')))
+        self.assertEqual(1, d.has_key(self.mk('OA')))
+
+        d.delete(self.mk('IA'))
+        del d[self.mk('OA')]
+        self.assertEqual(0, d.has_key(self.mk('IA')))
+        self.assertEqual(0, d.has_key(self.mk('OA')))
+        self.assertEqual(len(d), l-2)
+
+        values = []
+        for key in d.keys():
+            value = d[key]
+            values.append(value)
+            if verbose:
+                print "%s: %s" % (key, value)
+            self.checkrec(key, value)
+
+        dbvalues = d.values()
+        self.assertEqual(len(dbvalues), len(d.keys()))
+        if sys.version_info < (2, 6) :
+            values.sort()
+            dbvalues.sort()
+            self.assertEqual(values, dbvalues)
+        else :  # XXX: Convert all to strings. Please, improve
+            values.sort(key=lambda x : str(x))
+            dbvalues.sort(key=lambda x : str(x))
+            self.assertEqual(repr(values), repr(dbvalues))
+
+        items = d.items()
+        self.assertEqual(len(items), len(values))
+
+        for key, value in items:
+            self.checkrec(key, value)
+
+        self.assertEqual(d.get(self.mk('bad key')), None)
+        self.assertEqual(d.get(self.mk('bad key'), None), None)
+        self.assertEqual(d.get(self.mk('bad key'), 'a string'), 'a string')
+        self.assertEqual(d.get(self.mk('bad key'), [1, 2, 3]), [1, 2, 3])
+
+        d.set_get_returns_none(0)
+        self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
+        d.set_get_returns_none(1)
+
+        d.put(self.mk('new key'), 'new data')
+        self.assertEqual(d.get(self.mk('new key')), 'new data')
+        self.assertEqual(d[self.mk('new key')], 'new data')
+
+
+
+    def test02_cursors(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_cursors..." % self.__class__.__name__
+
+        self.populateDB(self.d)
+        d = self.d
+
+        count = 0
+        c = d.cursor()
+        rec = c.first()
+        while rec is not None:
+            count = count + 1
+            if verbose:
+                print rec
+            key, value = rec
+            self.checkrec(key, value)
+            # Hack to avoid conversion by 2to3 tool
+            rec = getattr(c, "next")()
+        del c
+
+        self.assertEqual(count, len(d))
+
+        count = 0
+        c = d.cursor()
+        rec = c.last()
+        while rec is not None:
+            count = count + 1
+            if verbose:
+                print rec
+            key, value = rec
+            self.checkrec(key, value)
+            rec = c.prev()
+
+        self.assertEqual(count, len(d))
+
+        c.set(self.mk('SS'))
+        key, value = c.current()
+        self.checkrec(key, value)
+        del c
+
+
+    def test03_append(self):
+        # NOTE: this is overridden in RECNO subclass, don't change its name.
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_append..." % self.__class__.__name__
+
+        self.assertRaises(dbshelve.DBShelveError,
+                          self.d.append, 'unit test was here')
+
+
+    def test04_iterable(self) :
+        self.populateDB(self.d)
+        d = self.d
+        keys = d.keys()
+        keyset = set(keys)
+        self.assertEqual(len(keyset), len(keys))
+
+        for key in d :
+            self.assertIn(key, keyset)
+            keyset.remove(key)
+        self.assertEqual(len(keyset), 0)
+
+    def checkrec(self, key, value):
+        # override this in a subclass if the key type is different
+
+        if sys.version_info[0] >= 3 :
+            if isinstance(key, bytes) :
+                key = key.decode("iso8859-1")  # 8 bits
+
+        x = key[1]
+        if key[0] == 'S':
+            self.assertEqual(type(value), str)
+            self.assertEqual(value, 10 * x)
+
+        elif key[0] == 'I':
+            self.assertEqual(type(value), int)
+            self.assertEqual(value, ord(x))
+
+        elif key[0] == 'L':
+            self.assertEqual(type(value), list)
+            self.assertEqual(value, [x] * 10)
+
+        elif key[0] == 'O':
+            if sys.version_info[0] < 3 :
+                from types import InstanceType
+                self.assertEqual(type(value), InstanceType)
+            else :
+                self.assertEqual(type(value), DataClass)
+
+            self.assertEqual(value.S, 10 * x)
+            self.assertEqual(value.I, ord(x))
+            self.assertEqual(value.L, [x] * 10)
+
+        else:
+            self.assertTrue(0, 'Unknown key type, fix the test')
+
+#----------------------------------------------------------------------
+
+class BasicShelveTestCase(DBShelveTestCase):
+    def do_open(self):
+        self.d = dbshelve.DBShelf()
+        self.d.open(self.filename, self.dbtype, self.dbflags)
+
+    def do_close(self):
+        self.d.close()
+
+
+class BTreeShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_BTREE
+    dbflags = db.DB_CREATE
+
+
+class HashShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_HASH
+    dbflags = db.DB_CREATE
+
+
+class ThreadBTreeShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_BTREE
+    dbflags = db.DB_CREATE | db.DB_THREAD
+
+
+class ThreadHashShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_HASH
+    dbflags = db.DB_CREATE | db.DB_THREAD
+
+
+#----------------------------------------------------------------------
+
+class BasicEnvShelveTestCase(DBShelveTestCase):
+    def do_open(self):
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir,
+                self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
+
+        self.filename = os.path.split(self.filename)[1]
+        self.d = dbshelve.DBShelf(self.env)
+        self.d.open(self.filename, self.dbtype, self.dbflags)
+
+
+    def do_close(self):
+        self.d.close()
+        self.env.close()
+
+
+    def setUp(self) :
+        self.homeDir = get_new_environment_path()
+        DBShelveTestCase.setUp(self)
+
+    def tearDown(self):
+        if sys.version_info[0] >= 3 :
+            from test_all import do_proxy_db_py3k
+            do_proxy_db_py3k(self._flag_proxy_db_py3k)
+        self.do_close()
+        test_support.rmtree(self.homeDir)
+
+
+class EnvBTreeShelveTestCase(BasicEnvShelveTestCase):
+    envflags = 0
+    dbtype = db.DB_BTREE
+    dbflags = db.DB_CREATE
+
+
+class EnvHashShelveTestCase(BasicEnvShelveTestCase):
+    envflags = 0
+    dbtype = db.DB_HASH
+    dbflags = db.DB_CREATE
+
+
+class EnvThreadBTreeShelveTestCase(BasicEnvShelveTestCase):
+    envflags = db.DB_THREAD
+    dbtype = db.DB_BTREE
+    dbflags = db.DB_CREATE | db.DB_THREAD
+
+
+class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
+    envflags = db.DB_THREAD
+    dbtype = db.DB_HASH
+    dbflags = db.DB_CREATE | db.DB_THREAD
+
+
+#----------------------------------------------------------------------
+# test cases for a DBShelf in a RECNO DB.
+
+class RecNoShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_RECNO
+    dbflags = db.DB_CREATE
+
+    def setUp(self):
+        BasicShelveTestCase.setUp(self)
+
+        # pool to assign integer key values out of
+        self.key_pool = list(range(1, 5000))
+        self.key_map = {}     # map string keys to the number we gave them
+        self.intkey_map = {}  # reverse map of above
+
+    def mk(self, key):
+        if key not in self.key_map:
+            self.key_map[key] = self.key_pool.pop(0)
+            self.intkey_map[self.key_map[key]] = key
+        return self.key_map[key]
+
+    def checkrec(self, intkey, value):
+        key = self.intkey_map[intkey]
+        BasicShelveTestCase.checkrec(self, key, value)
+
+    def test03_append(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_append..." % self.__class__.__name__
+
+        self.d[1] = 'spam'
+        self.d[5] = 'eggs'
+        self.assertEqual(6, self.d.append('spam'))
+        self.assertEqual(7, self.d.append('baked beans'))
+        self.assertEqual('spam', self.d.get(6))
+        self.assertEqual('spam', self.d.get(1))
+        self.assertEqual('baked beans', self.d.get(7))
+        self.assertEqual('eggs', self.d.get(5))
+
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(DBShelveTestCase))
+    suite.addTest(unittest.makeSuite(BTreeShelveTestCase))
+    suite.addTest(unittest.makeSuite(HashShelveTestCase))
+    suite.addTest(unittest.makeSuite(ThreadBTreeShelveTestCase))
+    suite.addTest(unittest.makeSuite(ThreadHashShelveTestCase))
+    suite.addTest(unittest.makeSuite(EnvBTreeShelveTestCase))
+    suite.addTest(unittest.makeSuite(EnvHashShelveTestCase))
+    suite.addTest(unittest.makeSuite(EnvThreadBTreeShelveTestCase))
+    suite.addTest(unittest.makeSuite(EnvThreadHashShelveTestCase))
+    suite.addTest(unittest.makeSuite(RecNoShelveTestCase))
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_dbtables.py b/lib/python2.7/bsddb/test/test_dbtables.py
new file mode 100644
index 0000000..bb31381
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_dbtables.py
@@ -0,0 +1,409 @@
+#!/usr/bin/env python
+#
+#-----------------------------------------------------------------------
+# A test suite for the table interface built on bsddb.db
+#-----------------------------------------------------------------------
+#
+# Copyright (C) 2000, 2001 by Autonomous Zone Industries
+# Copyright (C) 2002 Gregory P. Smith
+#
+# March 20, 2000
+#
+# License:      This is free software.  You may use this software for any
+#               purpose including modification/redistribution, so long as
+#               this header remains intact and that you do not claim any
+#               rights of ownership or authorship of this software.  This
+#               software has been tested, but no warranty is expressed or
+#               implied.
+#
+#   --  Gregory P. Smith <greg@krypto.org>
+#
+# $Id$
+
+import os, re, sys
+
+if sys.version_info[0] < 3 :
+    try:
+        import cPickle
+        pickle = cPickle
+    except ImportError:
+        import pickle
+else :
+    import pickle
+
+import unittest
+from test_all import db, dbtables, test_support, verbose, \
+        get_new_environment_path, get_new_database_path
+
+#----------------------------------------------------------------------
+
+class TableDBTestCase(unittest.TestCase):
+    db_name = 'test-table.db'
+
+    def setUp(self):
+        import sys
+        if sys.version_info[0] >= 3 :
+            from test_all import do_proxy_db_py3k
+            self._flag_proxy_db_py3k = do_proxy_db_py3k(False)
+
+        self.testHomeDir = get_new_environment_path()
+        self.tdb = dbtables.bsdTableDB(
+            filename='tabletest.db', dbhome=self.testHomeDir, create=1)
+
+    def tearDown(self):
+        self.tdb.close()
+        import sys
+        if sys.version_info[0] >= 3 :
+            from test_all import do_proxy_db_py3k
+            do_proxy_db_py3k(self._flag_proxy_db_py3k)
+        test_support.rmtree(self.testHomeDir)
+
+    def test01(self):
+        tabname = "test01"
+        colname = 'cool numbers'
+        try:
+            self.tdb.Drop(tabname)
+        except dbtables.TableDBError:
+            pass
+        self.tdb.CreateTable(tabname, [colname])
+        import sys
+        if sys.version_info[0] < 3 :
+            self.tdb.Insert(tabname, {colname: pickle.dumps(3.14159, 1)})
+        else :
+            self.tdb.Insert(tabname, {colname: pickle.dumps(3.14159,
+                1).decode("iso8859-1")})  # 8 bits
+
+        if verbose:
+            self.tdb._db_print()
+
+        values = self.tdb.Select(
+            tabname, [colname], conditions={colname: None})
+
+        import sys
+        if sys.version_info[0] < 3 :
+            colval = pickle.loads(values[0][colname])
+        else :
+            colval = pickle.loads(bytes(values[0][colname], "iso8859-1"))
+        self.assertTrue(colval > 3.141)
+        self.assertTrue(colval < 3.142)
+
+
+    def test02(self):
+        tabname = "test02"
+        col0 = 'coolness factor'
+        col1 = 'but can it fly?'
+        col2 = 'Species'
+
+        import sys
+        if sys.version_info[0] < 3 :
+            testinfo = [
+                {col0: pickle.dumps(8, 1), col1: 'no', col2: 'Penguin'},
+                {col0: pickle.dumps(-1, 1), col1: 'no', col2: 'Turkey'},
+                {col0: pickle.dumps(9, 1), col1: 'yes', col2: 'SR-71A Blackbird'}
+            ]
+        else :
+            testinfo = [
+                {col0: pickle.dumps(8, 1).decode("iso8859-1"),
+                    col1: 'no', col2: 'Penguin'},
+                {col0: pickle.dumps(-1, 1).decode("iso8859-1"),
+                    col1: 'no', col2: 'Turkey'},
+                {col0: pickle.dumps(9, 1).decode("iso8859-1"),
+                    col1: 'yes', col2: 'SR-71A Blackbird'}
+            ]
+
+        try:
+            self.tdb.Drop(tabname)
+        except dbtables.TableDBError:
+            pass
+        self.tdb.CreateTable(tabname, [col0, col1, col2])
+        for row in testinfo :
+            self.tdb.Insert(tabname, row)
+
+        import sys
+        if sys.version_info[0] < 3 :
+            values = self.tdb.Select(tabname, [col2],
+                conditions={col0: lambda x: pickle.loads(x) >= 8})
+        else :
+            values = self.tdb.Select(tabname, [col2],
+                conditions={col0: lambda x:
+                    pickle.loads(bytes(x, "iso8859-1")) >= 8})
+
+        self.assertEqual(len(values), 2)
+        if values[0]['Species'] == 'Penguin' :
+            self.assertEqual(values[1]['Species'], 'SR-71A Blackbird')
+        elif values[0]['Species'] == 'SR-71A Blackbird' :
+            self.assertEqual(values[1]['Species'], 'Penguin')
+        else :
+            if verbose:
+                print "values= %r" % (values,)
+            raise RuntimeError("Wrong values returned!")
+
+    def test03(self):
+        tabname = "test03"
+        try:
+            self.tdb.Drop(tabname)
+        except dbtables.TableDBError:
+            pass
+        if verbose:
+            print '...before CreateTable...'
+            self.tdb._db_print()
+        self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
+        if verbose:
+            print '...after CreateTable...'
+            self.tdb._db_print()
+        self.tdb.Drop(tabname)
+        if verbose:
+            print '...after Drop...'
+            self.tdb._db_print()
+        self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
+
+        try:
+            self.tdb.Insert(tabname,
+                            {'a': "",
+                             'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
+                             'f': "Zero"})
+            self.fail('Expected an exception')
+        except dbtables.TableDBError:
+            pass
+
+        try:
+            self.tdb.Select(tabname, [], conditions={'foo': '123'})
+            self.fail('Expected an exception')
+        except dbtables.TableDBError:
+            pass
+
+        self.tdb.Insert(tabname,
+                        {'a': '42',
+                         'b': "bad",
+                         'c': "meep",
+                         'e': 'Fuzzy wuzzy was a bear'})
+        self.tdb.Insert(tabname,
+                        {'a': '581750',
+                         'b': "good",
+                         'd': "bla",
+                         'c': "black",
+                         'e': 'fuzzy was here'})
+        self.tdb.Insert(tabname,
+                        {'a': '800000',
+                         'b': "good",
+                         'd': "bla",
+                         'c': "black",
+                         'e': 'Fuzzy wuzzy is a bear'})
+
+        if verbose:
+            self.tdb._db_print()
+
+        # this should return two rows
+        values = self.tdb.Select(tabname, ['b', 'a', 'd'],
+            conditions={'e': re.compile('wuzzy').search,
+                        'a': re.compile('^[0-9]+$').match})
+        self.assertEqual(len(values), 2)
+
+        # now lets delete one of them and try again
+        self.tdb.Delete(tabname, conditions={'b': dbtables.ExactCond('good')})
+        values = self.tdb.Select(
+            tabname, ['a', 'd', 'b'],
+            conditions={'e': dbtables.PrefixCond('Fuzzy')})
+        self.assertEqual(len(values), 1)
+        self.assertEqual(values[0]['d'], None)
+
+        values = self.tdb.Select(tabname, ['b'],
+            conditions={'c': lambda c: c == 'meep'})
+        self.assertEqual(len(values), 1)
+        self.assertEqual(values[0]['b'], "bad")
+
+
+    def test04_MultiCondSelect(self):
+        tabname = "test04_MultiCondSelect"
+        try:
+            self.tdb.Drop(tabname)
+        except dbtables.TableDBError:
+            pass
+        self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
+
+        try:
+            self.tdb.Insert(tabname,
+                            {'a': "",
+                             'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
+                             'f': "Zero"})
+            self.fail('Expected an exception')
+        except dbtables.TableDBError:
+            pass
+
+        self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D",
+                                  'e': "E"})
+        self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D",
+                                  'e': "-E"})
+        self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-",
+                                  'e': "E-"})
+
+        if verbose:
+            self.tdb._db_print()
+
+        # This select should return 0 rows.  it is designed to test
+        # the bug identified and fixed in sourceforge bug # 590449
+        # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
+        # and supplying a fix!!  This one caused many headaches to say
+        # the least...)
+        values = self.tdb.Select(tabname, ['b', 'a', 'd'],
+            conditions={'e': dbtables.ExactCond('E'),
+                        'a': dbtables.ExactCond('A'),
+                        'd': dbtables.PrefixCond('-')
+                       } )
+        self.assertEqual(len(values), 0, values)
+
+
+    def test_CreateOrExtend(self):
+        tabname = "test_CreateOrExtend"
+
+        self.tdb.CreateOrExtendTable(
+            tabname, ['name', 'taste', 'filling', 'alcohol content', 'price'])
+        try:
+            self.tdb.Insert(tabname,
+                            {'taste': 'crap',
+                             'filling': 'no',
+                             'is it Guinness?': 'no'})
+            self.fail("Insert should've failed due to bad column name")
+        except:
+            pass
+        self.tdb.CreateOrExtendTable(tabname,
+                                     ['name', 'taste', 'is it Guinness?'])
+
+        # these should both succeed as the table should contain the union of both sets of columns.
+        self.tdb.Insert(tabname, {'taste': 'crap', 'filling': 'no',
+                                  'is it Guinness?': 'no'})
+        self.tdb.Insert(tabname, {'taste': 'great', 'filling': 'yes',
+                                  'is it Guinness?': 'yes',
+                                  'name': 'Guinness'})
+
+
+    def test_CondObjs(self):
+        tabname = "test_CondObjs"
+
+        self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e', 'p'])
+
+        self.tdb.Insert(tabname, {'a': "the letter A",
+                                  'b': "the letter B",
+                                  'c': "is for cookie"})
+        self.tdb.Insert(tabname, {'a': "is for aardvark",
+                                  'e': "the letter E",
+                                  'c': "is for cookie",
+                                  'd': "is for dog"})
+        self.tdb.Insert(tabname, {'a': "the letter A",
+                                  'e': "the letter E",
+                                  'c': "is for cookie",
+                                  'p': "is for Python"})
+
+        values = self.tdb.Select(
+            tabname, ['p', 'e'],
+            conditions={'e': dbtables.PrefixCond('the l')})
+        self.assertEqual(len(values), 2, values)
+        self.assertEqual(values[0]['e'], values[1]['e'], values)
+        self.assertNotEqual(values[0]['p'], values[1]['p'], values)
+
+        values = self.tdb.Select(
+            tabname, ['d', 'a'],
+            conditions={'a': dbtables.LikeCond('%aardvark%')})
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['d'], "is for dog", values)
+        self.assertEqual(values[0]['a'], "is for aardvark", values)
+
+        values = self.tdb.Select(tabname, None,
+                                 {'b': dbtables.Cond(),
+                                  'e':dbtables.LikeCond('%letter%'),
+                                  'a':dbtables.PrefixCond('is'),
+                                  'd':dbtables.ExactCond('is for dog'),
+                                  'c':dbtables.PrefixCond('is for'),
+                                  'p':lambda s: not s})
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['d'], "is for dog", values)
+        self.assertEqual(values[0]['a'], "is for aardvark", values)
+
+    def test_Delete(self):
+        tabname = "test_Delete"
+        self.tdb.CreateTable(tabname, ['x', 'y', 'z'])
+
+        # prior to 2001-05-09 there was a bug where Delete() would
+        # fail if it encountered any rows that did not have values in
+        # every column.
+        # Hunted and Squashed by <Donwulff> (Jukka Santala - donwulff@nic.fi)
+        self.tdb.Insert(tabname, {'x': 'X1', 'y':'Y1'})
+        self.tdb.Insert(tabname, {'x': 'X2', 'y':'Y2', 'z': 'Z2'})
+
+        self.tdb.Delete(tabname, conditions={'x': dbtables.PrefixCond('X')})
+        values = self.tdb.Select(tabname, ['y'],
+                                 conditions={'x': dbtables.PrefixCond('X')})
+        self.assertEqual(len(values), 0)
+
+    def test_Modify(self):
+        tabname = "test_Modify"
+        self.tdb.CreateTable(tabname, ['Name', 'Type', 'Access'])
+
+        self.tdb.Insert(tabname, {'Name': 'Index to MP3 files.doc',
+                                  'Type': 'Word', 'Access': '8'})
+        self.tdb.Insert(tabname, {'Name': 'Nifty.MP3', 'Access': '1'})
+        self.tdb.Insert(tabname, {'Type': 'Unknown', 'Access': '0'})
+
+        def set_type(type):
+            if type is None:
+                return 'MP3'
+            return type
+
+        def increment_access(count):
+            return str(int(count)+1)
+
+        def remove_value(value):
+            return None
+
+        self.tdb.Modify(tabname,
+                        conditions={'Access': dbtables.ExactCond('0')},
+                        mappings={'Access': remove_value})
+        self.tdb.Modify(tabname,
+                        conditions={'Name': dbtables.LikeCond('%MP3%')},
+                        mappings={'Type': set_type})
+        self.tdb.Modify(tabname,
+                        conditions={'Name': dbtables.LikeCond('%')},
+                        mappings={'Access': increment_access})
+
+        try:
+            self.tdb.Modify(tabname,
+                            conditions={'Name': dbtables.LikeCond('%')},
+                            mappings={'Access': 'What is your quest?'})
+        except TypeError:
+            # success, the string value in mappings isn't callable
+            pass
+        else:
+            raise RuntimeError, "why was TypeError not raised for bad callable?"
+
+        # Delete key in select conditions
+        values = self.tdb.Select(
+            tabname, None,
+            conditions={'Type': dbtables.ExactCond('Unknown')})
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Name'], None, values)
+        self.assertEqual(values[0]['Access'], None, values)
+
+        # Modify value by select conditions
+        values = self.tdb.Select(
+            tabname, None,
+            conditions={'Name': dbtables.ExactCond('Nifty.MP3')})
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Type'], "MP3", values)
+        self.assertEqual(values[0]['Access'], "2", values)
+
+        # Make sure change applied only to select conditions
+        values = self.tdb.Select(
+            tabname, None, conditions={'Name': dbtables.LikeCond('%doc%')})
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Type'], "Word", values)
+        self.assertEqual(values[0]['Access'], "9", values)
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TableDBTestCase))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_distributed_transactions.py b/lib/python2.7/bsddb/test/test_distributed_transactions.py
new file mode 100644
index 0000000..9058575
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_distributed_transactions.py
@@ -0,0 +1,152 @@
+"""TestCases for distributed transactions.
+"""
+
+import os
+import unittest
+
+from test_all import db, test_support, get_new_environment_path, \
+        get_new_database_path
+
+from test_all import verbose
+
+#----------------------------------------------------------------------
+
+class DBTxn_distributed(unittest.TestCase):
+    num_txns=1234
+    nosync=True
+    must_open_db=False
+    def _create_env(self, must_open_db) :
+        self.dbenv = db.DBEnv()
+        self.dbenv.set_tx_max(self.num_txns)
+        self.dbenv.set_lk_max_lockers(self.num_txns*2)
+        self.dbenv.set_lk_max_locks(self.num_txns*2)
+        self.dbenv.set_lk_max_objects(self.num_txns*2)
+        if self.nosync :
+            self.dbenv.set_flags(db.DB_TXN_NOSYNC,True)
+        self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_THREAD |
+                db.DB_RECOVER |
+                db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL |
+                db.DB_INIT_LOCK, 0666)
+        self.db = db.DB(self.dbenv)
+        self.db.set_re_len(db.DB_GID_SIZE)
+        if must_open_db :
+            txn=self.dbenv.txn_begin()
+            self.db.open(self.filename,
+                    db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666,
+                    txn=txn)
+            txn.commit()
+
+    def setUp(self) :
+        self.homeDir = get_new_environment_path()
+        self.filename = "test"
+        return self._create_env(must_open_db=True)
+
+    def _destroy_env(self):
+        if self.nosync or (db.version()[:2] == (4,6)):  # Known bug
+            self.dbenv.log_flush()
+        self.db.close()
+        self.dbenv.close()
+
+    def tearDown(self):
+        self._destroy_env()
+        test_support.rmtree(self.homeDir)
+
+    def _recreate_env(self,must_open_db) :
+        self._destroy_env()
+        self._create_env(must_open_db)
+
+    def test01_distributed_transactions(self) :
+        txns=set()
+        adapt = lambda x : x
+        import sys
+        if sys.version_info[0] >= 3 :
+            adapt = lambda x : bytes(x, "ascii")
+    # Create transactions, "prepare" them, and
+    # let them be garbage collected.
+        for i in xrange(self.num_txns) :
+            txn = self.dbenv.txn_begin()
+            gid = "%%%dd" %db.DB_GID_SIZE
+            gid = adapt(gid %i)
+            self.db.put(i, gid, txn=txn, flags=db.DB_APPEND)
+            txns.add(gid)
+            txn.prepare(gid)
+        del txn
+
+        self._recreate_env(self.must_open_db)
+
+    # Get "to be recovered" transactions but
+    # let them be garbage collected.
+        recovered_txns=self.dbenv.txn_recover()
+        self.assertEqual(self.num_txns,len(recovered_txns))
+        for gid,txn in recovered_txns :
+            self.assertTrue(gid in txns)
+        del txn
+        del recovered_txns
+
+        self._recreate_env(self.must_open_db)
+
+    # Get "to be recovered" transactions. Commit, abort and
+    # discard them.
+        recovered_txns=self.dbenv.txn_recover()
+        self.assertEqual(self.num_txns,len(recovered_txns))
+        discard_txns=set()
+        committed_txns=set()
+        state=0
+        for gid,txn in recovered_txns :
+            if state==0 or state==1:
+                committed_txns.add(gid)
+                txn.commit()
+            elif state==2 :
+                txn.abort()
+            elif state==3 :
+                txn.discard()
+                discard_txns.add(gid)
+                state=-1
+            state+=1
+        del txn
+        del recovered_txns
+
+        self._recreate_env(self.must_open_db)
+
+    # Verify the discarded transactions are still
+    # around, and dispose them.
+        recovered_txns=self.dbenv.txn_recover()
+        self.assertEqual(len(discard_txns),len(recovered_txns))
+        for gid,txn in recovered_txns :
+            txn.abort()
+        del txn
+        del recovered_txns
+
+        self._recreate_env(must_open_db=True)
+
+    # Be sure there are not pending transactions.
+    # Check also database size.
+        recovered_txns=self.dbenv.txn_recover()
+        self.assertTrue(len(recovered_txns)==0)
+        self.assertEqual(len(committed_txns),self.db.stat()["nkeys"])
+
+class DBTxn_distributedSYNC(DBTxn_distributed):
+    nosync=False
+
+class DBTxn_distributed_must_open_db(DBTxn_distributed):
+    must_open_db=True
+
+class DBTxn_distributedSYNC_must_open_db(DBTxn_distributed):
+    nosync=False
+    must_open_db=True
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+    if db.version() >= (4,5) :
+        suite.addTest(unittest.makeSuite(DBTxn_distributed))
+        suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC))
+    if db.version() >= (4,6) :
+        suite.addTest(unittest.makeSuite(DBTxn_distributed_must_open_db))
+        suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC_must_open_db))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_early_close.py b/lib/python2.7/bsddb/test/test_early_close.py
new file mode 100644
index 0000000..e925279
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_early_close.py
@@ -0,0 +1,215 @@
+"""TestCases for checking that it does not segfault when a DBEnv object
+is closed before its DB objects.
+"""
+
+import os, sys
+import unittest
+
+from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path
+
+# We're going to get warnings in this module about trying to close the db when
+# its env is already closed.  Let's just ignore those.
+try:
+    import warnings
+except ImportError:
+    pass
+else:
+    warnings.filterwarnings('ignore',
+                            message='DB could not be closed in',
+                            category=RuntimeWarning)
+
+
+#----------------------------------------------------------------------
+
+class DBEnvClosedEarlyCrash(unittest.TestCase):
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+        self.filename = "test"
+
+    def tearDown(self):
+        test_support.rmtree(self.homeDir)
+
+    def test01_close_dbenv_before_db(self):
+        dbenv = db.DBEnv()
+        dbenv.open(self.homeDir,
+                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
+                   0666)
+
+        d = db.DB(dbenv)
+        d2 = db.DB(dbenv)
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+
+        self.assertRaises(db.DBNoSuchFileError, d2.open,
+                self.filename+"2", db.DB_BTREE, db.DB_THREAD, 0666)
+
+        d.put("test","this is a test")
+        self.assertEqual(d.get("test"), "this is a test", "put!=get")
+        dbenv.close()  # This "close" should close the child db handle also
+        self.assertRaises(db.DBError, d.get, "test")
+
+    def test02_close_dbenv_before_dbcursor(self):
+        dbenv = db.DBEnv()
+        dbenv.open(self.homeDir,
+                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
+                   0666)
+
+        d = db.DB(dbenv)
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+
+        d.put("test","this is a test")
+        d.put("test2","another test")
+        d.put("test3","another one")
+        self.assertEqual(d.get("test"), "this is a test", "put!=get")
+        c=d.cursor()
+        c.first()
+        c.next()
+        d.close()  # This "close" should close the child db handle also
+     # db.close should close the child cursor
+        self.assertRaises(db.DBError,c.next)
+
+        d = db.DB(dbenv)
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+        c=d.cursor()
+        c.first()
+        c.next()
+        dbenv.close()
+    # The "close" should close the child db handle also, with cursors
+        self.assertRaises(db.DBError, c.next)
+
+    def test03_close_db_before_dbcursor_without_env(self):
+        import os.path
+        path=os.path.join(self.homeDir,self.filename)
+        d = db.DB()
+        d.open(path, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+
+        d.put("test","this is a test")
+        d.put("test2","another test")
+        d.put("test3","another one")
+        self.assertEqual(d.get("test"), "this is a test", "put!=get")
+        c=d.cursor()
+        c.first()
+        c.next()
+        d.close()
+    # The "close" should close the child db handle also
+        self.assertRaises(db.DBError, c.next)
+
+    def test04_close_massive(self):
+        dbenv = db.DBEnv()
+        dbenv.open(self.homeDir,
+                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
+                   0666)
+
+        dbs=[db.DB(dbenv) for i in xrange(16)]
+        cursors=[]
+        for i in dbs :
+            i.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+
+        dbs[10].put("test","this is a test")
+        dbs[10].put("test2","another test")
+        dbs[10].put("test3","another one")
+        self.assertEqual(dbs[4].get("test"), "this is a test", "put!=get")
+
+        for i in dbs :
+            cursors.extend([i.cursor() for j in xrange(32)])
+
+        for i in dbs[::3] :
+            i.close()
+        for i in cursors[::3] :
+            i.close()
+
+    # Check for missing exception in DB! (after DB close)
+        self.assertRaises(db.DBError, dbs[9].get, "test")
+
+    # Check for missing exception in DBCursor! (after DB close)
+        self.assertRaises(db.DBError, cursors[101].first)
+
+        cursors[80].first()
+        cursors[80].next()
+        dbenv.close()  # This "close" should close the child db handle also
+    # Check for missing exception! (after DBEnv close)
+        self.assertRaises(db.DBError, cursors[80].next)
+
+    def test05_close_dbenv_delete_db_success(self):
+        dbenv = db.DBEnv()
+        dbenv.open(self.homeDir,
+                   db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
+                   0666)
+
+        d = db.DB(dbenv)
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+
+        dbenv.close()  # This "close" should close the child db handle also
+
+        del d
+        try:
+            import gc
+        except ImportError:
+            gc = None
+        if gc:
+            # force d.__del__ [DB_dealloc] to be called
+            gc.collect()
+
+    def test06_close_txn_before_dup_cursor(self) :
+        dbenv = db.DBEnv()
+        dbenv.open(self.homeDir,db.DB_INIT_TXN | db.DB_INIT_MPOOL |
+                db.DB_INIT_LOG | db.DB_CREATE)
+        d = db.DB(dbenv)
+        txn = dbenv.txn_begin()
+        d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE,
+                txn=txn)
+        d.put("XXX", "yyy", txn=txn)
+        txn.commit()
+        txn = dbenv.txn_begin()
+        c1 = d.cursor(txn)
+        c2 = c1.dup()
+        self.assertEqual(("XXX", "yyy"), c1.first())
+
+        # Not interested in warnings about implicit close.
+        import warnings
+        if sys.version_info < (2, 6) :
+            # Completely resetting the warning state is
+            # problematic with python >=2.6 with -3 (py3k warning),
+            # because some stdlib modules selectively ignores warnings.
+            warnings.simplefilter("ignore")
+            txn.commit()
+            warnings.resetwarnings()
+        else :
+            # When we drop support for python 2.4
+            # we could use: (in 2.5 we need a __future__ statement)
+            #
+            #    with warnings.catch_warnings():
+            #        warnings.simplefilter("ignore")
+            #        txn.commit()
+            #
+            # We can not use "with" as is, because it would be invalid syntax
+            # in python 2.4 and (with no __future__) 2.5.
+            # Here we simulate "with" following PEP 343 :
+            w = warnings.catch_warnings()
+            w.__enter__()
+            try :
+                warnings.simplefilter("ignore")
+                txn.commit()
+            finally :
+                w.__exit__()
+
+        self.assertRaises(db.DBCursorClosedError, c2.first)
+
+    def test07_close_db_before_sequence(self):
+        import os.path
+        path=os.path.join(self.homeDir,self.filename)
+        d = db.DB()
+        d.open(path, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
+        dbs=db.DBSequence(d)
+        d.close()  # This "close" should close the child DBSequence also
+        dbs.close()  # If not closed, core dump (in Berkeley DB 4.6.*)
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(DBEnvClosedEarlyCrash))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_fileid.py b/lib/python2.7/bsddb/test/test_fileid.py
new file mode 100644
index 0000000..095ec83
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_fileid.py
@@ -0,0 +1,61 @@
+"""TestCase for reseting File ID.
+"""
+
+import os
+import shutil
+import unittest
+
+from test_all import db, test_support, get_new_environment_path, get_new_database_path
+
+class FileidResetTestCase(unittest.TestCase):
+    def setUp(self):
+        self.db_path_1 = get_new_database_path()
+        self.db_path_2 = get_new_database_path()
+        self.db_env_path = get_new_environment_path()
+
+    def test_fileid_reset(self):
+        # create DB 1
+        self.db1 = db.DB()
+        self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=(db.DB_CREATE|db.DB_EXCL))
+        self.db1.put('spam', 'eggs')
+        self.db1.close()
+
+        shutil.copy(self.db_path_1, self.db_path_2)
+
+        self.db2 = db.DB()
+        self.db2.open(self.db_path_2, dbtype=db.DB_HASH)
+        self.db2.put('spam', 'spam')
+        self.db2.close()
+
+        self.db_env = db.DBEnv()
+        self.db_env.open(self.db_env_path, db.DB_CREATE|db.DB_INIT_MPOOL)
+
+        # use fileid_reset() here
+        self.db_env.fileid_reset(self.db_path_2)
+
+        self.db1 = db.DB(self.db_env)
+        self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
+        self.assertEqual(self.db1.get('spam'), 'eggs')
+
+        self.db2 = db.DB(self.db_env)
+        self.db2.open(self.db_path_2, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
+        self.assertEqual(self.db2.get('spam'), 'spam')
+
+        self.db1.close()
+        self.db2.close()
+
+        self.db_env.close()
+
+    def tearDown(self):
+        test_support.unlink(self.db_path_1)
+        test_support.unlink(self.db_path_2)
+        test_support.rmtree(self.db_env_path)
+
+def test_suite():
+    suite = unittest.TestSuite()
+    if db.version() >= (4, 4):
+        suite.addTest(unittest.makeSuite(FileidResetTestCase))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_get_none.py b/lib/python2.7/bsddb/test/test_get_none.py
new file mode 100644
index 0000000..8763b54
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_get_none.py
@@ -0,0 +1,92 @@
+"""
+TestCases for checking set_get_returns_none.
+"""
+
+import os, string
+import unittest
+
+from test_all import db, verbose, get_new_database_path
+
+
+#----------------------------------------------------------------------
+
+class GetReturnsNoneTestCase(unittest.TestCase):
+    def setUp(self):
+        self.filename = get_new_database_path()
+
+    def tearDown(self):
+        try:
+            os.remove(self.filename)
+        except os.error:
+            pass
+
+
+    def test01_get_returns_none(self):
+        d = db.DB()
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
+        d.set_get_returns_none(1)
+
+        for x in string.letters:
+            d.put(x, x * 40)
+
+        data = d.get('bad key')
+        self.assertEqual(data, None)
+
+        data = d.get(string.letters[0])
+        self.assertEqual(data, string.letters[0]*40)
+
+        count = 0
+        c = d.cursor()
+        rec = c.first()
+        while rec:
+            count = count + 1
+            rec = c.next()
+
+        self.assertEqual(rec, None)
+        self.assertEqual(count, len(string.letters))
+
+        c.close()
+        d.close()
+
+
+    def test02_get_raises_exception(self):
+        d = db.DB()
+        d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
+        d.set_get_returns_none(0)
+
+        for x in string.letters:
+            d.put(x, x * 40)
+
+        self.assertRaises(db.DBNotFoundError, d.get, 'bad key')
+        self.assertRaises(KeyError, d.get, 'bad key')
+
+        data = d.get(string.letters[0])
+        self.assertEqual(data, string.letters[0]*40)
+
+        count = 0
+        exceptionHappened = 0
+        c = d.cursor()
+        rec = c.first()
+        while rec:
+            count = count + 1
+            try:
+                rec = c.next()
+            except db.DBNotFoundError:  # end of the records
+                exceptionHappened = 1
+                break
+
+        self.assertNotEqual(rec, None)
+        self.assertTrue(exceptionHappened)
+        self.assertEqual(count, len(string.letters))
+
+        c.close()
+        d.close()
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    return unittest.makeSuite(GetReturnsNoneTestCase)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_join.py b/lib/python2.7/bsddb/test/test_join.py
new file mode 100644
index 0000000..1f0dfff
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_join.py
@@ -0,0 +1,99 @@
+"""TestCases for using the DB.join and DBCursor.join_item methods.
+"""
+
+import os
+
+import unittest
+
+from test_all import db, dbshelve, test_support, verbose, \
+        get_new_environment_path, get_new_database_path
+
+#----------------------------------------------------------------------
+
+ProductIndex = [
+    ('apple', "Convenience Store"),
+    ('blueberry', "Farmer's Market"),
+    ('shotgun', "S-Mart"),              # Aisle 12
+    ('pear', "Farmer's Market"),
+    ('chainsaw', "S-Mart"),             # "Shop smart.  Shop S-Mart!"
+    ('strawberry', "Farmer's Market"),
+]
+
+ColorIndex = [
+    ('blue', "blueberry"),
+    ('red', "apple"),
+    ('red', "chainsaw"),
+    ('red', "strawberry"),
+    ('yellow', "peach"),
+    ('yellow', "pear"),
+    ('black', "shotgun"),
+]
+
+class JoinTestCase(unittest.TestCase):
+    keytype = ''
+
+    def setUp(self):
+        self.filename = self.__class__.__name__ + '.db'
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK )
+
+    def tearDown(self):
+        self.env.close()
+        test_support.rmtree(self.homeDir)
+
+    def test01_join(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_join..." % \
+                  self.__class__.__name__
+
+        # create and populate primary index
+        priDB = db.DB(self.env)
+        priDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE)
+        map(lambda t, priDB=priDB: priDB.put(*t), ProductIndex)
+
+        # create and populate secondary index
+        secDB = db.DB(self.env)
+        secDB.set_flags(db.DB_DUP | db.DB_DUPSORT)
+        secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
+        map(lambda t, secDB=secDB: secDB.put(*t), ColorIndex)
+
+        sCursor = None
+        jCursor = None
+        try:
+            # lets look up all of the red Products
+            sCursor = secDB.cursor()
+            # Don't do the .set() in an assert, or you can get a bogus failure
+            # when running python -O
+            tmp = sCursor.set('red')
+            self.assertTrue(tmp)
+
+            # FIXME: jCursor doesn't properly hold a reference to its
+            # cursors, if they are closed before jcursor is used it
+            # can cause a crash.
+            jCursor = priDB.join([sCursor])
+
+            if jCursor.get(0) != ('apple', "Convenience Store"):
+                self.fail("join cursor positioned wrong")
+            if jCursor.join_item() != 'chainsaw':
+                self.fail("DBCursor.join_item returned wrong item")
+            if jCursor.get(0)[0] != 'strawberry':
+                self.fail("join cursor returned wrong thing")
+            if jCursor.get(0):  # there were only three red items to return
+                self.fail("join cursor returned too many items")
+        finally:
+            if jCursor:
+                jCursor.close()
+            if sCursor:
+                sCursor.close()
+            priDB.close()
+            secDB.close()
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    suite.addTest(unittest.makeSuite(JoinTestCase))
+
+    return suite
diff --git a/lib/python2.7/bsddb/test/test_lock.py b/lib/python2.7/bsddb/test/test_lock.py
new file mode 100644
index 0000000..10ca8d6
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_lock.py
@@ -0,0 +1,184 @@
+"""
+TestCases for testing the locking sub-system.
+"""
+
+import time
+
+import unittest
+from test_all import db, test_support, verbose, have_threads, \
+        get_new_environment_path, get_new_database_path
+
+if have_threads :
+    from threading import Thread
+    import sys
+    if sys.version_info[0] < 3 :
+        from threading import currentThread
+    else :
+        from threading import current_thread as currentThread
+
+#----------------------------------------------------------------------
+
+class LockingTestCase(unittest.TestCase):
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL |
+                                    db.DB_INIT_LOCK | db.DB_CREATE)
+
+
+    def tearDown(self):
+        self.env.close()
+        test_support.rmtree(self.homeDir)
+
+
+    def test01_simple(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_simple..." % self.__class__.__name__
+
+        anID = self.env.lock_id()
+        if verbose:
+            print "locker ID: %s" % anID
+        lock = self.env.lock_get(anID, "some locked thing", db.DB_LOCK_WRITE)
+        if verbose:
+            print "Aquired lock: %s" % lock
+        self.env.lock_put(lock)
+        if verbose:
+            print "Released lock: %s" % lock
+        self.env.lock_id_free(anID)
+
+
+    def test02_threaded(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_threaded..." % self.__class__.__name__
+
+        threads = []
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_WRITE,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_READ,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_READ,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_WRITE,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_READ,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_READ,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_WRITE,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_WRITE,)))
+        threads.append(Thread(target = self.theThread,
+                              args=(db.DB_LOCK_WRITE,)))
+
+        for t in threads:
+            import sys
+            if sys.version_info[0] < 3 :
+                t.setDaemon(True)
+            else :
+                t.daemon = True
+            t.start()
+        for t in threads:
+            t.join()
+
+        def test03_lock_timeout(self):
+            self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
+            self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 0)
+            self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
+            self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 0)
+            self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
+            self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 123456)
+            self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
+            self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 7890123)
+
+    def test04_lock_timeout2(self):
+        self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
+        self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
+        self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
+        self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
+
+        def deadlock_detection() :
+            while not deadlock_detection.end :
+                deadlock_detection.count = \
+                    self.env.lock_detect(db.DB_LOCK_EXPIRE)
+                if deadlock_detection.count :
+                    while not deadlock_detection.end :
+                        pass
+                    break
+                time.sleep(0.01)
+
+        deadlock_detection.end=False
+        deadlock_detection.count=0
+        t=Thread(target=deadlock_detection)
+        import sys
+        if sys.version_info[0] < 3 :
+            t.setDaemon(True)
+        else :
+            t.daemon = True
+        t.start()
+        self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
+        anID = self.env.lock_id()
+        anID2 = self.env.lock_id()
+        self.assertNotEqual(anID, anID2)
+        lock = self.env.lock_get(anID, "shared lock", db.DB_LOCK_WRITE)
+        start_time=time.time()
+        self.assertRaises(db.DBLockNotGrantedError,
+                self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
+        end_time=time.time()
+        deadlock_detection.end=True
+        # Floating point rounding
+        self.assertTrue((end_time-start_time) >= 0.0999)
+        self.env.lock_put(lock)
+        t.join()
+
+        self.env.lock_id_free(anID)
+        self.env.lock_id_free(anID2)
+
+        if db.version() >= (4,6):
+            self.assertTrue(deadlock_detection.count>0)
+
+    def theThread(self, lockType):
+        import sys
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        if lockType ==  db.DB_LOCK_WRITE:
+            lt = "write"
+        else:
+            lt = "read"
+
+        anID = self.env.lock_id()
+        if verbose:
+            print "%s: locker ID: %s" % (name, anID)
+
+        for i in xrange(1000) :
+            lock = self.env.lock_get(anID, "some locked thing", lockType)
+            if verbose:
+                print "%s: Aquired %s lock: %s" % (name, lt, lock)
+
+            self.env.lock_put(lock)
+            if verbose:
+                print "%s: Released %s lock: %s" % (name, lt, lock)
+
+        self.env.lock_id_free(anID)
+
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    if have_threads:
+        suite.addTest(unittest.makeSuite(LockingTestCase))
+    else:
+        suite.addTest(unittest.makeSuite(LockingTestCase, 'test01'))
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_misc.py b/lib/python2.7/bsddb/test/test_misc.py
new file mode 100644
index 0000000..b1e928f
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_misc.py
@@ -0,0 +1,138 @@
+"""Miscellaneous bsddb module test cases
+"""
+
+import os, sys
+import unittest
+
+from test_all import db, dbshelve, hashopen, test_support, get_new_environment_path, get_new_database_path
+
+#----------------------------------------------------------------------
+
+class MiscTestCase(unittest.TestCase):
+    def setUp(self):
+        self.filename = get_new_database_path()
+        self.homeDir = get_new_environment_path()
+
+    def tearDown(self):
+        test_support.unlink(self.filename)
+        test_support.rmtree(self.homeDir)
+
+    def test01_badpointer(self):
+        dbs = dbshelve.open(self.filename)
+        dbs.close()
+        self.assertRaises(db.DBError, dbs.get, "foo")
+
+    def test02_db_home(self):
+        env = db.DBEnv()
+        # check for crash fixed when db_home is used before open()
+        self.assertTrue(env.db_home is None)
+        env.open(self.homeDir, db.DB_CREATE)
+        if sys.version_info[0] < 3 :
+            self.assertEqual(self.homeDir, env.db_home)
+        else :
+            self.assertEqual(bytes(self.homeDir, "ascii"), env.db_home)
+
+    def test03_repr_closed_db(self):
+        db = hashopen(self.filename)
+        db.close()
+        rp = repr(db)
+        self.assertEqual(rp, "{}")
+
+    def test04_repr_db(self) :
+        db = hashopen(self.filename)
+        d = {}
+        for i in xrange(100) :
+            db[repr(i)] = repr(100*i)
+            d[repr(i)] = repr(100*i)
+        db.close()
+        db = hashopen(self.filename)
+        rp = repr(db)
+        self.assertEqual(rp, repr(d))
+        db.close()
+
+    # http://sourceforge.net/tracker/index.php?func=detail&aid=1708868&group_id=13900&atid=313900
+    #
+    # See the bug report for details.
+    #
+    # The problem was that make_key_dbt() was not allocating a copy of
+    # string keys but FREE_DBT() was always being told to free it when the
+    # database was opened with DB_THREAD.
+    def test05_double_free_make_key_dbt(self):
+        try:
+            db1 = db.DB()
+            db1.open(self.filename, None, db.DB_BTREE,
+                     db.DB_CREATE | db.DB_THREAD)
+
+            curs = db1.cursor()
+            t = curs.get("/foo", db.DB_SET)
+            # double free happened during exit from DBC_get
+        finally:
+            db1.close()
+            test_support.unlink(self.filename)
+
+    def test06_key_with_null_bytes(self):
+        try:
+            db1 = db.DB()
+            db1.open(self.filename, None, db.DB_HASH, db.DB_CREATE)
+            db1['a'] = 'eh?'
+            db1['a\x00'] = 'eh zed.'
+            db1['a\x00a'] = 'eh zed eh?'
+            db1['aaa'] = 'eh eh eh!'
+            keys = db1.keys()
+            keys.sort()
+            self.assertEqual(['a', 'a\x00', 'a\x00a', 'aaa'], keys)
+            self.assertEqual(db1['a'], 'eh?')
+            self.assertEqual(db1['a\x00'], 'eh zed.')
+            self.assertEqual(db1['a\x00a'], 'eh zed eh?')
+            self.assertEqual(db1['aaa'], 'eh eh eh!')
+        finally:
+            db1.close()
+            test_support.unlink(self.filename)
+
+    def test07_DB_set_flags_persists(self):
+        try:
+            db1 = db.DB()
+            db1.set_flags(db.DB_DUPSORT)
+            db1.open(self.filename, db.DB_HASH, db.DB_CREATE)
+            db1['a'] = 'eh'
+            db1['a'] = 'A'
+            self.assertEqual([('a', 'A')], db1.items())
+            db1.put('a', 'Aa')
+            self.assertEqual([('a', 'A'), ('a', '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([('a', 'A'), ('a', 'Aa')], db1.items())
+            # if it read the flags right this will replace all values
+            # for key 'a' instead of adding a new one.  (as a dict should)
+            db1['a'] = 'new A'
+            self.assertEqual([('a', 'new A')], db1.items())
+        finally:
+            db1.close()
+            test_support.unlink(self.filename)
+
+
+    def test08_ExceptionTypes(self) :
+        self.assertTrue(issubclass(db.DBError, Exception))
+        for i, j in db.__dict__.items() :
+            if i.startswith("DB") and i.endswith("Error") :
+                self.assertTrue(issubclass(j, db.DBError), msg=i)
+                if i not in ("DBKeyEmptyError", "DBNotFoundError") :
+                    self.assertFalse(issubclass(j, KeyError), msg=i)
+
+        # This two exceptions have two bases
+        self.assertTrue(issubclass(db.DBKeyEmptyError, KeyError))
+        self.assertTrue(issubclass(db.DBNotFoundError, KeyError))
+
+
+#----------------------------------------------------------------------
+
+
+def test_suite():
+    return unittest.makeSuite(MiscTestCase)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_pickle.py b/lib/python2.7/bsddb/test/test_pickle.py
new file mode 100644
index 0000000..6a8478d
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_pickle.py
@@ -0,0 +1,68 @@
+
+import os
+import pickle
+import sys
+
+if sys.version_info[0] < 3 :
+    try:
+        import cPickle
+    except ImportError:
+        cPickle = None
+else :
+    cPickle = None
+
+import unittest
+
+from test_all import db, test_support, get_new_environment_path, get_new_database_path
+
+#----------------------------------------------------------------------
+
+class pickleTestCase(unittest.TestCase):
+    """Verify that DBError can be pickled and unpickled"""
+    db_name = 'test-dbobj.db'
+
+    def setUp(self):
+        self.homeDir = get_new_environment_path()
+
+    def tearDown(self):
+        if hasattr(self, 'db'):
+            del self.db
+        if hasattr(self, 'env'):
+            del self.env
+        test_support.rmtree(self.homeDir)
+
+    def _base_test_pickle_DBError(self, pickle):
+        self.env = db.DBEnv()
+        self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
+        self.db = db.DB(self.env)
+        self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
+        self.db.put('spam', 'eggs')
+        self.assertEqual(self.db['spam'], 'eggs')
+        try:
+            self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
+        except db.DBError, egg:
+            pickledEgg = pickle.dumps(egg)
+            #print repr(pickledEgg)
+            rottenEgg = pickle.loads(pickledEgg)
+            if rottenEgg.args != egg.args or type(rottenEgg) != type(egg):
+                raise Exception, (rottenEgg, '!=', egg)
+        else:
+            raise Exception, "where's my DBError exception?!?"
+
+        self.db.close()
+        self.env.close()
+
+    def test01_pickle_DBError(self):
+        self._base_test_pickle_DBError(pickle=pickle)
+
+    if cPickle:
+        def test02_cPickle_DBError(self):
+            self._base_test_pickle_DBError(pickle=cPickle)
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    return unittest.makeSuite(pickleTestCase)
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_queue.py b/lib/python2.7/bsddb/test/test_queue.py
new file mode 100644
index 0000000..c213ff4
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_queue.py
@@ -0,0 +1,163 @@
+"""
+TestCases for exercising a Queue DB.
+"""
+
+import os, string
+from pprint import pprint
+import unittest
+
+from test_all import db, verbose, get_new_database_path
+
+#----------------------------------------------------------------------
+
+class SimpleQueueTestCase(unittest.TestCase):
+    def setUp(self):
+        self.filename = get_new_database_path()
+
+    def tearDown(self):
+        try:
+            os.remove(self.filename)
+        except os.error:
+            pass
+
+
+    def test01_basic(self):
+        # Basic Queue tests using the deprecated DBCursor.consume method.
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_basic..." % self.__class__.__name__
+
+        d = db.DB()
+        d.set_re_len(40)  # Queues must be fixed length
+        d.open(self.filename, db.DB_QUEUE, db.DB_CREATE)
+
+        if verbose:
+            print "before appends" + '-' * 30
+            pprint(d.stat())
+
+        for x in string.letters:
+            d.append(x * 40)
+
+        self.assertEqual(len(d), len(string.letters))
+
+        d.put(100, "some more data")
+        d.put(101, "and some more ")
+        d.put(75,  "out of order")
+        d.put(1,   "replacement data")
+
+        self.assertEqual(len(d), len(string.letters)+3)
+
+        if verbose:
+            print "before close" + '-' * 30
+            pprint(d.stat())
+
+        d.close()
+        del d
+        d = db.DB()
+        d.open(self.filename)
+
+        if verbose:
+            print "after open" + '-' * 30
+            pprint(d.stat())
+
+        # Test "txn" as a positional parameter
+        d.append("one more", None)
+        # Test "txn" as a keyword parameter
+        d.append("another one", txn=None)
+
+        c = d.cursor()
+
+        if verbose:
+            print "after append" + '-' * 30
+            pprint(d.stat())
+
+        rec = c.consume()
+        while rec:
+            if verbose:
+                print rec
+            rec = c.consume()
+        c.close()
+
+        if verbose:
+            print "after consume loop" + '-' * 30
+            pprint(d.stat())
+
+        self.assertEqual(len(d), 0, \
+               "if you see this message then you need to rebuild " \
+               "Berkeley DB 3.1.17 with the patch in patches/qam_stat.diff")
+
+        d.close()
+
+
+
+    def test02_basicPost32(self):
+        # Basic Queue tests using the new DB.consume method in DB 3.2+
+        # (No cursor needed)
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_basicPost32..." % self.__class__.__name__
+
+        d = db.DB()
+        d.set_re_len(40)  # Queues must be fixed length
+        d.open(self.filename, db.DB_QUEUE, db.DB_CREATE)
+
+        if verbose:
+            print "before appends" + '-' * 30
+            pprint(d.stat())
+
+        for x in string.letters:
+            d.append(x * 40)
+
+        self.assertEqual(len(d), len(string.letters))
+
+        d.put(100, "some more data")
+        d.put(101, "and some more ")
+        d.put(75,  "out of order")
+        d.put(1,   "replacement data")
+
+        self.assertEqual(len(d), len(string.letters)+3)
+
+        if verbose:
+            print "before close" + '-' * 30
+            pprint(d.stat())
+
+        d.close()
+        del d
+        d = db.DB()
+        d.open(self.filename)
+        #d.set_get_returns_none(true)
+
+        if verbose:
+            print "after open" + '-' * 30
+            pprint(d.stat())
+
+        d.append("one more")
+
+        if verbose:
+            print "after append" + '-' * 30
+            pprint(d.stat())
+
+        rec = d.consume()
+        while rec:
+            if verbose:
+                print rec
+            rec = d.consume()
+
+        if verbose:
+            print "after consume loop" + '-' * 30
+            pprint(d.stat())
+
+        d.close()
+
+
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    return unittest.makeSuite(SimpleQueueTestCase)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_recno.py b/lib/python2.7/bsddb/test/test_recno.py
new file mode 100644
index 0000000..fb6956a
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_recno.py
@@ -0,0 +1,320 @@
+"""TestCases for exercising a Recno DB.
+"""
+
+import os, sys
+import errno
+from pprint import pprint
+import unittest
+
+from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path
+
+letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+
+
+#----------------------------------------------------------------------
+
+class SimpleRecnoTestCase(unittest.TestCase):
+    if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
+            (sys.version_info < (3, 2))) :
+        def assertIsInstance(self, obj, datatype, msg=None) :
+            return self.assertEqual(type(obj), datatype, msg=msg)
+        def assertGreaterEqual(self, a, b, msg=None) :
+            return self.assertTrue(a>=b, msg=msg)
+
+
+    def setUp(self):
+        self.filename = get_new_database_path()
+        self.homeDir = None
+
+    def tearDown(self):
+        test_support.unlink(self.filename)
+        if self.homeDir:
+            test_support.rmtree(self.homeDir)
+
+    def test01_basic(self):
+        d = db.DB()
+
+        get_returns_none = d.set_get_returns_none(2)
+        d.set_get_returns_none(get_returns_none)
+
+        d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
+
+        for x in letters:
+            recno = d.append(x * 60)
+            self.assertIsInstance(recno, int)
+            self.assertGreaterEqual(recno, 1)
+            if verbose:
+                print recno,
+
+        if verbose: print
+
+        stat = d.stat()
+        if verbose:
+            pprint(stat)
+
+        for recno in range(1, len(d)+1):
+            data = d[recno]
+            if verbose:
+                print data
+
+            self.assertIsInstance(data, str)
+            self.assertEqual(data, d.get(recno))
+
+        try:
+            data = d[0]  # This should raise a KeyError!?!?!
+        except db.DBInvalidArgError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.EINVAL)
+            else :
+                self.assertEqual(val.args[0], db.EINVAL)
+            if verbose: print val
+        else:
+            self.fail("expected exception")
+
+        # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
+        try:
+            d.has_key(0)
+        except db.DBError, val:
+            pass
+        else:
+            self.fail("has_key did not raise a proper exception")
+
+        try:
+            data = d[100]
+        except KeyError:
+            pass
+        else:
+            self.fail("expected exception")
+
+        try:
+            data = d.get(100)
+        except db.DBNotFoundError, val:
+            if get_returns_none:
+                self.fail("unexpected exception")
+        else:
+            self.assertEqual(data, None)
+
+        keys = d.keys()
+        if verbose:
+            print keys
+        self.assertIsInstance(keys, list)
+        self.assertIsInstance(keys[0], int)
+        self.assertEqual(len(keys), len(d))
+
+        items = d.items()
+        if verbose:
+            pprint(items)
+        self.assertIsInstance(items, list)
+        self.assertIsInstance(items[0], tuple)
+        self.assertEqual(len(items[0]), 2)
+        self.assertIsInstance(items[0][0], int)
+        self.assertIsInstance(items[0][1], str)
+        self.assertEqual(len(items), len(d))
+
+        self.assertTrue(d.has_key(25))
+
+        del d[25]
+        self.assertFalse(d.has_key(25))
+
+        d.delete(13)
+        self.assertFalse(d.has_key(13))
+
+        data = d.get_both(26, "z" * 60)
+        self.assertEqual(data, "z" * 60, 'was %r' % data)
+        if verbose:
+            print data
+
+        fd = d.fd()
+        if verbose:
+            print fd
+
+        c = d.cursor()
+        rec = c.first()
+        while rec:
+            if verbose:
+                print rec
+            rec = c.next()
+
+        c.set(50)
+        rec = c.current()
+        if verbose:
+            print rec
+
+        c.put(-1, "a replacement record", db.DB_CURRENT)
+
+        c.set(50)
+        rec = c.current()
+        self.assertEqual(rec, (50, "a replacement record"))
+        if verbose:
+            print rec
+
+        rec = c.set_range(30)
+        if verbose:
+            print rec
+
+        # test that non-existent key lookups work (and that
+        # DBC_set_range doesn't have a memleak under valgrind)
+        rec = c.set_range(999999)
+        self.assertEqual(rec, None)
+        if verbose:
+            print rec
+
+        c.close()
+        d.close()
+
+        d = db.DB()
+        d.open(self.filename)
+        c = d.cursor()
+
+        # put a record beyond the consecutive end of the recno's
+        d[100] = "way out there"
+        self.assertEqual(d[100], "way out there")
+
+        try:
+            data = d[99]
+        except KeyError:
+            pass
+        else:
+            self.fail("expected exception")
+
+        try:
+            d.get(99)
+        except db.DBKeyEmptyError, val:
+            if get_returns_none:
+                self.fail("unexpected DBKeyEmptyError exception")
+            else:
+                if sys.version_info < (2, 6) :
+                    self.assertEqual(val[0], db.DB_KEYEMPTY)
+                else :
+                    self.assertEqual(val.args[0], db.DB_KEYEMPTY)
+                if verbose: print val
+        else:
+            if not get_returns_none:
+                self.fail("expected exception")
+
+        rec = c.set(40)
+        while rec:
+            if verbose:
+                print rec
+            rec = c.next()
+
+        c.close()
+        d.close()
+
+    def test02_WithSource(self):
+        """
+        A Recno file that is given a "backing source file" is essentially a
+        simple ASCII file.  Normally each record is delimited by \n and so is
+        just a line in the file, but you can set a different record delimiter
+        if needed.
+        """
+        homeDir = get_new_environment_path()
+        self.homeDir = homeDir
+        source = os.path.join(homeDir, 'test_recno.txt')
+        if not os.path.isdir(homeDir):
+            os.mkdir(homeDir)
+        f = open(source, 'w') # create the file
+        f.close()
+
+        d = db.DB()
+        # This is the default value, just checking if both int
+        d.set_re_delim(0x0A)
+        d.set_re_delim('\n')  # and char can be used...
+        d.set_re_source(source)
+        d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
+
+        data = "The quick brown fox jumped over the lazy dog".split()
+        for datum in data:
+            d.append(datum)
+        d.sync()
+        d.close()
+
+        # get the text from the backing source
+        f = open(source, 'r')
+        text = f.read()
+        f.close()
+        text = text.strip()
+        if verbose:
+            print text
+            print data
+            print text.split('\n')
+
+        self.assertEqual(text.split('\n'), data)
+
+        # open as a DB again
+        d = db.DB()
+        d.set_re_source(source)
+        d.open(self.filename, db.DB_RECNO)
+
+        d[3] = 'reddish-brown'
+        d[8] = 'comatose'
+
+        d.sync()
+        d.close()
+
+        f = open(source, 'r')
+        text = f.read()
+        f.close()
+        text = text.strip()
+        if verbose:
+            print text
+            print text.split('\n')
+
+        self.assertEqual(text.split('\n'),
+           "The quick reddish-brown fox jumped over the comatose dog".split())
+
+    def test03_FixedLength(self):
+        d = db.DB()
+        d.set_re_len(40)  # fixed length records, 40 bytes long
+        d.set_re_pad('-') # sets the pad character...
+        d.set_re_pad(45)  # ...test both int and char
+        d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
+
+        for x in letters:
+            d.append(x * 35)    # These will be padded
+
+        d.append('.' * 40)      # this one will be exact
+
+        try:                    # this one will fail
+            d.append('bad' * 20)
+        except db.DBInvalidArgError, val:
+            if sys.version_info < (2, 6) :
+                self.assertEqual(val[0], db.EINVAL)
+            else :
+                self.assertEqual(val.args[0], db.EINVAL)
+            if verbose: print val
+        else:
+            self.fail("expected exception")
+
+        c = d.cursor()
+        rec = c.first()
+        while rec:
+            if verbose:
+                print rec
+            rec = c.next()
+
+        c.close()
+        d.close()
+
+    def test04_get_size_empty(self) :
+        d = db.DB()
+        d.open(self.filename, dbtype=db.DB_RECNO, flags=db.DB_CREATE)
+
+        row_id = d.append(' ')
+        self.assertEqual(1, d.get_size(key=row_id))
+        row_id = d.append('')
+        self.assertEqual(0, d.get_size(key=row_id))
+
+
+
+
+
+#----------------------------------------------------------------------
+
+
+def test_suite():
+    return unittest.makeSuite(SimpleRecnoTestCase)
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_replication.py b/lib/python2.7/bsddb/test/test_replication.py
new file mode 100644
index 0000000..12ab2dd
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_replication.py
@@ -0,0 +1,543 @@
+"""TestCases for distributed transactions.
+"""
+
+import os
+import time
+import unittest
+
+from test_all import db, test_support, have_threads, verbose, \
+        get_new_environment_path, get_new_database_path
+
+
+#----------------------------------------------------------------------
+
+class DBReplication(unittest.TestCase) :
+    def setUp(self) :
+        self.homeDirMaster = get_new_environment_path()
+        self.homeDirClient = get_new_environment_path()
+
+        self.dbenvMaster = db.DBEnv()
+        self.dbenvClient = db.DBEnv()
+
+        # Must use "DB_THREAD" because the Replication Manager will
+        # be executed in other threads but will use the same environment.
+        # http://forums.oracle.com/forums/thread.jspa?threadID=645788&tstart=0
+        self.dbenvMaster.open(self.homeDirMaster, db.DB_CREATE | db.DB_INIT_TXN
+                | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
+                db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666)
+        self.dbenvClient.open(self.homeDirClient, db.DB_CREATE | db.DB_INIT_TXN
+                | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
+                db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666)
+
+        self.confirmed_master=self.client_startupdone=False
+        def confirmed_master(a,b,c) :
+            if b==db.DB_EVENT_REP_MASTER :
+                self.confirmed_master=True
+
+        def client_startupdone(a,b,c) :
+            if b==db.DB_EVENT_REP_STARTUPDONE :
+                self.client_startupdone=True
+
+        self.dbenvMaster.set_event_notify(confirmed_master)
+        self.dbenvClient.set_event_notify(client_startupdone)
+
+        #self.dbenvMaster.set_verbose(db.DB_VERB_REPLICATION, True)
+        #self.dbenvMaster.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
+        #self.dbenvClient.set_verbose(db.DB_VERB_REPLICATION, True)
+        #self.dbenvClient.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
+
+        self.dbMaster = self.dbClient = None
+
+
+    def tearDown(self):
+        if self.dbClient :
+            self.dbClient.close()
+        if self.dbMaster :
+            self.dbMaster.close()
+
+        # Here we assign dummy event handlers to allow GC of the test object.
+        # Since the dummy handler doesn't use any outer scope variable, it
+        # doesn't keep any reference to the test object.
+        def dummy(*args) :
+            pass
+        self.dbenvMaster.set_event_notify(dummy)
+        self.dbenvClient.set_event_notify(dummy)
+
+        self.dbenvClient.close()
+        self.dbenvMaster.close()
+        test_support.rmtree(self.homeDirClient)
+        test_support.rmtree(self.homeDirMaster)
+
+class DBReplicationManager(DBReplication) :
+    def test01_basic_replication(self) :
+        master_port = test_support.find_unused_port()
+        client_port = test_support.find_unused_port()
+        if db.version() >= (5, 2) :
+            self.site = self.dbenvMaster.repmgr_site("127.0.0.1", master_port)
+            self.site.set_config(db.DB_GROUP_CREATOR, True)
+            self.site.set_config(db.DB_LOCAL_SITE, True)
+            self.site2 = self.dbenvMaster.repmgr_site("127.0.0.1", client_port)
+
+            self.site3 = self.dbenvClient.repmgr_site("127.0.0.1", master_port)
+            self.site3.set_config(db.DB_BOOTSTRAP_HELPER, True)
+            self.site4 = self.dbenvClient.repmgr_site("127.0.0.1", client_port)
+            self.site4.set_config(db.DB_LOCAL_SITE, True)
+
+            d = {
+                    db.DB_BOOTSTRAP_HELPER: [False, False, True, False],
+                    db.DB_GROUP_CREATOR: [True, False, False, False],
+                    db.DB_LEGACY: [False, False, False, False],
+                    db.DB_LOCAL_SITE: [True, False, False, True],
+                    db.DB_REPMGR_PEER: [False, False, False, False ],
+                }
+
+            for i, j in d.items() :
+                for k, v in \
+                        zip([self.site, self.site2, self.site3, self.site4], j) :
+                    if v :
+                        self.assertTrue(k.get_config(i))
+                    else :
+                        self.assertFalse(k.get_config(i))
+
+            self.assertNotEqual(self.site.get_eid(), self.site2.get_eid())
+            self.assertNotEqual(self.site3.get_eid(), self.site4.get_eid())
+
+            for i, j in zip([self.site, self.site2, self.site3, self.site4], \
+                    [master_port, client_port, master_port, client_port]) :
+                addr = i.get_address()
+                self.assertEqual(addr, ("127.0.0.1", j))
+
+            for i in [self.site, self.site2] :
+                self.assertEqual(i.get_address(),
+                        self.dbenvMaster.repmgr_site_by_eid(i.get_eid()).get_address())
+            for i in [self.site3, self.site4] :
+                self.assertEqual(i.get_address(),
+                        self.dbenvClient.repmgr_site_by_eid(i.get_eid()).get_address())
+        else :
+            self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port)
+            self.dbenvClient.repmgr_set_local_site("127.0.0.1", client_port)
+            self.dbenvMaster.repmgr_add_remote_site("127.0.0.1", client_port)
+            self.dbenvClient.repmgr_add_remote_site("127.0.0.1", master_port)
+
+            self.dbenvMaster.rep_set_nsites(2)
+            self.dbenvClient.rep_set_nsites(2)
+
+        self.dbenvMaster.rep_set_priority(10)
+        self.dbenvClient.rep_set_priority(0)
+
+        self.dbenvMaster.rep_set_timeout(db.DB_REP_CONNECTION_RETRY,100123)
+        self.dbenvClient.rep_set_timeout(db.DB_REP_CONNECTION_RETRY,100321)
+        self.assertEqual(self.dbenvMaster.rep_get_timeout(
+            db.DB_REP_CONNECTION_RETRY), 100123)
+        self.assertEqual(self.dbenvClient.rep_get_timeout(
+            db.DB_REP_CONNECTION_RETRY), 100321)
+
+        self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 100234)
+        self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 100432)
+        self.assertEqual(self.dbenvMaster.rep_get_timeout(
+            db.DB_REP_ELECTION_TIMEOUT), 100234)
+        self.assertEqual(self.dbenvClient.rep_get_timeout(
+            db.DB_REP_ELECTION_TIMEOUT), 100432)
+
+        self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_RETRY, 100345)
+        self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_RETRY, 100543)
+        self.assertEqual(self.dbenvMaster.rep_get_timeout(
+            db.DB_REP_ELECTION_RETRY), 100345)
+        self.assertEqual(self.dbenvClient.rep_get_timeout(
+            db.DB_REP_ELECTION_RETRY), 100543)
+
+        self.dbenvMaster.repmgr_set_ack_policy(db.DB_REPMGR_ACKS_ALL)
+        self.dbenvClient.repmgr_set_ack_policy(db.DB_REPMGR_ACKS_ALL)
+
+        self.dbenvMaster.repmgr_start(1, db.DB_REP_MASTER);
+        self.dbenvClient.repmgr_start(1, db.DB_REP_CLIENT);
+
+        self.assertEqual(self.dbenvMaster.rep_get_nsites(),2)
+        self.assertEqual(self.dbenvClient.rep_get_nsites(),2)
+        self.assertEqual(self.dbenvMaster.rep_get_priority(),10)
+        self.assertEqual(self.dbenvClient.rep_get_priority(),0)
+        self.assertEqual(self.dbenvMaster.repmgr_get_ack_policy(),
+                db.DB_REPMGR_ACKS_ALL)
+        self.assertEqual(self.dbenvClient.repmgr_get_ack_policy(),
+                db.DB_REPMGR_ACKS_ALL)
+
+        # The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
+        # is not generated if the master has no new transactions.
+        # This is solved in BDB 4.6 (#15542).
+        import time
+        timeout = time.time()+60
+        while (time.time()<timeout) and not (self.confirmed_master and self.client_startupdone) :
+            time.sleep(0.02)
+        # self.client_startupdone does not always get set to True within
+        # the timeout.  On windows this may be a deep issue, on other
+        # platforms it is likely just a timing issue, especially on slow
+        # virthost buildbots (see issue 3892 for more).  Even though
+        # the timeout triggers, the rest of this test method usually passes
+        # (but not all of it always, see below).  So we just note the
+        # timeout on stderr and keep soldering on.
+        if time.time()>timeout:
+            import sys
+            print >> sys.stderr, ("XXX: timeout happened before"
+                "startup was confirmed - see issue 3892")
+            startup_timeout = True
+
+        d = self.dbenvMaster.repmgr_site_list()
+        self.assertEqual(len(d), 1)
+        d = d.values()[0]  # There is only one
+        self.assertEqual(d[0], "127.0.0.1")
+        self.assertEqual(d[1], client_port)
+        self.assertTrue((d[2]==db.DB_REPMGR_CONNECTED) or \
+                (d[2]==db.DB_REPMGR_DISCONNECTED))
+
+        d = self.dbenvClient.repmgr_site_list()
+        self.assertEqual(len(d), 1)
+        d = d.values()[0]  # There is only one
+        self.assertEqual(d[0], "127.0.0.1")
+        self.assertEqual(d[1], master_port)
+        self.assertTrue((d[2]==db.DB_REPMGR_CONNECTED) or \
+                (d[2]==db.DB_REPMGR_DISCONNECTED))
+
+        if db.version() >= (4,6) :
+            d = self.dbenvMaster.repmgr_stat(flags=db.DB_STAT_CLEAR);
+            self.assertTrue("msgs_queued" in d)
+
+        self.dbMaster=db.DB(self.dbenvMaster)
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.open("test", db.DB_HASH, db.DB_CREATE, 0666, txn=txn)
+        txn.commit()
+
+        import time,os.path
+        timeout=time.time()+10
+        while (time.time()<timeout) and \
+          not (os.path.exists(os.path.join(self.homeDirClient,"test"))) :
+            time.sleep(0.01)
+
+        self.dbClient=db.DB(self.dbenvClient)
+        while True :
+            txn=self.dbenvClient.txn_begin()
+            try :
+                self.dbClient.open("test", db.DB_HASH, flags=db.DB_RDONLY,
+                        mode=0666, txn=txn)
+            except db.DBRepHandleDeadError :
+                txn.abort()
+                self.dbClient.close()
+                self.dbClient=db.DB(self.dbenvClient)
+                continue
+
+            txn.commit()
+            break
+
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.put("ABC", "123", txn=txn)
+        txn.commit()
+        import time
+        timeout=time.time()+10
+        v=None
+        while (time.time()<timeout) and (v is None) :
+            txn=self.dbenvClient.txn_begin()
+            v=self.dbClient.get("ABC", txn=txn)
+            txn.commit()
+            if v is None :
+                time.sleep(0.02)
+        # If startup did not happen before the timeout above, then this test
+        # sometimes fails.  This happens randomly, which causes buildbot
+        # instability, but all the other bsddb tests pass.  Since bsddb3 in the
+        # stdlib is currently not getting active maintenance, and is gone in
+        # py3k, we just skip the end of the test in that case.
+        if time.time()>=timeout and startup_timeout:
+            self.skipTest("replication test skipped due to random failure, "
+                "see issue 3892")
+        self.assertTrue(time.time()<timeout)
+        self.assertEqual("123", v)
+
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.delete("ABC", txn=txn)
+        txn.commit()
+        timeout=time.time()+10
+        while (time.time()<timeout) and (v is not None) :
+            txn=self.dbenvClient.txn_begin()
+            v=self.dbClient.get("ABC", txn=txn)
+            txn.commit()
+            if v is None :
+                time.sleep(0.02)
+        self.assertTrue(time.time()<timeout)
+        self.assertEqual(None, v)
+
+class DBBaseReplication(DBReplication) :
+    def setUp(self) :
+        DBReplication.setUp(self)
+        def confirmed_master(a,b,c) :
+            if (b == db.DB_EVENT_REP_MASTER) or (b == db.DB_EVENT_REP_ELECTED) :
+                self.confirmed_master = True
+
+        def client_startupdone(a,b,c) :
+            if b == db.DB_EVENT_REP_STARTUPDONE :
+                self.client_startupdone = True
+
+        self.dbenvMaster.set_event_notify(confirmed_master)
+        self.dbenvClient.set_event_notify(client_startupdone)
+
+        import Queue
+        self.m2c = Queue.Queue()
+        self.c2m = Queue.Queue()
+
+        # There are only two nodes, so we don't need to
+        # do any routing decision
+        def m2c(dbenv, control, rec, lsnp, envid, flags) :
+            self.m2c.put((control, rec))
+
+        def c2m(dbenv, control, rec, lsnp, envid, flags) :
+            self.c2m.put((control, rec))
+
+        self.dbenvMaster.rep_set_transport(13,m2c)
+        self.dbenvMaster.rep_set_priority(10)
+        self.dbenvClient.rep_set_transport(3,c2m)
+        self.dbenvClient.rep_set_priority(0)
+
+        self.assertEqual(self.dbenvMaster.rep_get_priority(),10)
+        self.assertEqual(self.dbenvClient.rep_get_priority(),0)
+
+        #self.dbenvMaster.set_verbose(db.DB_VERB_REPLICATION, True)
+        #self.dbenvMaster.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
+        #self.dbenvClient.set_verbose(db.DB_VERB_REPLICATION, True)
+        #self.dbenvClient.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
+
+        def thread_master() :
+            return self.thread_do(self.dbenvMaster, self.c2m, 3,
+                    self.master_doing_election, True)
+
+        def thread_client() :
+            return self.thread_do(self.dbenvClient, self.m2c, 13,
+                    self.client_doing_election, False)
+
+        from threading import Thread
+        t_m=Thread(target=thread_master)
+        t_c=Thread(target=thread_client)
+        import sys
+        if sys.version_info[0] < 3 :
+            t_m.setDaemon(True)
+            t_c.setDaemon(True)
+        else :
+            t_m.daemon = True
+            t_c.daemon = True
+
+        self.t_m = t_m
+        self.t_c = t_c
+
+        self.dbMaster = self.dbClient = None
+
+        self.master_doing_election=[False]
+        self.client_doing_election=[False]
+
+
+    def tearDown(self):
+        if self.dbClient :
+            self.dbClient.close()
+        if self.dbMaster :
+            self.dbMaster.close()
+        self.m2c.put(None)
+        self.c2m.put(None)
+        self.t_m.join()
+        self.t_c.join()
+
+        # Here we assign dummy event handlers to allow GC of the test object.
+        # Since the dummy handler doesn't use any outer scope variable, it
+        # doesn't keep any reference to the test object.
+        def dummy(*args) :
+            pass
+        self.dbenvMaster.set_event_notify(dummy)
+        self.dbenvClient.set_event_notify(dummy)
+        self.dbenvMaster.rep_set_transport(13,dummy)
+        self.dbenvClient.rep_set_transport(3,dummy)
+
+        self.dbenvClient.close()
+        self.dbenvMaster.close()
+        test_support.rmtree(self.homeDirClient)
+        test_support.rmtree(self.homeDirMaster)
+
+    def basic_rep_threading(self) :
+        self.dbenvMaster.rep_start(flags=db.DB_REP_MASTER)
+        self.dbenvClient.rep_start(flags=db.DB_REP_CLIENT)
+
+        def thread_do(env, q, envid, election_status, must_be_master) :
+            while True :
+                v=q.get()
+                if v is None : return
+                env.rep_process_message(v[0], v[1], envid)
+
+        self.thread_do = thread_do
+
+        self.t_m.start()
+        self.t_c.start()
+
+    def test01_basic_replication(self) :
+        self.basic_rep_threading()
+
+        # The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
+        # is not generated if the master has no new transactions.
+        # This is solved in BDB 4.6 (#15542).
+        import time
+        timeout = time.time()+60
+        while (time.time()<timeout) and not (self.confirmed_master and
+                self.client_startupdone) :
+            time.sleep(0.02)
+        self.assertTrue(time.time()<timeout)
+
+        self.dbMaster=db.DB(self.dbenvMaster)
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.open("test", db.DB_HASH, db.DB_CREATE, 0666, txn=txn)
+        txn.commit()
+
+        import time,os.path
+        timeout=time.time()+10
+        while (time.time()<timeout) and \
+          not (os.path.exists(os.path.join(self.homeDirClient,"test"))) :
+            time.sleep(0.01)
+
+        self.dbClient=db.DB(self.dbenvClient)
+        while True :
+            txn=self.dbenvClient.txn_begin()
+            try :
+                self.dbClient.open("test", db.DB_HASH, flags=db.DB_RDONLY,
+                        mode=0666, txn=txn)
+            except db.DBRepHandleDeadError :
+                txn.abort()
+                self.dbClient.close()
+                self.dbClient=db.DB(self.dbenvClient)
+                continue
+
+            txn.commit()
+            break
+
+        d = self.dbenvMaster.rep_stat(flags=db.DB_STAT_CLEAR);
+        self.assertTrue("master_changes" in d)
+
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.put("ABC", "123", txn=txn)
+        txn.commit()
+        import time
+        timeout=time.time()+10
+        v=None
+        while (time.time()<timeout) and (v is None) :
+            txn=self.dbenvClient.txn_begin()
+            v=self.dbClient.get("ABC", txn=txn)
+            txn.commit()
+            if v is None :
+                time.sleep(0.02)
+        self.assertTrue(time.time()<timeout)
+        self.assertEqual("123", v)
+
+        txn=self.dbenvMaster.txn_begin()
+        self.dbMaster.delete("ABC", txn=txn)
+        txn.commit()
+        timeout=time.time()+10
+        while (time.time()<timeout) and (v is not None) :
+            txn=self.dbenvClient.txn_begin()
+            v=self.dbClient.get("ABC", txn=txn)
+            txn.commit()
+            if v is None :
+                time.sleep(0.02)
+        self.assertTrue(time.time()<timeout)
+        self.assertEqual(None, v)
+
+    if db.version() >= (4,7) :
+        def test02_test_request(self) :
+            self.basic_rep_threading()
+            (minimum, maximum) = self.dbenvClient.rep_get_request()
+            self.dbenvClient.rep_set_request(minimum-1, maximum+1)
+            self.assertEqual(self.dbenvClient.rep_get_request(),
+                    (minimum-1, maximum+1))
+
+    if db.version() >= (4,6) :
+        def test03_master_election(self) :
+            # Get ready to hold an election
+            #self.dbenvMaster.rep_start(flags=db.DB_REP_MASTER)
+            self.dbenvMaster.rep_start(flags=db.DB_REP_CLIENT)
+            self.dbenvClient.rep_start(flags=db.DB_REP_CLIENT)
+
+            def thread_do(env, q, envid, election_status, must_be_master) :
+                while True :
+                    v=q.get()
+                    if v is None : return
+                    r = env.rep_process_message(v[0],v[1],envid)
+                    if must_be_master and self.confirmed_master :
+                        self.dbenvMaster.rep_start(flags = db.DB_REP_MASTER)
+                        must_be_master = False
+
+                    if r[0] == db.DB_REP_HOLDELECTION :
+                        def elect() :
+                            while True :
+                                try :
+                                    env.rep_elect(2, 1)
+                                    election_status[0] = False
+                                    break
+                                except db.DBRepUnavailError :
+                                    pass
+                        if not election_status[0] and not self.confirmed_master :
+                            from threading import Thread
+                            election_status[0] = True
+                            t=Thread(target=elect)
+                            import sys
+                            if sys.version_info[0] < 3 :
+                                t.setDaemon(True)
+                            else :
+                                t.daemon = True
+                            t.start()
+
+            self.thread_do = thread_do
+
+            self.t_m.start()
+            self.t_c.start()
+
+            self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 50000)
+            self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 50000)
+            self.client_doing_election[0] = True
+            while True :
+                try :
+                    self.dbenvClient.rep_elect(2, 1)
+                    self.client_doing_election[0] = False
+                    break
+                except db.DBRepUnavailError :
+                    pass
+
+            self.assertTrue(self.confirmed_master)
+
+            # Race condition showed up after upgrading to Solaris 10 Update 10
+            # https://forums.oracle.com/forums/thread.jspa?messageID=9902860
+            # jcea@jcea.es: See private email from Paula Bingham (Oracle),
+            # in 20110929.
+            while not (self.dbenvClient.rep_stat()["startup_complete"]) :
+                pass
+
+    if db.version() >= (4,7) :
+        def test04_test_clockskew(self) :
+            fast, slow = 1234, 1230
+            self.dbenvMaster.rep_set_clockskew(fast, slow)
+            self.assertEqual((fast, slow),
+                    self.dbenvMaster.rep_get_clockskew())
+            self.basic_rep_threading()
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+    if db.version() >= (4, 6) :
+        dbenv = db.DBEnv()
+        try :
+            dbenv.repmgr_get_ack_policy()
+            ReplicationManager_available=True
+        except :
+            ReplicationManager_available=False
+        dbenv.close()
+        del dbenv
+        if ReplicationManager_available :
+            suite.addTest(unittest.makeSuite(DBReplicationManager))
+
+        if have_threads :
+            suite.addTest(unittest.makeSuite(DBBaseReplication))
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_sequence.py b/lib/python2.7/bsddb/test/test_sequence.py
new file mode 100644
index 0000000..f0aa12a
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_sequence.py
@@ -0,0 +1,136 @@
+import unittest
+import os
+
+from test_all import db, test_support, get_new_environment_path, get_new_database_path
+
+
+class DBSequenceTest(unittest.TestCase):
+    def setUp(self):
+        self.int_32_max = 0x100000000
+        self.homeDir = get_new_environment_path()
+        self.filename = "test"
+
+        self.dbenv = db.DBEnv()
+        self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666)
+        self.d = db.DB(self.dbenv)
+        self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666)
+
+    def tearDown(self):
+        if hasattr(self, 'seq'):
+            self.seq.close()
+            del self.seq
+        if hasattr(self, 'd'):
+            self.d.close()
+            del self.d
+        if hasattr(self, 'dbenv'):
+            self.dbenv.close()
+            del self.dbenv
+
+        test_support.rmtree(self.homeDir)
+
+    def test_get(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        start_value = 10 * self.int_32_max
+        self.assertEqual(0xA00000000, start_value)
+        self.assertEqual(None, self.seq.initial_value(start_value))
+        self.assertEqual(None, self.seq.open(key='id', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(start_value, self.seq.get(5))
+        self.assertEqual(start_value + 5, self.seq.get())
+
+    def test_remove(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(None, self.seq.remove(txn=None, flags=0))
+        del self.seq
+
+    def test_get_key(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        key = 'foo'
+        self.assertEqual(None, self.seq.open(key=key, txn=None, flags=db.DB_CREATE))
+        self.assertEqual(key, self.seq.get_key())
+
+    def test_get_dbp(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(self.d, self.seq.get_dbp())
+
+    def test_cachesize(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        cashe_size = 10
+        self.assertEqual(None, self.seq.set_cachesize(cashe_size))
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(cashe_size, self.seq.get_cachesize())
+
+    def test_flags(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        flag = db.DB_SEQ_WRAP;
+        self.assertEqual(None, self.seq.set_flags(flag))
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(flag, self.seq.get_flags() & flag)
+
+    def test_range(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        seq_range = (10 * self.int_32_max, 11 * self.int_32_max - 1)
+        self.assertEqual(None, self.seq.set_range(seq_range))
+        self.seq.initial_value(seq_range[0])
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        self.assertEqual(seq_range, self.seq.get_range())
+
+    def test_stat(self):
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
+        stat = self.seq.stat()
+        for param in ('nowait', 'min', 'max', 'value', 'current',
+                      'flags', 'cache_size', 'last_value', 'wait'):
+            self.assertTrue(param in stat, "parameter %s isn't in stat info" % param)
+
+    if db.version() >= (4,7) :
+        # This code checks a crash solved in Berkeley DB 4.7
+        def test_stat_crash(self) :
+            d=db.DB()
+            d.open(None,dbtype=db.DB_HASH,flags=db.DB_CREATE)  # In RAM
+            seq = db.DBSequence(d, flags=0)
+
+            self.assertRaises(db.DBNotFoundError, seq.open,
+                    key='id', txn=None, flags=0)
+
+            self.assertRaises(db.DBInvalidArgError, seq.stat)
+
+            d.close()
+
+    def test_64bits(self) :
+        # We don't use both extremes because they are problematic
+        value_plus=(1L<<63)-2
+        self.assertEqual(9223372036854775806L,value_plus)
+        value_minus=(-1L<<63)+1  # Two complement
+        self.assertEqual(-9223372036854775807L,value_minus)
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEqual(None, self.seq.initial_value(value_plus-1))
+        self.assertEqual(None, self.seq.open(key='id', txn=None,
+            flags=db.DB_CREATE))
+        self.assertEqual(value_plus-1, self.seq.get(1))
+        self.assertEqual(value_plus, self.seq.get(1))
+
+        self.seq.remove(txn=None, flags=0)
+
+        self.seq = db.DBSequence(self.d, flags=0)
+        self.assertEqual(None, self.seq.initial_value(value_minus))
+        self.assertEqual(None, self.seq.open(key='id', txn=None,
+            flags=db.DB_CREATE))
+        self.assertEqual(value_minus, self.seq.get(1))
+        self.assertEqual(value_minus+1, self.seq.get(1))
+
+    def test_multiple_close(self):
+        self.seq = db.DBSequence(self.d)
+        self.seq.close()  # You can close a Sequence multiple times
+        self.seq.close()
+        self.seq.close()
+
+def test_suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(DBSequenceTest))
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/bsddb/test/test_thread.py b/lib/python2.7/bsddb/test/test_thread.py
new file mode 100644
index 0000000..42212e9
--- /dev/null
+++ b/lib/python2.7/bsddb/test/test_thread.py
@@ -0,0 +1,517 @@
+"""TestCases for multi-threaded access to a DB.
+"""
+
+import os
+import sys
+import time
+import errno
+from random import random
+
+DASH = '-'
+
+try:
+    WindowsError
+except NameError:
+    class WindowsError(Exception):
+        pass
+
+import unittest
+from test_all import db, dbutils, test_support, verbose, have_threads, \
+        get_new_environment_path, get_new_database_path
+
+if have_threads :
+    from threading import Thread
+    if sys.version_info[0] < 3 :
+        from threading import currentThread
+    else :
+        from threading import current_thread as currentThread
+
+
+#----------------------------------------------------------------------
+
+class BaseThreadedTestCase(unittest.TestCase):
+    dbtype       = db.DB_UNKNOWN  # must be set in derived class
+    dbopenflags  = 0
+    dbsetflags   = 0
+    envflags     = 0
+
+    def setUp(self):
+        if verbose:
+            dbutils._deadlock_VerboseFile = sys.stdout
+
+        self.homeDir = get_new_environment_path()
+        self.env = db.DBEnv()
+        self.setEnvOpts()
+        self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
+
+        self.filename = self.__class__.__name__ + '.db'
+        self.d = db.DB(self.env)
+        if self.dbsetflags:
+            self.d.set_flags(self.dbsetflags)
+        self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE)
+
+    def tearDown(self):
+        self.d.close()
+        self.env.close()
+        test_support.rmtree(self.homeDir)
+
+    def setEnvOpts(self):
+        pass
+
+    def makeData(self, key):
+        return DASH.join([key] * 5)
+
+
+#----------------------------------------------------------------------
+
+
+class ConcurrentDataStoreBase(BaseThreadedTestCase):
+    dbopenflags = db.DB_THREAD
+    envflags    = db.DB_THREAD | db.DB_INIT_CDB | db.DB_INIT_MPOOL
+    readers     = 0 # derived class should set
+    writers     = 0
+    records     = 1000
+
+    def test01_1WriterMultiReaders(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test01_1WriterMultiReaders..." % \
+                  self.__class__.__name__
+
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records//self.writers
+        readers_per_writer=self.readers//self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
+        readers = []
+
+        for x in xrange(self.readers):
+            rt = Thread(target = self.readerThread,
+                        args = (self.d, x),
+                        name = 'reader %d' % x,
+                        )#verbose = verbose)
+            if sys.version_info[0] < 3 :
+                rt.setDaemon(True)
+            else :
+                rt.daemon = True
+            readers.append(rt)
+
+        writers=[]
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            a.sort()  # Generate conflicts
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
+
+        for t in writers:
+            if sys.version_info[0] < 3 :
+                t.setDaemon(True)
+            else :
+                t.daemon = True
+            t.start()
+
+        for t in writers:
+            t.join()
+        for t in readers:
+            t.join()
+
+    def writerThread(self, d, keys, readers):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        if verbose:
+            print "%s: creating records %d - %d" % (name, start, stop)
+
+        count=len(keys)//len(readers)
+        count2=count
+        for x in keys :
+            key = '%04d' % x
+            dbutils.DeadlockWrap(d.put, key, self.makeData(key),
+                                 max_retries=12)
+            if verbose and x % 100 == 0:
+                print "%s: records %d - %d finished" % (name, start, x)
+
+            count2-=1
+            if not count2 :
+                readers.pop().start()
+                count2=count
+
+        if verbose:
+            print "%s: finished creating records" % name
+
+        if verbose:
+            print "%s: thread finished" % name
+
+    def readerThread(self, d, readerNum):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        for i in xrange(5) :
+            c = d.cursor()
+            count = 0
+            rec = c.first()
+            while rec:
+                count += 1
+                key, data = rec
+                self.assertEqual(self.makeData(key), data)
+                rec = c.next()
+            if verbose:
+                print "%s: found %d records" % (name, count)
+            c.close()
+
+        if verbose:
+            print "%s: thread finished" % name
+
+
+class BTreeConcurrentDataStore(ConcurrentDataStoreBase):
+    dbtype  = db.DB_BTREE
+    writers = 2
+    readers = 10
+    records = 1000
+
+
+class HashConcurrentDataStore(ConcurrentDataStoreBase):
+    dbtype  = db.DB_HASH
+    writers = 2
+    readers = 10
+    records = 1000
+
+
+#----------------------------------------------------------------------
+
+class SimpleThreadedBase(BaseThreadedTestCase):
+    dbopenflags = db.DB_THREAD
+    envflags    = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
+    readers = 10
+    writers = 2
+    records = 1000
+
+    def setEnvOpts(self):
+        self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
+
+    def test02_SimpleLocks(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test02_SimpleLocks..." % self.__class__.__name__
+
+
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records//self.writers
+        readers_per_writer=self.readers//self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
+
+        readers = []
+        for x in xrange(self.readers):
+            rt = Thread(target = self.readerThread,
+                        args = (self.d, x),
+                        name = 'reader %d' % x,
+                        )#verbose = verbose)
+            if sys.version_info[0] < 3 :
+                rt.setDaemon(True)
+            else :
+                rt.daemon = True
+            readers.append(rt)
+
+        writers = []
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            a.sort()  # Generate conflicts
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
+
+        for t in writers:
+            if sys.version_info[0] < 3 :
+                t.setDaemon(True)
+            else :
+                t.daemon = True
+            t.start()
+
+        for t in writers:
+            t.join()
+        for t in readers:
+            t.join()
+
+    def writerThread(self, d, keys, readers):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+        if verbose:
+            print "%s: creating records %d - %d" % (name, start, stop)
+
+        count=len(keys)//len(readers)
+        count2=count
+        for x in keys :
+            key = '%04d' % x
+            dbutils.DeadlockWrap(d.put, key, self.makeData(key),
+                                 max_retries=12)
+
+            if verbose and x % 100 == 0:
+                print "%s: records %d - %d finished" % (name, start, x)
+
+            count2-=1
+            if not count2 :
+                readers.pop().start()
+                count2=count
+
+        if verbose:
+            print "%s: thread finished" % name
+
+    def readerThread(self, d, readerNum):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        c = d.cursor()
+        count = 0
+        rec = dbutils.DeadlockWrap(c.first, max_retries=10)
+        while rec:
+            count += 1
+            key, data = rec
+            self.assertEqual(self.makeData(key), data)
+            rec = dbutils.DeadlockWrap(c.next, max_retries=10)
+        if verbose:
+            print "%s: found %d records" % (name, count)
+        c.close()
+
+        if verbose:
+            print "%s: thread finished" % name
+
+
+class BTreeSimpleThreaded(SimpleThreadedBase):
+    dbtype = db.DB_BTREE
+
+
+class HashSimpleThreaded(SimpleThreadedBase):
+    dbtype = db.DB_HASH
+
+
+#----------------------------------------------------------------------
+
+
+class ThreadedTransactionsBase(BaseThreadedTestCase):
+    dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT
+    envflags    = (db.DB_THREAD |
+                   db.DB_INIT_MPOOL |
+                   db.DB_INIT_LOCK |
+                   db.DB_INIT_LOG |
+                   db.DB_INIT_TXN
+                   )
+    readers = 0
+    writers = 0
+    records = 2000
+    txnFlag = 0
+
+    def setEnvOpts(self):
+        #self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
+        pass
+
+    def test03_ThreadedTransactions(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_ThreadedTransactions..." % \
+                  self.__class__.__name__
+
+        keys=range(self.records)
+        import random
+        random.shuffle(keys)
+        records_per_writer=self.records//self.writers
+        readers_per_writer=self.readers//self.writers
+        self.assertEqual(self.records,self.writers*records_per_writer)
+        self.assertEqual(self.readers,self.writers*readers_per_writer)
+        self.assertTrue((records_per_writer%readers_per_writer)==0)
+
+        readers=[]
+        for x in xrange(self.readers):
+            rt = Thread(target = self.readerThread,
+                        args = (self.d, x),
+                        name = 'reader %d' % x,
+                        )#verbose = verbose)
+            if sys.version_info[0] < 3 :
+                rt.setDaemon(True)
+            else :
+                rt.daemon = True
+            readers.append(rt)
+
+        writers = []
+        for x in xrange(self.writers):
+            a=keys[records_per_writer*x:records_per_writer*(x+1)]
+            b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
+            wt = Thread(target = self.writerThread,
+                        args = (self.d, a, b),
+                        name = 'writer %d' % x,
+                        )#verbose = verbose)
+            writers.append(wt)
+
+        dt = Thread(target = self.deadlockThread)
+        if sys.version_info[0] < 3 :
+            dt.setDaemon(True)
+        else :
+            dt.daemon = True
+        dt.start()
+
+        for t in writers:
+            if sys.version_info[0] < 3 :
+                t.setDaemon(True)
+            else :
+                t.daemon = True
+            t.start()
+
+        for t in writers:
+            t.join()
+        for t in readers:
+            t.join()
+
+        self.doLockDetect = False
+        dt.join()
+
+    def writerThread(self, d, keys, readers):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        count=len(keys)//len(readers)
+        while len(keys):
+            try:
+                txn = self.env.txn_begin(None, self.txnFlag)
+                keys2=keys[:count]
+                for x in keys2 :
+                    key = '%04d' % x
+                    d.put(key, self.makeData(key), txn)
+                    if verbose and x % 100 == 0:
+                        print "%s: records %d - %d finished" % (name, start, x)
+                txn.commit()
+                keys=keys[count:]
+                readers.pop().start()
+            except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
+                if verbose:
+                    if sys.version_info < (2, 6) :
+                        print "%s: Aborting transaction (%s)" % (name, val[1])
+                    else :
+                        print "%s: Aborting transaction (%s)" % (name,
+                                val.args[1])
+                txn.abort()
+
+        if verbose:
+            print "%s: thread finished" % name
+
+    def readerThread(self, d, readerNum):
+        if sys.version_info[0] < 3 :
+            name = currentThread().getName()
+        else :
+            name = currentThread().name
+
+        finished = False
+        while not finished:
+            try:
+                txn = self.env.txn_begin(None, self.txnFlag)
+                c = d.cursor(txn)
+                count = 0
+                rec = c.first()
+                while rec:
+                    count += 1
+                    key, data = rec
+                    self.assertEqual(self.makeData(key), data)
+                    rec = c.next()
+                if verbose: print "%s: found %d records" % (name, count)
+                c.close()
+                txn.commit()
+                finished = True
+            except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
+                if verbose:
+                    if sys.version_info < (2, 6) :
+                        print "%s: Aborting transaction (%s)" % (name, val[1])
+                    else :
+                        print "%s: Aborting transaction (%s)" % (name,
+                                val.args[1])
+                c.close()
+                txn.abort()
+
+        if verbose:
+            print "%s: thread finished" % name
+
+    def deadlockThread(self):
+        self.doLockDetect = True
+        while self.doLockDetect:
+            time.sleep(0.05)
+            try:
+                aborted = self.env.lock_detect(
+                    db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT)
+                if verbose and aborted:
+                    print "deadlock: Aborted %d deadlocked transaction(s)" \
+                          % aborted
+            except db.DBError:
+                pass
+
+
+class BTreeThreadedTransactions(ThreadedTransactionsBase):
+    dbtype = db.DB_BTREE
+    writers = 2
+    readers = 10
+    records = 1000
+
+class HashThreadedTransactions(ThreadedTransactionsBase):
+    dbtype = db.DB_HASH
+    writers = 2
+    readers = 10
+    records = 1000
+
+class BTreeThreadedNoWaitTransactions(ThreadedTransactionsBase):
+    dbtype = db.DB_BTREE
+    writers = 2
+    readers = 10
+    records = 1000
+    txnFlag = db.DB_TXN_NOWAIT
+
+class HashThreadedNoWaitTransactions(ThreadedTransactionsBase):
+    dbtype = db.DB_HASH
+    writers = 2
+    readers = 10
+    records = 1000
+    txnFlag = db.DB_TXN_NOWAIT
+
+
+#----------------------------------------------------------------------
+
+def test_suite():
+    suite = unittest.TestSuite()
+
+    if have_threads:
+        suite.addTest(unittest.makeSuite(BTreeConcurrentDataStore))
+        suite.addTest(unittest.makeSuite(HashConcurrentDataStore))
+        suite.addTest(unittest.makeSuite(BTreeSimpleThreaded))
+        suite.addTest(unittest.makeSuite(HashSimpleThreaded))
+        suite.addTest(unittest.makeSuite(BTreeThreadedTransactions))
+        suite.addTest(unittest.makeSuite(HashThreadedTransactions))
+        suite.addTest(unittest.makeSuite(BTreeThreadedNoWaitTransactions))
+        suite.addTest(unittest.makeSuite(HashThreadedNoWaitTransactions))
+
+    else:
+        print "Threads not available, skipping thread tests."
+
+    return suite
+
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
diff --git a/lib/python2.7/config/Makefile b/lib/python2.7/config/Makefile
index ee2059b..e2c66ac 100644
--- a/lib/python2.7/config/Makefile
+++ b/lib/python2.7/config/Makefile
@@ -26,11 +26,11 @@
 
 # === Variables set by configure
 VERSION=	2.7
-srcdir=		/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5
-VPATH=		/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5
-MSYSVPATH=	/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5
-abs_srcdir=	/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5
-abs_builddir=	/buildbot/tmp/buildhost/build-python-darwin-x86_64-2.7.5
+srcdir=		/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5
+VPATH=		/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5
+MSYSVPATH=	/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5
+abs_srcdir=	/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5
+abs_builddir=	/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/build-python-darwin-x86_64-2.7.5
 build=		x86_64-apple-darwin
 host=		x86_64-apple-darwin
 
@@ -63,7 +63,7 @@
 # Also, making them read-only seems to be a good idea...
 INSTALL_SHARED= ${INSTALL} -m 555
 
-MKDIR_P=	/Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/install-sh -c -d
+MKDIR_P=	/Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/install-sh -c -d
 
 MAKESETUP=      $(srcdir)/Modules/makesetup
 
@@ -95,7 +95,7 @@
 MULTIARCH=	
 
 # Install prefix for architecture-independent files
-prefix=		/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64
+prefix=		/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools
 
 # Install prefix for architecture-dependent files
 exec_prefix=	${prefix}
@@ -154,7 +154,7 @@
 FILEMODE=	644
 
 # configure script arguments
-CONFIG_ARGS=	 '--prefix=/buildbot/tmp/buildhost/install/prebuilt/darwin-x86_64' '--build=x86_64-apple-darwin' '--host=x86_64-apple-darwin' '--with-build-sysroot' '--disable-ipv6' 'build_alias=x86_64-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=x86_64-apple-darwin-gcc' 'CFLAGS=-O2 -Os -fomit-frame-pointer -s' 'LDFLAGS='
+CONFIG_ARGS=	 '--prefix=/Volumes/Android/buildbot/src/android/master-ndk/out/build/buildhost/darwin-x86_64/install/host-tools' '--build=x86_64-apple-darwin' '--host=x86_64-apple-darwin' '--with-build-sysroot' '--disable-ipv6' 'build_alias=x86_64-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=x86_64-apple-darwin-gcc' 'CFLAGS=-O2 -Os -fomit-frame-pointer -s' 'LDFLAGS='
 
 
 # Subdirectories with code
@@ -540,7 +540,7 @@
 # for a shared core library; otherwise, this rule is a noop.
 $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
 	if test -n "$(DLLLIBRARY)"; then \
-		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
+		$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) -static-libgcc $^ \
 			$(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
 	else true; \
 	fi
diff --git a/lib/python2.7/config/config.c b/lib/python2.7/config/config.c
index 671a4f4..c727edd 100644
--- a/lib/python2.7/config/config.c
+++ b/lib/python2.7/config/config.c
@@ -1,4 +1,4 @@
-/* Generated automatically from /Volumes/Android/buildbot/repo_clients/https___android.googlesource.com_a_platform_manifest.git/master-ndk/toolchain/python/Python-2.7.5/Modules/config.c.in by makesetup. */
+/* Generated automatically from /Volumes/Android/buildbot/src/android/master-ndk/toolchain/python/Python-2.7.5/Modules/config.c.in by makesetup. */
 /* -*- C -*- ***********************************************
 Copyright (c) 2000, BeOpen.com.
 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
diff --git a/lib/python2.7/config/libpython2.7.a b/lib/python2.7/config/libpython2.7.a
index 51c16b3..8ab07ee 100644
--- a/lib/python2.7/config/libpython2.7.a
+++ b/lib/python2.7/config/libpython2.7.a
Binary files differ
diff --git a/lib/python2.7/ctypes/test/__init__.py b/lib/python2.7/ctypes/test/__init__.py
new file mode 100644
index 0000000..808e418
--- /dev/null
+++ b/lib/python2.7/ctypes/test/__init__.py
@@ -0,0 +1,208 @@
+import os, sys, unittest, getopt, time
+
+use_resources = []
+
+class ResourceDenied(Exception):
+    """Test skipped because it requested a disallowed resource.
+
+    This is raised when a test calls requires() for a resource that
+    has not be enabled.  Resources are defined by test modules.
+    """
+
+def is_resource_enabled(resource):
+    """Test whether a resource is enabled.
+
+    If the caller's module is __main__ then automatically return True."""
+    if sys._getframe().f_back.f_globals.get("__name__") == "__main__":
+        return True
+    result = use_resources is not None and \
+           (resource in use_resources or "*" in use_resources)
+    if not result:
+        _unavail[resource] = None
+    return result
+
+_unavail = {}
+def requires(resource, msg=None):
+    """Raise ResourceDenied if the specified resource is not available.
+
+    If the caller's module is __main__ then automatically return True."""
+    # see if the caller's module is __main__ - if so, treat as if
+    # the resource was set
+    if sys._getframe().f_back.f_globals.get("__name__") == "__main__":
+        return
+    if not is_resource_enabled(resource):
+        if msg is None:
+            msg = "Use of the `%s' resource not enabled" % resource
+        raise ResourceDenied(msg)
+
+def find_package_modules(package, mask):
+    import fnmatch
+    if (hasattr(package, "__loader__") and
+            hasattr(package.__loader__, '_files')):
+        path = package.__name__.replace(".", os.path.sep)
+        mask = os.path.join(path, mask)
+        for fnm in package.__loader__._files.iterkeys():
+            if fnmatch.fnmatchcase(fnm, mask):
+                yield os.path.splitext(fnm)[0].replace(os.path.sep, ".")
+    else:
+        path = package.__path__[0]
+        for fnm in os.listdir(path):
+            if fnmatch.fnmatchcase(fnm, mask):
+                yield "%s.%s" % (package.__name__, os.path.splitext(fnm)[0])
+
+def get_tests(package, mask, verbosity, exclude=()):
+    """Return a list of skipped test modules, and a list of test cases."""
+    tests = []
+    skipped = []
+    for modname in find_package_modules(package, mask):
+        if modname.split(".")[-1] in exclude:
+            skipped.append(modname)
+            if verbosity > 1:
+                print >> sys.stderr, "Skipped %s: excluded" % modname
+            continue
+        try:
+            mod = __import__(modname, globals(), locals(), ['*'])
+        except (ResourceDenied, unittest.SkipTest) as detail:
+            skipped.append(modname)
+            if verbosity > 1:
+                print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
+            continue
+        for name in dir(mod):
+            if name.startswith("_"):
+                continue
+            o = getattr(mod, name)
+            if type(o) is type(unittest.TestCase) and issubclass(o, unittest.TestCase):
+                tests.append(o)
+    return skipped, tests
+
+def usage():
+    print __doc__
+    return 1
+
+def test_with_refcounts(runner, verbosity, testcase):
+    """Run testcase several times, tracking reference counts."""
+    import gc
+    import ctypes
+    ptc = ctypes._pointer_type_cache.copy()
+    cfc = ctypes._c_functype_cache.copy()
+    wfc = ctypes._win_functype_cache.copy()
+
+    # when searching for refcount leaks, we have to manually reset any
+    # caches that ctypes has.
+    def cleanup():
+        ctypes._pointer_type_cache = ptc.copy()
+        ctypes._c_functype_cache = cfc.copy()
+        ctypes._win_functype_cache = wfc.copy()
+        gc.collect()
+
+    test = unittest.makeSuite(testcase)
+    for i in range(5):
+        rc = sys.gettotalrefcount()
+        runner.run(test)
+        cleanup()
+    COUNT = 5
+    refcounts = [None] * COUNT
+    for i in range(COUNT):
+        rc = sys.gettotalrefcount()
+        runner.run(test)
+        cleanup()
+        refcounts[i] = sys.gettotalrefcount() - rc
+    if filter(None, refcounts):
+        print "%s leaks:\n\t" % testcase, refcounts
+    elif verbosity:
+        print "%s: ok." % testcase
+
+class TestRunner(unittest.TextTestRunner):
+    def run(self, test, skipped):
+        "Run the given test case or test suite."
+        # Same as unittest.TextTestRunner.run, except that it reports
+        # skipped tests.
+        result = self._makeResult()
+        startTime = time.time()
+        test(result)
+        stopTime = time.time()
+        timeTaken = stopTime - startTime
+        result.printErrors()
+        self.stream.writeln(result.separator2)
+        run = result.testsRun
+        if _unavail: #skipped:
+            requested = _unavail.keys()
+            requested.sort()
+            self.stream.writeln("Ran %d test%s in %.3fs (%s module%s skipped)" %
+                                (run, run != 1 and "s" or "", timeTaken,
+                                 len(skipped),
+                                 len(skipped) != 1 and "s" or ""))
+            self.stream.writeln("Unavailable resources: %s" % ", ".join(requested))
+        else:
+            self.stream.writeln("Ran %d test%s in %.3fs" %
+                                (run, run != 1 and "s" or "", timeTaken))
+        self.stream.writeln()
+        if not result.wasSuccessful():
+            self.stream.write("FAILED (")
+            failed, errored = map(len, (result.failures, result.errors))
+            if failed:
+                self.stream.write("failures=%d" % failed)
+            if errored:
+                if failed: self.stream.write(", ")
+                self.stream.write("errors=%d" % errored)
+            self.stream.writeln(")")
+        else:
+            self.stream.writeln("OK")
+        return result
+
+
+def main(*packages):
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "rqvu:x:")
+    except getopt.error:
+        return usage()
+
+    verbosity = 1
+    search_leaks = False
+    exclude = []
+    for flag, value in opts:
+        if flag == "-q":
+            verbosity -= 1
+        elif flag == "-v":
+            verbosity += 1
+        elif flag == "-r":
+            try:
+                sys.gettotalrefcount
+            except AttributeError:
+                print >> sys.stderr, "-r flag requires Python debug build"
+                return -1
+            search_leaks = True
+        elif flag == "-u":
+            use_resources.extend(value.split(","))
+        elif flag == "-x":
+            exclude.extend(value.split(","))
+
+    mask = "test_*.py"
+    if args:
+        mask = args[0]
+
+    for package in packages:
+        run_tests(package, mask, verbosity, search_leaks, exclude)
+
+
+def run_tests(package, mask, verbosity, search_leaks, exclude):
+    skipped, testcases = get_tests(package, mask, verbosity, exclude)
+    runner = TestRunner(verbosity=verbosity)
+
+    suites = [unittest.makeSuite(o) for o in testcases]
+    suite = unittest.TestSuite(suites)
+    result = runner.run(suite, skipped)
+
+    if search_leaks:
+        # hunt for refcount leaks
+        runner = BasicTestRunner()
+        for t in testcases:
+            test_with_refcounts(runner, verbosity, t)
+
+    return bool(result.errors)
+
+class BasicTestRunner:
+    def run(self, test):
+        result = unittest.TestResult()
+        test(result)
+        return result
diff --git a/lib/python2.7/ctypes/test/runtests.py b/lib/python2.7/ctypes/test/runtests.py
new file mode 100644
index 0000000..ec31fc8
--- /dev/null
+++ b/lib/python2.7/ctypes/test/runtests.py
@@ -0,0 +1,19 @@
+"""Usage: runtests.py [-q] [-r] [-v] [-u resources] [mask]
+
+Run all tests found in this directory, and print a summary of the results.
+Command line flags:
+  -q     quiet mode: don't prnt anything while the tests are running
+  -r     run tests repeatedly, look for refcount leaks
+  -u<resources>
+         Add resources to the lits of allowed resources. '*' allows all
+         resources.
+  -v     verbose mode: print the test currently executed
+  -x<test1[,test2...]>
+         Exclude specified tests.
+  mask   mask to select filenames containing testcases, wildcards allowed
+"""
+import sys
+import ctypes.test
+
+if __name__ == "__main__":
+    sys.exit(ctypes.test.main(ctypes.test))
diff --git a/lib/python2.7/ctypes/test/test_anon.py b/lib/python2.7/ctypes/test/test_anon.py
new file mode 100644
index 0000000..d892b59
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_anon.py
@@ -0,0 +1,60 @@
+import unittest
+from ctypes import *
+
+class AnonTest(unittest.TestCase):
+
+    def test_anon(self):
+        class ANON(Union):
+            _fields_ = [("a", c_int),
+                        ("b", c_int)]
+
+        class Y(Structure):
+            _fields_ = [("x", c_int),
+                        ("_", ANON),
+                        ("y", c_int)]
+            _anonymous_ = ["_"]
+
+        self.assertEqual(Y.a.offset, sizeof(c_int))
+        self.assertEqual(Y.b.offset, sizeof(c_int))
+
+        self.assertEqual(ANON.a.offset, 0)
+        self.assertEqual(ANON.b.offset, 0)
+
+    def test_anon_nonseq(self):
+        # TypeError: _anonymous_ must be a sequence
+        self.assertRaises(TypeError,
+                              lambda: type(Structure)("Name",
+                                                      (Structure,),
+                                                      {"_fields_": [], "_anonymous_": 42}))
+
+    def test_anon_nonmember(self):
+        # AttributeError: type object 'Name' has no attribute 'x'
+        self.assertRaises(AttributeError,
+                              lambda: type(Structure)("Name",
+                                                      (Structure,),
+                                                      {"_fields_": [],
+                                                       "_anonymous_": ["x"]}))
+
+    def test_nested(self):
+        class ANON_S(Structure):
+            _fields_ = [("a", c_int)]
+
+        class ANON_U(Union):
+            _fields_ = [("_", ANON_S),
+                        ("b", c_int)]
+            _anonymous_ = ["_"]
+
+        class Y(Structure):
+            _fields_ = [("x", c_int),
+                        ("_", ANON_U),
+                        ("y", c_int)]
+            _anonymous_ = ["_"]
+
+        self.assertEqual(Y.x.offset, 0)
+        self.assertEqual(Y.a.offset, sizeof(c_int))
+        self.assertEqual(Y.b.offset, sizeof(c_int))
+        self.assertEqual(Y._.offset, sizeof(c_int))
+        self.assertEqual(Y.y.offset, sizeof(c_int) * 2)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_array_in_pointer.py b/lib/python2.7/ctypes/test/test_array_in_pointer.py
new file mode 100644
index 0000000..ee7863c
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_array_in_pointer.py
@@ -0,0 +1,64 @@
+import unittest
+from ctypes import *
+from binascii import hexlify
+import re
+
+def dump(obj):
+    # helper function to dump memory contents in hex, with a hyphen
+    # between the bytes.
+    h = hexlify(memoryview(obj))
+    return re.sub(r"(..)", r"\1-", h)[:-1]
+
+
+class Value(Structure):
+    _fields_ = [("val", c_byte)]
+
+class Container(Structure):
+    _fields_ = [("pvalues", POINTER(Value))]
+
+class Test(unittest.TestCase):
+    def test(self):
+        # create an array of 4 values
+        val_array = (Value * 4)()
+
+        # create a container, which holds a pointer to the pvalues array.
+        c = Container()
+        c.pvalues = val_array
+
+        # memory contains 4 NUL bytes now, that's correct
+        self.assertEqual("00-00-00-00", dump(val_array))
+
+        # set the values of the array through the pointer:
+        for i in range(4):
+            c.pvalues[i].val = i + 1
+
+        values = [c.pvalues[i].val for i in range(4)]
+
+        # These are the expected results: here s the bug!
+        self.assertEqual(
+            (values, dump(val_array)),
+            ([1, 2, 3, 4], "01-02-03-04")
+        )
+
+    def test_2(self):
+
+        val_array = (Value * 4)()
+
+        # memory contains 4 NUL bytes now, that's correct
+        self.assertEqual("00-00-00-00", dump(val_array))
+
+        ptr = cast(val_array, POINTER(Value))
+        # set the values of the array through the pointer:
+        for i in range(4):
+            ptr[i].val = i + 1
+
+        values = [ptr[i].val for i in range(4)]
+
+        # These are the expected results: here s the bug!
+        self.assertEqual(
+            (values, dump(val_array)),
+            ([1, 2, 3, 4], "01-02-03-04")
+        )
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_arrays.py b/lib/python2.7/ctypes/test/test_arrays.py
new file mode 100644
index 0000000..925f8bf
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_arrays.py
@@ -0,0 +1,134 @@
+import unittest
+from ctypes import *
+
+formats = "bBhHiIlLqQfd"
+
+formats = c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, \
+          c_long, c_ulonglong, c_float, c_double, c_longdouble
+
+class ArrayTestCase(unittest.TestCase):
+    def test_simple(self):
+        # create classes holding simple numeric types, and check
+        # various properties.
+
+        init = range(15, 25)
+
+        for fmt in formats:
+            alen = len(init)
+            int_array = ARRAY(fmt, alen)
+
+            ia = int_array(*init)
+            # length of instance ok?
+            self.assertEqual(len(ia), alen)
+
+            # slot values ok?
+            values = [ia[i] for i in range(len(init))]
+            self.assertEqual(values, init)
+
+            # change the items
+            from operator import setitem
+            new_values = range(42, 42+alen)
+            [setitem(ia, n, new_values[n]) for n in range(alen)]
+            values = [ia[i] for i in range(len(init))]
+            self.assertEqual(values, new_values)
+
+            # are the items initialized to 0?
+            ia = int_array()
+            values = [ia[i] for i in range(len(init))]
+            self.assertEqual(values, [0] * len(init))
+
+            # Too many initializers should be caught
+            self.assertRaises(IndexError, int_array, *range(alen*2))
+
+        CharArray = ARRAY(c_char, 3)
+
+        ca = CharArray("a", "b", "c")
+
+        # Should this work? It doesn't:
+        # CharArray("abc")
+        self.assertRaises(TypeError, CharArray, "abc")
+
+        self.assertEqual(ca[0], "a")
+        self.assertEqual(ca[1], "b")
+        self.assertEqual(ca[2], "c")
+        self.assertEqual(ca[-3], "a")
+        self.assertEqual(ca[-2], "b")
+        self.assertEqual(ca[-1], "c")
+
+        self.assertEqual(len(ca), 3)
+
+        # slicing is now supported, but not extended slicing (3-argument)!
+        from operator import getslice, delitem
+        self.assertRaises(TypeError, getslice, ca, 0, 1, -1)
+
+        # cannot delete items
+        self.assertRaises(TypeError, delitem, ca, 0)
+
+    def test_numeric_arrays(self):
+
+        alen = 5
+
+        numarray = ARRAY(c_int, alen)
+
+        na = numarray()
+        values = [na[i] for i in range(alen)]
+        self.assertEqual(values, [0] * alen)
+
+        na = numarray(*[c_int()] * alen)
+        values = [na[i] for i in range(alen)]
+        self.assertEqual(values, [0]*alen)
+
+        na = numarray(1, 2, 3, 4, 5)
+        values = [i for i in na]
+        self.assertEqual(values, [1, 2, 3, 4, 5])
+
+        na = numarray(*map(c_int, (1, 2, 3, 4, 5)))
+        values = [i for i in na]
+        self.assertEqual(values, [1, 2, 3, 4, 5])
+
+    def test_classcache(self):
+        self.assertTrue(not ARRAY(c_int, 3) is ARRAY(c_int, 4))
+        self.assertTrue(ARRAY(c_int, 3) is ARRAY(c_int, 3))
+
+    def test_from_address(self):
+        # Failed with 0.9.8, reported by JUrner
+        p = create_string_buffer("foo")
+        sz = (c_char * 3).from_address(addressof(p))
+        self.assertEqual(sz[:], "foo")
+        self.assertEqual(sz[::], "foo")
+        self.assertEqual(sz[::-1], "oof")
+        self.assertEqual(sz[::3], "f")
+        self.assertEqual(sz[1:4:2], "o")
+        self.assertEqual(sz.value, "foo")
+
+    try:
+        create_unicode_buffer
+    except NameError:
+        pass
+    else:
+        def test_from_addressW(self):
+            p = create_unicode_buffer("foo")
+            sz = (c_wchar * 3).from_address(addressof(p))
+            self.assertEqual(sz[:], "foo")
+            self.assertEqual(sz[::], "foo")
+            self.assertEqual(sz[::-1], "oof")
+            self.assertEqual(sz[::3], "f")
+            self.assertEqual(sz[1:4:2], "o")
+            self.assertEqual(sz.value, "foo")
+
+    def test_cache(self):
+        # Array types are cached internally in the _ctypes extension,
+        # in a WeakValueDictionary.  Make sure the array type is
+        # removed from the cache when the itemtype goes away.  This
+        # test will not fail, but will show a leak in the testsuite.
+
+        # Create a new type:
+        class my_int(c_int):
+            pass
+        # Create a new array type based on it:
+        t1 = my_int * 1
+        t2 = my_int * 1
+        self.assertTrue(t1 is t2)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_as_parameter.py b/lib/python2.7/ctypes/test/test_as_parameter.py
new file mode 100644
index 0000000..0553e66
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_as_parameter.py
@@ -0,0 +1,233 @@
+import unittest
+from ctypes import *
+import _ctypes_test
+import sys
+
+dll = CDLL(_ctypes_test.__file__)
+
+try:
+    CALLBACK_FUNCTYPE = WINFUNCTYPE
+except NameError:
+    # fake to enable this test on Linux
+    CALLBACK_FUNCTYPE = CFUNCTYPE
+
+class POINT(Structure):
+    _fields_ = [("x", c_int), ("y", c_int)]
+
+class BasicWrapTestCase(unittest.TestCase):
+    def wrap(self, param):
+        return param
+
+    def test_wchar_parm(self):
+        try:
+            c_wchar
+        except NameError:
+            return
+        f = dll._testfunc_i_bhilfd
+        f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
+        result = f(self.wrap(1), self.wrap(u"x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
+        self.assertEqual(result, 139)
+        self.assertTrue(type(result), int)
+
+    def test_pointers(self):
+        f = dll._testfunc_p_p
+        f.restype = POINTER(c_int)
+        f.argtypes = [POINTER(c_int)]
+
+        # This only works if the value c_int(42) passed to the
+        # function is still alive while the pointer (the result) is
+        # used.
+
+        v = c_int(42)
+
+        self.assertEqual(pointer(v).contents.value, 42)
+        result = f(self.wrap(pointer(v)))
+        self.assertEqual(type(result), POINTER(c_int))
+        self.assertEqual(result.contents.value, 42)
+
+        # This on works...
+        result = f(self.wrap(pointer(v)))
+        self.assertEqual(result.contents.value, v.value)
+
+        p = pointer(c_int(99))
+        result = f(self.wrap(p))
+        self.assertEqual(result.contents.value, 99)
+
+    def test_shorts(self):
+        f = dll._testfunc_callback_i_if
+
+        args = []
+        expected = [262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048,
+                    1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
+
+        def callback(v):
+            args.append(v)
+            return v
+
+        CallBack = CFUNCTYPE(c_int, c_int)
+
+        cb = CallBack(callback)
+        f(self.wrap(2**18), self.wrap(cb))
+        self.assertEqual(args, expected)
+
+    ################################################################
+
+    def test_callbacks(self):
+        f = dll._testfunc_callback_i_if
+        f.restype = c_int
+        f.argtypes = None
+
+        MyCallback = CFUNCTYPE(c_int, c_int)
+
+        def callback(value):
+            #print "called back with", value
+            return value
+
+        cb = MyCallback(callback)
+
+        result = f(self.wrap(-10), self.wrap(cb))
+        self.assertEqual(result, -18)
+
+        # test with prototype
+        f.argtypes = [c_int, MyCallback]
+        cb = MyCallback(callback)
+
+        result = f(self.wrap(-10), self.wrap(cb))
+        self.assertEqual(result, -18)
+
+        result = f(self.wrap(-10), self.wrap(cb))
+        self.assertEqual(result, -18)
+
+        AnotherCallback = CALLBACK_FUNCTYPE(c_int, c_int, c_int, c_int, c_int)
+
+        # check that the prototype works: we call f with wrong
+        # argument types
+        cb = AnotherCallback(callback)
+        self.assertRaises(ArgumentError, f, self.wrap(-10), self.wrap(cb))
+
+    def test_callbacks_2(self):
+        # Can also use simple datatypes as argument type specifiers
+        # for the callback function.
+        # In this case the call receives an instance of that type
+        f = dll._testfunc_callback_i_if
+        f.restype = c_int
+
+        MyCallback = CFUNCTYPE(c_int, c_int)
+
+        f.argtypes = [c_int, MyCallback]
+
+        def callback(value):
+            #print "called back with", value
+            self.assertEqual(type(value), int)
+            return value
+
+        cb = MyCallback(callback)
+        result = f(self.wrap(-10), self.wrap(cb))
+        self.assertEqual(result, -18)
+
+    def test_longlong_callbacks(self):
+
+        f = dll._testfunc_callback_q_qf
+        f.restype = c_longlong
+
+        MyCallback = CFUNCTYPE(c_longlong, c_longlong)
+
+        f.argtypes = [c_longlong, MyCallback]
+
+        def callback(value):
+            self.assertTrue(isinstance(value, (int, long)))
+            return value & 0x7FFFFFFF
+
+        cb = MyCallback(callback)
+
+        self.assertEqual(13577625587, int(f(self.wrap(1000000000000), self.wrap(cb))))
+
+    def test_byval(self):
+        # without prototype
+        ptin = POINT(1, 2)
+        ptout = POINT()
+        # EXPORT int _testfunc_byval(point in, point *pout)
+        result = dll._testfunc_byval(ptin, byref(ptout))
+        got = result, ptout.x, ptout.y
+        expected = 3, 1, 2
+        self.assertEqual(got, expected)
+
+        # with prototype
+        ptin = POINT(101, 102)
+        ptout = POINT()
+        dll._testfunc_byval.argtypes = (POINT, POINTER(POINT))
+        dll._testfunc_byval.restype = c_int
+        result = dll._testfunc_byval(self.wrap(ptin), byref(ptout))
+        got = result, ptout.x, ptout.y
+        expected = 203, 101, 102
+        self.assertEqual(got, expected)
+
+    def test_struct_return_2H(self):
+        class S2H(Structure):
+            _fields_ = [("x", c_short),
+                        ("y", c_short)]
+        dll.ret_2h_func.restype = S2H
+        dll.ret_2h_func.argtypes = [S2H]
+        inp = S2H(99, 88)
+        s2h = dll.ret_2h_func(self.wrap(inp))
+        self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
+
+    # This is known cdecl incompatibility between GCC
+    # and MSVC. It is addressed in GCC issue #36834.
+    # Python libffi detect it and complain.
+    @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)')
+    def test_struct_return_8H(self):
+        class S8I(Structure):
+            _fields_ = [("a", c_int),
+                        ("b", c_int),
+                        ("c", c_int),
+                        ("d", c_int),
+                        ("e", c_int),
+                        ("f", c_int),
+                        ("g", c_int),
+                        ("h", c_int)]
+        dll.ret_8i_func.restype = S8I
+        dll.ret_8i_func.argtypes = [S8I]
+        inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
+        s8i = dll.ret_8i_func(self.wrap(inp))
+        self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+                             (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
+
+    def test_recursive_as_param(self):
+        from ctypes import c_int
+
+        class A(object):
+            pass
+
+        a = A()
+        a._as_parameter_ = a
+        with self.assertRaises(RuntimeError):
+            c_int.from_param(a)
+
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+class AsParamWrapper(object):
+    def __init__(self, param):
+        self._as_parameter_ = param
+
+class AsParamWrapperTestCase(BasicWrapTestCase):
+    wrap = AsParamWrapper
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+class AsParamPropertyWrapper(object):
+    def __init__(self, param):
+        self._param = param
+
+    def getParameter(self):
+        return self._param
+    _as_parameter_ = property(getParameter)
+
+class AsParamPropertyWrapperTestCase(BasicWrapTestCase):
+    wrap = AsParamPropertyWrapper
+
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_bitfields.py b/lib/python2.7/ctypes/test/test_bitfields.py
new file mode 100644
index 0000000..3bcc67f
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_bitfields.py
@@ -0,0 +1,264 @@
+from ctypes import *
+import unittest
+import os
+
+import ctypes
+import _ctypes_test
+
+class BITS(Structure):
+    _fields_ = [("A", c_int, 1),
+                ("B", c_int, 2),
+                ("C", c_int, 3),
+                ("D", c_int, 4),
+                ("E", c_int, 5),
+                ("F", c_int, 6),
+                ("G", c_int, 7),
+                ("H", c_int, 8),
+                ("I", c_int, 9),
+
+                ("M", c_short, 1),
+                ("N", c_short, 2),
+                ("O", c_short, 3),
+                ("P", c_short, 4),
+                ("Q", c_short, 5),
+                ("R", c_short, 6),
+                ("S", c_short, 7)]
+
+func = CDLL(_ctypes_test.__file__).unpack_bitfields
+func.argtypes = POINTER(BITS), c_char
+
+##for n in "ABCDEFGHIMNOPQRS":
+##    print n, hex(getattr(BITS, n).size), getattr(BITS, n).offset
+
+class C_Test(unittest.TestCase):
+
+    def test_ints(self):
+        for i in range(512):
+            for name in "ABCDEFGHI":
+                b = BITS()
+                setattr(b, name, i)
+                self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+
+    def test_shorts(self):
+        for i in range(256):
+            for name in "MNOPQRS":
+                b = BITS()
+                setattr(b, name, i)
+                self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+
+signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
+unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
+int_types = unsigned_int_types + signed_int_types
+
+class BitFieldTest(unittest.TestCase):
+
+    def test_longlong(self):
+        class X(Structure):
+            _fields_ = [("a", c_longlong, 1),
+                        ("b", c_longlong, 62),
+                        ("c", c_longlong, 1)]
+
+        self.assertEqual(sizeof(X), sizeof(c_longlong))
+        x = X()
+        x.a, x.b, x.c = -1, 7, -1
+        self.assertEqual((x.a, x.b, x.c), (-1, 7, -1))
+
+    def test_ulonglong(self):
+        class X(Structure):
+            _fields_ = [("a", c_ulonglong, 1),
+                        ("b", c_ulonglong, 62),
+                        ("c", c_ulonglong, 1)]
+
+        self.assertEqual(sizeof(X), sizeof(c_longlong))
+        x = X()
+        self.assertEqual((x.a, x.b, x.c), (0, 0, 0))
+        x.a, x.b, x.c = 7, 7, 7
+        self.assertEqual((x.a, x.b, x.c), (1, 7, 1))
+
+    def test_signed(self):
+        for c_typ in signed_int_types:
+            class X(Structure):
+                _fields_ = [("dummy", c_typ),
+                            ("a", c_typ, 3),
+                            ("b", c_typ, 3),
+                            ("c", c_typ, 1)]
+            self.assertEqual(sizeof(X), sizeof(c_typ)*2)
+
+            x = X()
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
+            x.a = -1
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, -1, 0, 0))
+            x.a, x.b = 0, -1
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, -1, 0))
+
+
+    def test_unsigned(self):
+        for c_typ in unsigned_int_types:
+            class X(Structure):
+                _fields_ = [("a", c_typ, 3),
+                            ("b", c_typ, 3),
+                            ("c", c_typ, 1)]
+            self.assertEqual(sizeof(X), sizeof(c_typ))
+
+            x = X()
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 0, 0))
+            x.a = -1
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 7, 0, 0))
+            x.a, x.b = 0, -1
+            self.assertEqual((c_typ, x.a, x.b, x.c), (c_typ, 0, 7, 0))
+
+
+    def fail_fields(self, *fields):
+        return self.get_except(type(Structure), "X", (),
+                               {"_fields_": fields})
+
+    def test_nonint_types(self):
+        # bit fields are not allowed on non-integer types.
+        result = self.fail_fields(("a", c_char_p, 1))
+        self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_char_p'))
+
+        result = self.fail_fields(("a", c_void_p, 1))
+        self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_void_p'))
+
+        if c_int != c_long:
+            result = self.fail_fields(("a", POINTER(c_int), 1))
+            self.assertEqual(result, (TypeError, 'bit fields not allowed for type LP_c_int'))
+
+        result = self.fail_fields(("a", c_char, 1))
+        self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_char'))
+
+        try:
+            c_wchar
+        except NameError:
+            pass
+        else:
+            result = self.fail_fields(("a", c_wchar, 1))
+            self.assertEqual(result, (TypeError, 'bit fields not allowed for type c_wchar'))
+
+        class Dummy(Structure):
+            _fields_ = []
+
+        result = self.fail_fields(("a", Dummy, 1))
+        self.assertEqual(result, (TypeError, 'bit fields not allowed for type Dummy'))
+
+    def test_single_bitfield_size(self):
+        for c_typ in int_types:
+            result = self.fail_fields(("a", c_typ, -1))
+            self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
+
+            result = self.fail_fields(("a", c_typ, 0))
+            self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
+
+            class X(Structure):
+                _fields_ = [("a", c_typ, 1)]
+            self.assertEqual(sizeof(X), sizeof(c_typ))
+
+            class X(Structure):
+                _fields_ = [("a", c_typ, sizeof(c_typ)*8)]
+            self.assertEqual(sizeof(X), sizeof(c_typ))
+
+            result = self.fail_fields(("a", c_typ, sizeof(c_typ)*8 + 1))
+            self.assertEqual(result, (ValueError, 'number of bits invalid for bit field'))
+
+    def test_multi_bitfields_size(self):
+        class X(Structure):
+            _fields_ = [("a", c_short, 1),
+                        ("b", c_short, 14),
+                        ("c", c_short, 1)]
+        self.assertEqual(sizeof(X), sizeof(c_short))
+
+        class X(Structure):
+            _fields_ = [("a", c_short, 1),
+                        ("a1", c_short),
+                        ("b", c_short, 14),
+                        ("c", c_short, 1)]
+        self.assertEqual(sizeof(X), sizeof(c_short)*3)
+        self.assertEqual(X.a.offset, 0)
+        self.assertEqual(X.a1.offset, sizeof(c_short))
+        self.assertEqual(X.b.offset, sizeof(c_short)*2)
+        self.assertEqual(X.c.offset, sizeof(c_short)*2)
+
+        class X(Structure):
+            _fields_ = [("a", c_short, 3),
+                        ("b", c_short, 14),
+                        ("c", c_short, 14)]
+        self.assertEqual(sizeof(X), sizeof(c_short)*3)
+        self.assertEqual(X.a.offset, sizeof(c_short)*0)
+        self.assertEqual(X.b.offset, sizeof(c_short)*1)
+        self.assertEqual(X.c.offset, sizeof(c_short)*2)
+
+
+    def get_except(self, func, *args, **kw):
+        try:
+            func(*args, **kw)
+        except Exception, detail:
+            return detail.__class__, str(detail)
+
+    def test_mixed_1(self):
+        class X(Structure):
+            _fields_ = [("a", c_byte, 4),
+                        ("b", c_int, 4)]
+        if os.name in ("nt", "ce"):
+            self.assertEqual(sizeof(X), sizeof(c_int)*2)
+        else:
+            self.assertEqual(sizeof(X), sizeof(c_int))
+
+    def test_mixed_2(self):
+        class X(Structure):
+            _fields_ = [("a", c_byte, 4),
+                        ("b", c_int, 32)]
+        self.assertEqual(sizeof(X), sizeof(c_int)*2)
+
+    def test_mixed_3(self):
+        class X(Structure):
+            _fields_ = [("a", c_byte, 4),
+                        ("b", c_ubyte, 4)]
+        self.assertEqual(sizeof(X), sizeof(c_byte))
+
+    def test_mixed_4(self):
+        class X(Structure):
+            _fields_ = [("a", c_short, 4),
+                        ("b", c_short, 4),
+                        ("c", c_int, 24),
+                        ("d", c_short, 4),
+                        ("e", c_short, 4),
+                        ("f", c_int, 24)]
+        # MSVC does NOT combine c_short and c_int into one field, GCC
+        # does (unless GCC is run with '-mms-bitfields' which
+        # produces code compatible with MSVC).
+        if os.name in ("nt", "ce"):
+            self.assertEqual(sizeof(X), sizeof(c_int) * 4)
+        else:
+            self.assertEqual(sizeof(X), sizeof(c_int) * 2)
+
+    def test_anon_bitfields(self):
+        # anonymous bit-fields gave a strange error message
+        class X(Structure):
+            _fields_ = [("a", c_byte, 4),
+                        ("b", c_ubyte, 4)]
+        class Y(Structure):
+            _anonymous_ = ["_"]
+            _fields_ = [("_", X)]
+
+    @unittest.skipUnless(hasattr(ctypes, "c_uint32"), "c_int32 is required")
+    def test_uint32(self):
+        class X(Structure):
+            _fields_ = [("a", c_uint32, 32)]
+        x = X()
+        x.a = 10
+        self.assertEqual(x.a, 10)
+        x.a = 0xFDCBA987
+        self.assertEqual(x.a, 0xFDCBA987)
+
+    @unittest.skipUnless(hasattr(ctypes, "c_uint64"), "c_int64 is required")
+    def test_uint64(self):
+        class X(Structure):
+            _fields_ = [("a", c_uint64, 64)]
+        x = X()
+        x.a = 10
+        self.assertEqual(x.a, 10)
+        x.a = 0xFEDCBA9876543211
+        self.assertEqual(x.a, 0xFEDCBA9876543211)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_buffers.py b/lib/python2.7/ctypes/test/test_buffers.py
new file mode 100644
index 0000000..12945ed
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_buffers.py
@@ -0,0 +1,74 @@
+from ctypes import *
+import unittest
+
+class StringBufferTestCase(unittest.TestCase):
+
+    def test_buffer(self):
+        b = create_string_buffer(32)
+        self.assertEqual(len(b), 32)
+        self.assertEqual(sizeof(b), 32 * sizeof(c_char))
+        self.assertTrue(type(b[0]) is str)
+
+        b = create_string_buffer("abc")
+        self.assertEqual(len(b), 4) # trailing nul char
+        self.assertEqual(sizeof(b), 4 * sizeof(c_char))
+        self.assertTrue(type(b[0]) is str)
+        self.assertEqual(b[0], "a")
+        self.assertEqual(b[:], "abc\0")
+        self.assertEqual(b[::], "abc\0")
+        self.assertEqual(b[::-1], "\0cba")
+        self.assertEqual(b[::2], "ac")
+        self.assertEqual(b[::5], "a")
+
+    def test_buffer_interface(self):
+        self.assertEqual(len(bytearray(create_string_buffer(0))), 0)
+        self.assertEqual(len(bytearray(create_string_buffer(1))), 1)
+
+    def test_string_conversion(self):
+        b = create_string_buffer(u"abc")
+        self.assertEqual(len(b), 4) # trailing nul char
+        self.assertEqual(sizeof(b), 4 * sizeof(c_char))
+        self.assertTrue(type(b[0]) is str)
+        self.assertEqual(b[0], "a")
+        self.assertEqual(b[:], "abc\0")
+        self.assertEqual(b[::], "abc\0")
+        self.assertEqual(b[::-1], "\0cba")
+        self.assertEqual(b[::2], "ac")
+        self.assertEqual(b[::5], "a")
+
+    try:
+        c_wchar
+    except NameError:
+        pass
+    else:
+        def test_unicode_buffer(self):
+            b = create_unicode_buffer(32)
+            self.assertEqual(len(b), 32)
+            self.assertEqual(sizeof(b), 32 * sizeof(c_wchar))
+            self.assertTrue(type(b[0]) is unicode)
+
+            b = create_unicode_buffer(u"abc")
+            self.assertEqual(len(b), 4) # trailing nul char
+            self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
+            self.assertTrue(type(b[0]) is unicode)
+            self.assertEqual(b[0], u"a")
+            self.assertEqual(b[:], "abc\0")
+            self.assertEqual(b[::], "abc\0")
+            self.assertEqual(b[::-1], "\0cba")
+            self.assertEqual(b[::2], "ac")
+            self.assertEqual(b[::5], "a")
+
+        def test_unicode_conversion(self):
+            b = create_unicode_buffer("abc")
+            self.assertEqual(len(b), 4) # trailing nul char
+            self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
+            self.assertTrue(type(b[0]) is unicode)
+            self.assertEqual(b[0], u"a")
+            self.assertEqual(b[:], "abc\0")
+            self.assertEqual(b[::], "abc\0")
+            self.assertEqual(b[::-1], "\0cba")
+            self.assertEqual(b[::2], "ac")
+            self.assertEqual(b[::5], "a")
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_byteswap.py b/lib/python2.7/ctypes/test/test_byteswap.py
new file mode 100644
index 0000000..4bd75cd
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_byteswap.py
@@ -0,0 +1,294 @@
+import sys, unittest, struct, math, ctypes
+from binascii import hexlify
+
+from ctypes import *
+
+def bin(s):
+    return hexlify(memoryview(s)).upper()
+
+# Each *simple* type that supports different byte orders has an
+# __ctype_be__ attribute that specifies the same type in BIG ENDIAN
+# byte order, and a __ctype_le__ attribute that is the same type in
+# LITTLE ENDIAN byte order.
+#
+# For Structures and Unions, these types are created on demand.
+
+class Test(unittest.TestCase):
+    def X_test(self):
+        print >> sys.stderr,  sys.byteorder
+        for i in range(32):
+            bits = BITS()
+            setattr(bits, "i%s" % i, 1)
+            dump(bits)
+
+    def test_endian_short(self):
+        if sys.byteorder == "little":
+            self.assertTrue(c_short.__ctype_le__ is c_short)
+            self.assertTrue(c_short.__ctype_be__.__ctype_le__ is c_short)
+        else:
+            self.assertTrue(c_short.__ctype_be__ is c_short)
+            self.assertTrue(c_short.__ctype_le__.__ctype_be__ is c_short)
+        s = c_short.__ctype_be__(0x1234)
+        self.assertEqual(bin(struct.pack(">h", 0x1234)), "1234")
+        self.assertEqual(bin(s), "1234")
+        self.assertEqual(s.value, 0x1234)
+
+        s = c_short.__ctype_le__(0x1234)
+        self.assertEqual(bin(struct.pack("<h", 0x1234)), "3412")
+        self.assertEqual(bin(s), "3412")
+        self.assertEqual(s.value, 0x1234)
+
+        s = c_ushort.__ctype_be__(0x1234)
+        self.assertEqual(bin(struct.pack(">h", 0x1234)), "1234")
+        self.assertEqual(bin(s), "1234")
+        self.assertEqual(s.value, 0x1234)
+
+        s = c_ushort.__ctype_le__(0x1234)
+        self.assertEqual(bin(struct.pack("<h", 0x1234)), "3412")
+        self.assertEqual(bin(s), "3412")
+        self.assertEqual(s.value, 0x1234)
+
+    def test_endian_int(self):
+        if sys.byteorder == "little":
+            self.assertTrue(c_int.__ctype_le__ is c_int)
+            self.assertTrue(c_int.__ctype_be__.__ctype_le__ is c_int)
+        else:
+            self.assertTrue(c_int.__ctype_be__ is c_int)
+            self.assertTrue(c_int.__ctype_le__.__ctype_be__ is c_int)
+
+        s = c_int.__ctype_be__(0x12345678)
+        self.assertEqual(bin(struct.pack(">i", 0x12345678)), "12345678")
+        self.assertEqual(bin(s), "12345678")
+        self.assertEqual(s.value, 0x12345678)
+
+        s = c_int.__ctype_le__(0x12345678)
+        self.assertEqual(bin(struct.pack("<i", 0x12345678)), "78563412")
+        self.assertEqual(bin(s), "78563412")
+        self.assertEqual(s.value, 0x12345678)
+
+        s = c_uint.__ctype_be__(0x12345678)
+        self.assertEqual(bin(struct.pack(">I", 0x12345678)), "12345678")
+        self.assertEqual(bin(s), "12345678")
+        self.assertEqual(s.value, 0x12345678)
+
+        s = c_uint.__ctype_le__(0x12345678)
+        self.assertEqual(bin(struct.pack("<I", 0x12345678)), "78563412")
+        self.assertEqual(bin(s), "78563412")
+        self.assertEqual(s.value, 0x12345678)
+
+    def test_endian_longlong(self):
+        if sys.byteorder == "little":
+            self.assertTrue(c_longlong.__ctype_le__ is c_longlong)
+            self.assertTrue(c_longlong.__ctype_be__.__ctype_le__ is c_longlong)
+        else:
+            self.assertTrue(c_longlong.__ctype_be__ is c_longlong)
+            self.assertTrue(c_longlong.__ctype_le__.__ctype_be__ is c_longlong)
+
+        s = c_longlong.__ctype_be__(0x1234567890ABCDEF)
+        self.assertEqual(bin(struct.pack(">q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
+        self.assertEqual(bin(s), "1234567890ABCDEF")
+        self.assertEqual(s.value, 0x1234567890ABCDEF)
+
+        s = c_longlong.__ctype_le__(0x1234567890ABCDEF)
+        self.assertEqual(bin(struct.pack("<q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
+        self.assertEqual(bin(s), "EFCDAB9078563412")
+        self.assertEqual(s.value, 0x1234567890ABCDEF)
+
+        s = c_ulonglong.__ctype_be__(0x1234567890ABCDEF)
+        self.assertEqual(bin(struct.pack(">Q", 0x1234567890ABCDEF)), "1234567890ABCDEF")
+        self.assertEqual(bin(s), "1234567890ABCDEF")
+        self.assertEqual(s.value, 0x1234567890ABCDEF)
+
+        s = c_ulonglong.__ctype_le__(0x1234567890ABCDEF)
+        self.assertEqual(bin(struct.pack("<Q", 0x1234567890ABCDEF)), "EFCDAB9078563412")
+        self.assertEqual(bin(s), "EFCDAB9078563412")
+        self.assertEqual(s.value, 0x1234567890ABCDEF)
+
+    def test_endian_float(self):
+        if sys.byteorder == "little":
+            self.assertTrue(c_float.__ctype_le__ is c_float)
+            self.assertTrue(c_float.__ctype_be__.__ctype_le__ is c_float)
+        else:
+            self.assertTrue(c_float.__ctype_be__ is c_float)
+            self.assertTrue(c_float.__ctype_le__.__ctype_be__ is c_float)
+        s = c_float(math.pi)
+        self.assertEqual(bin(struct.pack("f", math.pi)), bin(s))
+        # Hm, what's the precision of a float compared to a double?
+        self.assertAlmostEqual(s.value, math.pi, 6)
+        s = c_float.__ctype_le__(math.pi)
+        self.assertAlmostEqual(s.value, math.pi, 6)
+        self.assertEqual(bin(struct.pack("<f", math.pi)), bin(s))
+        s = c_float.__ctype_be__(math.pi)
+        self.assertAlmostEqual(s.value, math.pi, 6)
+        self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s))
+
+    def test_endian_double(self):
+        if sys.byteorder == "little":
+            self.assertTrue(c_double.__ctype_le__ is c_double)
+            self.assertTrue(c_double.__ctype_be__.__ctype_le__ is c_double)
+        else:
+            self.assertTrue(c_double.__ctype_be__ is c_double)
+            self.assertTrue(c_double.__ctype_le__.__ctype_be__ is c_double)
+        s = c_double(math.pi)
+        self.assertEqual(s.value, math.pi)
+        self.assertEqual(bin(struct.pack("d", math.pi)), bin(s))
+        s = c_double.__ctype_le__(math.pi)
+        self.assertEqual(s.value, math.pi)
+        self.assertEqual(bin(struct.pack("<d", math.pi)), bin(s))
+        s = c_double.__ctype_be__(math.pi)
+        self.assertEqual(s.value, math.pi)
+        self.assertEqual(bin(struct.pack(">d", math.pi)), bin(s))
+
+    def test_endian_other(self):
+        self.assertTrue(c_byte.__ctype_le__ is c_byte)
+        self.assertTrue(c_byte.__ctype_be__ is c_byte)
+
+        self.assertTrue(c_ubyte.__ctype_le__ is c_ubyte)
+        self.assertTrue(c_ubyte.__ctype_be__ is c_ubyte)
+
+        self.assertTrue(c_char.__ctype_le__ is c_char)
+        self.assertTrue(c_char.__ctype_be__ is c_char)
+
+    def test_struct_fields_1(self):
+        if sys.byteorder == "little":
+            base = BigEndianStructure
+        else:
+            base = LittleEndianStructure
+
+        class T(base):
+            pass
+        _fields_ = [("a", c_ubyte),
+                    ("b", c_byte),
+                    ("c", c_short),
+                    ("d", c_ushort),
+                    ("e", c_int),
+                    ("f", c_uint),
+                    ("g", c_long),
+                    ("h", c_ulong),
+                    ("i", c_longlong),
+                    ("k", c_ulonglong),
+                    ("l", c_float),
+                    ("m", c_double),
+                    ("n", c_char),
+
+                    ("b1", c_byte, 3),
+                    ("b2", c_byte, 3),
+                    ("b3", c_byte, 2),
+                    ("a", c_int * 3 * 3 * 3)]
+        T._fields_ = _fields_
+
+        # these fields do not support different byte order:
+        for typ in c_wchar, c_void_p, POINTER(c_int):
+            _fields_.append(("x", typ))
+            class T(base):
+                pass
+            self.assertRaises(TypeError, setattr, T, "_fields_", [("x", typ)])
+
+    def test_struct_struct(self):
+        # nested structures with different byteorders
+
+        # create nested structures with given byteorders and set memory to data
+
+        for nested, data in (
+            (BigEndianStructure, b'\0\0\0\1\0\0\0\2'),
+            (LittleEndianStructure, b'\1\0\0\0\2\0\0\0'),
+        ):
+            for parent in (
+                BigEndianStructure,
+                LittleEndianStructure,
+                Structure,
+            ):
+                class NestedStructure(nested):
+                    _fields_ = [("x", c_uint32),
+                                ("y", c_uint32)]
+
+                class TestStructure(parent):
+                    _fields_ = [("point", NestedStructure)]
+
+                self.assertEqual(len(data), sizeof(TestStructure))
+                ptr = POINTER(TestStructure)
+                s = cast(data, ptr)[0]
+                del ctypes._pointer_type_cache[TestStructure]
+                self.assertEqual(s.point.x, 1)
+                self.assertEqual(s.point.y, 2)
+
+    def test_struct_fields_2(self):
+        # standard packing in struct uses no alignment.
+        # So, we have to align using pad bytes.
+        #
+        # Unaligned accesses will crash Python (on those platforms that
+        # don't allow it, like sparc solaris).
+        if sys.byteorder == "little":
+            base = BigEndianStructure
+            fmt = ">bxhid"
+        else:
+            base = LittleEndianStructure
+            fmt = "<bxhid"
+
+        class S(base):
+            _fields_ = [("b", c_byte),
+                        ("h", c_short),
+                        ("i", c_int),
+                        ("d", c_double)]
+
+        s1 = S(0x12, 0x1234, 0x12345678, 3.14)
+        s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
+        self.assertEqual(bin(s1), bin(s2))
+
+    def test_unaligned_nonnative_struct_fields(self):
+        if sys.byteorder == "little":
+            base = BigEndianStructure
+            fmt = ">b h xi xd"
+        else:
+            base = LittleEndianStructure
+            fmt = "<b h xi xd"
+
+        class S(base):
+            _pack_ = 1
+            _fields_ = [("b", c_byte),
+
+                        ("h", c_short),
+
+                        ("_1", c_byte),
+                        ("i", c_int),
+
+                        ("_2", c_byte),
+                        ("d", c_double)]
+
+        s1 = S()
+        s1.b = 0x12
+        s1.h = 0x1234
+        s1.i = 0x12345678
+        s1.d = 3.14
+        s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
+        self.assertEqual(bin(s1), bin(s2))
+
+    def test_unaligned_native_struct_fields(self):
+        if sys.byteorder == "little":
+            fmt = "<b h xi xd"
+        else:
+            base = LittleEndianStructure
+            fmt = ">b h xi xd"
+
+        class S(Structure):
+            _pack_ = 1
+            _fields_ = [("b", c_byte),
+
+                        ("h", c_short),
+
+                        ("_1", c_byte),
+                        ("i", c_int),
+
+                        ("_2", c_byte),
+                        ("d", c_double)]
+
+        s1 = S()
+        s1.b = 0x12
+        s1.h = 0x1234
+        s1.i = 0x12345678
+        s1.d = 3.14
+        s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
+        self.assertEqual(bin(s1), bin(s2))
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_callbacks.py b/lib/python2.7/ctypes/test/test_callbacks.py
new file mode 100644
index 0000000..be0c17e
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_callbacks.py
@@ -0,0 +1,256 @@
+import unittest
+from ctypes import *
+import _ctypes_test
+
+class Callbacks(unittest.TestCase):
+    functype = CFUNCTYPE
+
+##    def tearDown(self):
+##        import gc
+##        gc.collect()
+
+    def callback(self, *args):
+        self.got_args = args
+        return args[-1]
+
+    def check_type(self, typ, arg):
+        PROTO = self.functype.im_func(typ, typ)
+        result = PROTO(self.callback)(arg)
+        if typ == c_float:
+            self.assertAlmostEqual(result, arg, places=5)
+        else:
+            self.assertEqual(self.got_args, (arg,))
+            self.assertEqual(result, arg)
+
+        PROTO = self.functype.im_func(typ, c_byte, typ)
+        result = PROTO(self.callback)(-3, arg)
+        if typ == c_float:
+            self.assertAlmostEqual(result, arg, places=5)
+        else:
+            self.assertEqual(self.got_args, (-3, arg))
+            self.assertEqual(result, arg)
+
+    ################
+
+    def test_byte(self):
+        self.check_type(c_byte, 42)
+        self.check_type(c_byte, -42)
+
+    def test_ubyte(self):
+        self.check_type(c_ubyte, 42)
+
+    def test_short(self):
+        self.check_type(c_short, 42)
+        self.check_type(c_short, -42)
+
+    def test_ushort(self):
+        self.check_type(c_ushort, 42)
+
+    def test_int(self):
+        self.check_type(c_int, 42)
+        self.check_type(c_int, -42)
+
+    def test_uint(self):
+        self.check_type(c_uint, 42)
+
+    def test_long(self):
+        self.check_type(c_long, 42)
+        self.check_type(c_long, -42)
+
+    def test_ulong(self):
+        self.check_type(c_ulong, 42)
+
+    def test_longlong(self):
+        # test some 64-bit values, positive and negative
+        self.check_type(c_longlong, 5948291757245277467)
+        self.check_type(c_longlong, -5229388909784190580)
+        self.check_type(c_longlong, 42)
+        self.check_type(c_longlong, -42)
+
+    def test_ulonglong(self):
+        # test some 64-bit values, with and without msb set.
+        self.check_type(c_ulonglong, 10955412242170339782)
+        self.check_type(c_ulonglong, 3665885499841167458)
+        self.check_type(c_ulonglong, 42)
+
+    def test_float(self):
+        # only almost equal: double -> float -> double
+        import math
+        self.check_type(c_float, math.e)
+        self.check_type(c_float, -math.e)
+
+    def test_double(self):
+        self.check_type(c_double, 3.14)
+        self.check_type(c_double, -3.14)
+
+    def test_longdouble(self):
+        self.check_type(c_longdouble, 3.14)
+        self.check_type(c_longdouble, -3.14)
+
+    def test_char(self):
+        self.check_type(c_char, "x")
+        self.check_type(c_char, "a")
+
+    # disabled: would now (correctly) raise a RuntimeWarning about
+    # a memory leak.  A callback function cannot return a non-integral
+    # C type without causing a memory leak.
+##    def test_char_p(self):
+##        self.check_type(c_char_p, "abc")
+##        self.check_type(c_char_p, "def")
+
+    def test_pyobject(self):
+        o = ()
+        from sys import getrefcount as grc
+        for o in (), [], object():
+            initial = grc(o)
+            # This call leaks a reference to 'o'...
+            self.check_type(py_object, o)
+            before = grc(o)
+            # ...but this call doesn't leak any more.  Where is the refcount?
+            self.check_type(py_object, o)
+            after = grc(o)
+            self.assertEqual((after, o), (before, o))
+
+    def test_unsupported_restype_1(self):
+        # Only "fundamental" result types are supported for callback
+        # functions, the type must have a non-NULL stgdict->setfunc.
+        # POINTER(c_double), for example, is not supported.
+
+        prototype = self.functype.im_func(POINTER(c_double))
+        # The type is checked when the prototype is called
+        self.assertRaises(TypeError, prototype, lambda: None)
+
+    def test_unsupported_restype_2(self):
+        prototype = self.functype.im_func(object)
+        self.assertRaises(TypeError, prototype, lambda: None)
+
+    def test_issue_7959(self):
+        proto = self.functype.im_func(None)
+
+        class X(object):
+            def func(self): pass
+            def __init__(self):
+                self.v = proto(self.func)
+
+        import gc
+        for i in range(32):
+            X()
+        gc.collect()
+        live = [x for x in gc.get_objects()
+                if isinstance(x, X)]
+        self.assertEqual(len(live), 0)
+
+    def test_issue12483(self):
+        import gc
+        class Nasty:
+            def __del__(self):
+                gc.collect()
+        CFUNCTYPE(None)(lambda x=Nasty(): None)
+
+
+try:
+    WINFUNCTYPE
+except NameError:
+    pass
+else:
+    class StdcallCallbacks(Callbacks):
+        functype = WINFUNCTYPE
+
+################################################################
+
+class SampleCallbacksTestCase(unittest.TestCase):
+
+    def test_integrate(self):
+        # Derived from some then non-working code, posted by David Foster
+        dll = CDLL(_ctypes_test.__file__)
+
+        # The function prototype called by 'integrate': double func(double);
+        CALLBACK = CFUNCTYPE(c_double, c_double)
+
+        # The integrate function itself, exposed from the _ctypes_test dll
+        integrate = dll.integrate
+        integrate.argtypes = (c_double, c_double, CALLBACK, c_long)
+        integrate.restype = c_double
+
+        def func(x):
+            return x**2
+
+        result = integrate(0.0, 1.0, CALLBACK(func), 10)
+        diff = abs(result - 1./3.)
+
+        self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
+
+    def test_issue_8959_a(self):
+        from ctypes.util import find_library
+        libc_path = find_library("c")
+        if not libc_path:
+            return # cannot test
+        libc = CDLL(libc_path)
+
+        @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
+        def cmp_func(a, b):
+            return a[0] - b[0]
+
+        array = (c_int * 5)(5, 1, 99, 7, 33)
+
+        libc.qsort(array, len(array), sizeof(c_int), cmp_func)
+        self.assertEqual(array[:], [1, 5, 7, 33, 99])
+
+    try:
+        WINFUNCTYPE
+    except NameError:
+        pass
+    else:
+        def test_issue_8959_b(self):
+            from ctypes.wintypes import BOOL, HWND, LPARAM
+            global windowCount
+            windowCount = 0
+
+            @WINFUNCTYPE(BOOL, HWND, LPARAM)
+            def EnumWindowsCallbackFunc(hwnd, lParam):
+                global windowCount
+                windowCount += 1
+                return True #Allow windows to keep enumerating
+
+            windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0)
+
+    def test_callback_register_int(self):
+        # Issue #8275: buggy handling of callback args under Win64
+        # NOTE: should be run on release builds as well
+        dll = CDLL(_ctypes_test.__file__)
+        CALLBACK = CFUNCTYPE(c_int, c_int, c_int, c_int, c_int, c_int)
+        # All this function does is call the callback with its args squared
+        func = dll._testfunc_cbk_reg_int
+        func.argtypes = (c_int, c_int, c_int, c_int, c_int, CALLBACK)
+        func.restype = c_int
+
+        def callback(a, b, c, d, e):
+            return a + b + c + d + e
+
+        result = func(2, 3, 4, 5, 6, CALLBACK(callback))
+        self.assertEqual(result, callback(2*2, 3*3, 4*4, 5*5, 6*6))
+
+    def test_callback_register_double(self):
+        # Issue #8275: buggy handling of callback args under Win64
+        # NOTE: should be run on release builds as well
+        dll = CDLL(_ctypes_test.__file__)
+        CALLBACK = CFUNCTYPE(c_double, c_double, c_double, c_double,
+                             c_double, c_double)
+        # All this function does is call the callback with its args squared
+        func = dll._testfunc_cbk_reg_double
+        func.argtypes = (c_double, c_double, c_double,
+                         c_double, c_double, CALLBACK)
+        func.restype = c_double
+
+        def callback(a, b, c, d, e):
+            return a + b + c + d + e
+
+        result = func(1.1, 2.2, 3.3, 4.4, 5.5, CALLBACK(callback))
+        self.assertEqual(result,
+                         callback(1.1*1.1, 2.2*2.2, 3.3*3.3, 4.4*4.4, 5.5*5.5))
+
+
+################################################################
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_cast.py b/lib/python2.7/ctypes/test/test_cast.py
new file mode 100644
index 0000000..906fffc
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_cast.py
@@ -0,0 +1,89 @@
+from ctypes import *
+import unittest
+import sys
+
+class Test(unittest.TestCase):
+
+    def test_array2pointer(self):
+        array = (c_int * 3)(42, 17, 2)
+
+        # casting an array to a pointer works.
+        ptr = cast(array, POINTER(c_int))
+        self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
+
+        if 2*sizeof(c_short) == sizeof(c_int):
+            ptr = cast(array, POINTER(c_short))
+            if sys.byteorder == "little":
+                self.assertEqual([ptr[i] for i in range(6)],
+                                     [42, 0, 17, 0, 2, 0])
+            else:
+                self.assertEqual([ptr[i] for i in range(6)],
+                                     [0, 42, 0, 17, 0, 2])
+
+    def test_address2pointer(self):
+        array = (c_int * 3)(42, 17, 2)
+
+        address = addressof(array)
+        ptr = cast(c_void_p(address), POINTER(c_int))
+        self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
+
+        ptr = cast(address, POINTER(c_int))
+        self.assertEqual([ptr[i] for i in range(3)], [42, 17, 2])
+
+    def test_p2a_objects(self):
+        array = (c_char_p * 5)()
+        self.assertEqual(array._objects, None)
+        array[0] = "foo bar"
+        self.assertEqual(array._objects, {'0': "foo bar"})
+
+        p = cast(array, POINTER(c_char_p))
+        # array and p share a common _objects attribute
+        self.assertTrue(p._objects is array._objects)
+        self.assertEqual(array._objects, {'0': "foo bar", id(array): array})
+        p[0] = "spam spam"
+        self.assertEqual(p._objects, {'0': "spam spam", id(array): array})
+        self.assertTrue(array._objects is p._objects)
+        p[1] = "foo bar"
+        self.assertEqual(p._objects, {'1': 'foo bar', '0': "spam spam", id(array): array})
+        self.assertTrue(array._objects is p._objects)
+
+    def test_other(self):
+        p = cast((c_int * 4)(1, 2, 3, 4), POINTER(c_int))
+        self.assertEqual(p[:4], [1,2, 3, 4])
+        self.assertEqual(p[:4:], [1, 2, 3, 4])
+        self.assertEqual(p[3:-1:-1], [4, 3, 2, 1])
+        self.assertEqual(p[:4:3], [1, 4])
+        c_int()
+        self.assertEqual(p[:4], [1, 2, 3, 4])
+        self.assertEqual(p[:4:], [1, 2, 3, 4])
+        self.assertEqual(p[3:-1:-1], [4, 3, 2, 1])
+        self.assertEqual(p[:4:3], [1, 4])
+        p[2] = 96
+        self.assertEqual(p[:4], [1, 2, 96, 4])
+        self.assertEqual(p[:4:], [1, 2, 96, 4])
+        self.assertEqual(p[3:-1:-1], [4, 96, 2, 1])
+        self.assertEqual(p[:4:3], [1, 4])
+        c_int()
+        self.assertEqual(p[:4], [1, 2, 96, 4])
+        self.assertEqual(p[:4:], [1, 2, 96, 4])
+        self.assertEqual(p[3:-1:-1], [4, 96, 2, 1])
+        self.assertEqual(p[:4:3], [1, 4])
+
+    def test_char_p(self):
+        # This didn't work: bad argument to internal function
+        s = c_char_p("hiho")
+        self.assertEqual(cast(cast(s, c_void_p), c_char_p).value,
+                             "hiho")
+
+    try:
+        c_wchar_p
+    except NameError:
+        pass
+    else:
+        def test_wchar_p(self):
+            s = c_wchar_p("hiho")
+            self.assertEqual(cast(cast(s, c_void_p), c_wchar_p).value,
+                                 "hiho")
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_cfuncs.py b/lib/python2.7/ctypes/test/test_cfuncs.py
new file mode 100644
index 0000000..493cbe9
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_cfuncs.py
@@ -0,0 +1,211 @@
+# A lot of failures in these tests on Mac OS X.
+# Byte order related?
+
+import unittest
+from ctypes import *
+
+import _ctypes_test
+
+class CFunctions(unittest.TestCase):
+    _dll = CDLL(_ctypes_test.__file__)
+
+    def S(self):
+        return c_longlong.in_dll(self._dll, "last_tf_arg_s").value
+    def U(self):
+        return c_ulonglong.in_dll(self._dll, "last_tf_arg_u").value
+
+    def test_byte(self):
+        self._dll.tf_b.restype = c_byte
+        self._dll.tf_b.argtypes = (c_byte,)
+        self.assertEqual(self._dll.tf_b(-126), -42)
+        self.assertEqual(self.S(), -126)
+
+    def test_byte_plus(self):
+        self._dll.tf_bb.restype = c_byte
+        self._dll.tf_bb.argtypes = (c_byte, c_byte)
+        self.assertEqual(self._dll.tf_bb(0, -126), -42)
+        self.assertEqual(self.S(), -126)
+
+    def test_ubyte(self):
+        self._dll.tf_B.restype = c_ubyte
+        self._dll.tf_B.argtypes = (c_ubyte,)
+        self.assertEqual(self._dll.tf_B(255), 85)
+        self.assertEqual(self.U(), 255)
+
+    def test_ubyte_plus(self):
+        self._dll.tf_bB.restype = c_ubyte
+        self._dll.tf_bB.argtypes = (c_byte, c_ubyte)
+        self.assertEqual(self._dll.tf_bB(0, 255), 85)
+        self.assertEqual(self.U(), 255)
+
+    def test_short(self):
+        self._dll.tf_h.restype = c_short
+        self._dll.tf_h.argtypes = (c_short,)
+        self.assertEqual(self._dll.tf_h(-32766), -10922)
+        self.assertEqual(self.S(), -32766)
+
+    def test_short_plus(self):
+        self._dll.tf_bh.restype = c_short
+        self._dll.tf_bh.argtypes = (c_byte, c_short)
+        self.assertEqual(self._dll.tf_bh(0, -32766), -10922)
+        self.assertEqual(self.S(), -32766)
+
+    def test_ushort(self):
+        self._dll.tf_H.restype = c_ushort
+        self._dll.tf_H.argtypes = (c_ushort,)
+        self.assertEqual(self._dll.tf_H(65535), 21845)
+        self.assertEqual(self.U(), 65535)
+
+    def test_ushort_plus(self):
+        self._dll.tf_bH.restype = c_ushort
+        self._dll.tf_bH.argtypes = (c_byte, c_ushort)
+        self.assertEqual(self._dll.tf_bH(0, 65535), 21845)
+        self.assertEqual(self.U(), 65535)
+
+    def test_int(self):
+        self._dll.tf_i.restype = c_int
+        self._dll.tf_i.argtypes = (c_int,)
+        self.assertEqual(self._dll.tf_i(-2147483646), -715827882)
+        self.assertEqual(self.S(), -2147483646)
+
+    def test_int_plus(self):
+        self._dll.tf_bi.restype = c_int
+        self._dll.tf_bi.argtypes = (c_byte, c_int)
+        self.assertEqual(self._dll.tf_bi(0, -2147483646), -715827882)
+        self.assertEqual(self.S(), -2147483646)
+
+    def test_uint(self):
+        self._dll.tf_I.restype = c_uint
+        self._dll.tf_I.argtypes = (c_uint,)
+        self.assertEqual(self._dll.tf_I(4294967295), 1431655765)
+        self.assertEqual(self.U(), 4294967295)
+
+    def test_uint_plus(self):
+        self._dll.tf_bI.restype = c_uint
+        self._dll.tf_bI.argtypes = (c_byte, c_uint)
+        self.assertEqual(self._dll.tf_bI(0, 4294967295), 1431655765)
+        self.assertEqual(self.U(), 4294967295)
+
+    def test_long(self):
+        self._dll.tf_l.restype = c_long
+        self._dll.tf_l.argtypes = (c_long,)
+        self.assertEqual(self._dll.tf_l(-2147483646), -715827882)
+        self.assertEqual(self.S(), -2147483646)
+
+    def test_long_plus(self):
+        self._dll.tf_bl.restype = c_long
+        self._dll.tf_bl.argtypes = (c_byte, c_long)
+        self.assertEqual(self._dll.tf_bl(0, -2147483646), -715827882)
+        self.assertEqual(self.S(), -2147483646)
+
+    def test_ulong(self):
+        self._dll.tf_L.restype = c_ulong
+        self._dll.tf_L.argtypes = (c_ulong,)
+        self.assertEqual(self._dll.tf_L(4294967295), 1431655765)
+        self.assertEqual(self.U(), 4294967295)
+
+    def test_ulong_plus(self):
+        self._dll.tf_bL.restype = c_ulong
+        self._dll.tf_bL.argtypes = (c_char, c_ulong)
+        self.assertEqual(self._dll.tf_bL(' ', 4294967295), 1431655765)
+        self.assertEqual(self.U(), 4294967295)
+
+    def test_longlong(self):
+        self._dll.tf_q.restype = c_longlong
+        self._dll.tf_q.argtypes = (c_longlong, )
+        self.assertEqual(self._dll.tf_q(-9223372036854775806), -3074457345618258602)
+        self.assertEqual(self.S(), -9223372036854775806)
+
+    def test_longlong_plus(self):
+        self._dll.tf_bq.restype = c_longlong
+        self._dll.tf_bq.argtypes = (c_byte, c_longlong)
+        self.assertEqual(self._dll.tf_bq(0, -9223372036854775806), -3074457345618258602)
+        self.assertEqual(self.S(), -9223372036854775806)
+
+    def test_ulonglong(self):
+        self._dll.tf_Q.restype = c_ulonglong
+        self._dll.tf_Q.argtypes = (c_ulonglong, )
+        self.assertEqual(self._dll.tf_Q(18446744073709551615), 6148914691236517205)
+        self.assertEqual(self.U(), 18446744073709551615)
+
+    def test_ulonglong_plus(self):
+        self._dll.tf_bQ.restype = c_ulonglong
+        self._dll.tf_bQ.argtypes = (c_byte, c_ulonglong)
+        self.assertEqual(self._dll.tf_bQ(0, 18446744073709551615), 6148914691236517205)
+        self.assertEqual(self.U(), 18446744073709551615)
+
+    def test_float(self):
+        self._dll.tf_f.restype = c_float
+        self._dll.tf_f.argtypes = (c_float,)
+        self.assertEqual(self._dll.tf_f(-42.), -14.)
+        self.assertEqual(self.S(), -42)
+
+    def test_float_plus(self):
+        self._dll.tf_bf.restype = c_float
+        self._dll.tf_bf.argtypes = (c_byte, c_float)
+        self.assertEqual(self._dll.tf_bf(0, -42.), -14.)
+        self.assertEqual(self.S(), -42)
+
+    def test_double(self):
+        self._dll.tf_d.restype = c_double
+        self._dll.tf_d.argtypes = (c_double,)
+        self.assertEqual(self._dll.tf_d(42.), 14.)
+        self.assertEqual(self.S(), 42)
+
+    def test_double_plus(self):
+        self._dll.tf_bd.restype = c_double
+        self._dll.tf_bd.argtypes = (c_byte, c_double)
+        self.assertEqual(self._dll.tf_bd(0, 42.), 14.)
+        self.assertEqual(self.S(), 42)
+
+    def test_longdouble(self):
+        self._dll.tf_D.restype = c_longdouble
+        self._dll.tf_D.argtypes = (c_longdouble,)
+        self.assertEqual(self._dll.tf_D(42.), 14.)
+        self.assertEqual(self.S(), 42)
+
+    def test_longdouble_plus(self):
+        self._dll.tf_bD.restype = c_longdouble
+        self._dll.tf_bD.argtypes = (c_byte, c_longdouble)
+        self.assertEqual(self._dll.tf_bD(0, 42.), 14.)
+        self.assertEqual(self.S(), 42)
+
+    def test_callwithresult(self):
+        def process_result(result):
+            return result * 2
+        self._dll.tf_i.restype = process_result
+        self._dll.tf_i.argtypes = (c_int,)
+        self.assertEqual(self._dll.tf_i(42), 28)
+        self.assertEqual(self.S(), 42)
+        self.assertEqual(self._dll.tf_i(-42), -28)
+        self.assertEqual(self.S(), -42)
+
+    def test_void(self):
+        self._dll.tv_i.restype = None
+        self._dll.tv_i.argtypes = (c_int,)
+        self.assertEqual(self._dll.tv_i(42), None)
+        self.assertEqual(self.S(), 42)
+        self.assertEqual(self._dll.tv_i(-42), None)
+        self.assertEqual(self.S(), -42)
+
+# The following repeates the above tests with stdcall functions (where
+# they are available)
+try:
+    WinDLL
+except NameError:
+    pass
+else:
+    class stdcall_dll(WinDLL):
+        def __getattr__(self, name):
+            if name[:2] == '__' and name[-2:] == '__':
+                raise AttributeError(name)
+            func = self._FuncPtr(("s_" + name, self))
+            setattr(self, name, func)
+            return func
+
+    class stdcallCFunctions(CFunctions):
+        _dll = stdcall_dll(_ctypes_test.__file__)
+        pass
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_checkretval.py b/lib/python2.7/ctypes/test/test_checkretval.py
new file mode 100644
index 0000000..01ccc57
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_checkretval.py
@@ -0,0 +1,39 @@
+import unittest
+
+from ctypes import *
+
+class CHECKED(c_int):
+    def _check_retval_(value):
+        # Receives a CHECKED instance.
+        return str(value.value)
+    _check_retval_ = staticmethod(_check_retval_)
+
+class Test(unittest.TestCase):
+
+    def test_checkretval(self):
+
+        import _ctypes_test
+        dll = CDLL(_ctypes_test.__file__)
+        self.assertEqual(42, dll._testfunc_p_p(42))
+
+        dll._testfunc_p_p.restype = CHECKED
+        self.assertEqual("42", dll._testfunc_p_p(42))
+
+        dll._testfunc_p_p.restype = None
+        self.assertEqual(None, dll._testfunc_p_p(42))
+
+        del dll._testfunc_p_p.restype
+        self.assertEqual(42, dll._testfunc_p_p(42))
+
+    try:
+        oledll
+    except NameError:
+        pass
+    else:
+        def test_oledll(self):
+            self.assertRaises(WindowsError,
+                                  oledll.oleaut32.CreateTypeLib2,
+                                  0, None, None)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_delattr.py b/lib/python2.7/ctypes/test/test_delattr.py
new file mode 100644
index 0000000..0f4d586
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_delattr.py
@@ -0,0 +1,21 @@
+import unittest
+from ctypes import *
+
+class X(Structure):
+    _fields_ = [("foo", c_int)]
+
+class TestCase(unittest.TestCase):
+    def test_simple(self):
+        self.assertRaises(TypeError,
+                          delattr, c_int(42), "value")
+
+    def test_chararray(self):
+        self.assertRaises(TypeError,
+                          delattr, (c_char * 5)(), "value")
+
+    def test_struct(self):
+        self.assertRaises(TypeError,
+                          delattr, X(), "foo")
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_errcheck.py b/lib/python2.7/ctypes/test/test_errcheck.py
new file mode 100644
index 0000000..a4913f9
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_errcheck.py
@@ -0,0 +1,19 @@
+import sys
+from ctypes import *
+
+##class HMODULE(Structure):
+##    _fields_ = [("value", c_void_p)]
+
+##    def __repr__(self):
+##        return "<HMODULE %s>" % self.value
+
+##windll.kernel32.GetModuleHandleA.restype = HMODULE
+
+##print windll.kernel32.GetModuleHandleA("python23.dll")
+##print hex(sys.dllhandle)
+
+##def nonzero(handle):
+##    return (GetLastError(), handle)
+
+##windll.kernel32.GetModuleHandleA.errcheck = nonzero
+##print windll.kernel32.GetModuleHandleA("spam")
diff --git a/lib/python2.7/ctypes/test/test_errno.py b/lib/python2.7/ctypes/test/test_errno.py
new file mode 100644
index 0000000..c7a5bf0
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_errno.py
@@ -0,0 +1,80 @@
+import unittest, os, errno
+from ctypes import *
+from ctypes.util import find_library
+from test import test_support
+try:
+    import threading
+except ImportError:
+    threading = None
+
+class Test(unittest.TestCase):
+    def test_open(self):
+        libc_name = find_library("c")
+        if libc_name is None:
+            raise unittest.SkipTest("Unable to find C library")
+        libc = CDLL(libc_name, use_errno=True)
+        if os.name == "nt":
+            libc_open = libc._open
+        else:
+            libc_open = libc.open
+
+        libc_open.argtypes = c_char_p, c_int
+
+        self.assertEqual(libc_open("", 0), -1)
+        self.assertEqual(get_errno(), errno.ENOENT)
+
+        self.assertEqual(set_errno(32), errno.ENOENT)
+        self.assertEqual(get_errno(), 32)
+
+        if threading:
+            def _worker():
+                set_errno(0)
+
+                libc = CDLL(libc_name, use_errno=False)
+                if os.name == "nt":
+                    libc_open = libc._open
+                else:
+                    libc_open = libc.open
+                libc_open.argtypes = c_char_p, c_int
+                self.assertEqual(libc_open("", 0), -1)
+                self.assertEqual(get_errno(), 0)
+
+            t = threading.Thread(target=_worker)
+            t.start()
+            t.join()
+
+            self.assertEqual(get_errno(), 32)
+            set_errno(0)
+
+    @unittest.skipUnless(os.name == "nt", 'Test specific to Windows')
+    def test_GetLastError(self):
+        dll = WinDLL("kernel32", use_last_error=True)
+        GetModuleHandle = dll.GetModuleHandleA
+        GetModuleHandle.argtypes = [c_wchar_p]
+
+        self.assertEqual(0, GetModuleHandle("foo"))
+        self.assertEqual(get_last_error(), 126)
+
+        self.assertEqual(set_last_error(32), 126)
+        self.assertEqual(get_last_error(), 32)
+
+        def _worker():
+            set_last_error(0)
+
+            dll = WinDLL("kernel32", use_last_error=False)
+            GetModuleHandle = dll.GetModuleHandleW
+            GetModuleHandle.argtypes = [c_wchar_p]
+            GetModuleHandle("bar")
+
+            self.assertEqual(get_last_error(), 0)
+
+        t = threading.Thread(target=_worker)
+        t.start()
+        t.join()
+
+        self.assertEqual(get_last_error(), 32)
+
+        set_last_error(0)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_find.py b/lib/python2.7/ctypes/test/test_find.py
new file mode 100644
index 0000000..77e789f
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_find.py
@@ -0,0 +1,82 @@
+import unittest
+import sys
+from ctypes import *
+from ctypes.util import find_library
+from ctypes.test import is_resource_enabled
+
+if sys.platform == "win32":
+    lib_gl = find_library("OpenGL32")
+    lib_glu = find_library("Glu32")
+    lib_gle = None
+elif sys.platform == "darwin":
+    lib_gl = lib_glu = find_library("OpenGL")
+    lib_gle = None
+else:
+    lib_gl = find_library("GL")
+    lib_glu = find_library("GLU")
+    lib_gle = find_library("gle")
+
+## print, for debugging
+if is_resource_enabled("printing"):
+    if lib_gl or lib_glu or lib_gle:
+        print "OpenGL libraries:"
+        for item in (("GL", lib_gl),
+                     ("GLU", lib_glu),
+                     ("gle", lib_gle)):
+            print "\t", item
+
+
+# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
+class Test_OpenGL_libs(unittest.TestCase):
+    def setUp(self):
+        self.gl = self.glu = self.gle = None
+        if lib_gl:
+            self.gl = CDLL(lib_gl, mode=RTLD_GLOBAL)
+        if lib_glu:
+            self.glu = CDLL(lib_glu, RTLD_GLOBAL)
+        if lib_gle:
+            try:
+                self.gle = CDLL(lib_gle)
+            except OSError:
+                pass
+
+    if lib_gl:
+        def test_gl(self):
+            if self.gl:
+                self.gl.glClearIndex
+
+    if lib_glu:
+        def test_glu(self):
+            if self.glu:
+                self.glu.gluBeginCurve
+
+    if lib_gle:
+        def test_gle(self):
+            if self.gle:
+                self.gle.gleGetJoinStyle
+
+##if os.name == "posix" and sys.platform != "darwin":
+
+##    # On platforms where the default shared library suffix is '.so',
+##    # at least some libraries can be loaded as attributes of the cdll
+##    # object, since ctypes now tries loading the lib again
+##    # with '.so' appended of the first try fails.
+##    #
+##    # Won't work for libc, unfortunately.  OTOH, it isn't
+##    # needed for libc since this is already mapped into the current
+##    # process (?)
+##    #
+##    # On MAC OSX, it won't work either, because dlopen() needs a full path,
+##    # and the default suffix is either none or '.dylib'.
+
+##    class LoadLibs(unittest.TestCase):
+##        def test_libm(self):
+##            import math
+##            libm = cdll.libm
+##            sqrt = libm.sqrt
+##            sqrt.argtypes = (c_double,)
+##            sqrt.restype = c_double
+##            self.assertEqual(sqrt(2), math.sqrt(2))
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_frombuffer.py b/lib/python2.7/ctypes/test/test_frombuffer.py
new file mode 100644
index 0000000..624fb70
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_frombuffer.py
@@ -0,0 +1,81 @@
+from ctypes import *
+import array
+import gc
+import unittest
+
+class X(Structure):
+    _fields_ = [("c_int", c_int)]
+    init_called = False
+    def __init__(self):
+        self._init_called = True
+
+class Test(unittest.TestCase):
+    def test_fom_buffer(self):
+        a = array.array("i", range(16))
+        x = (c_int * 16).from_buffer(a)
+
+        y = X.from_buffer(a)
+        self.assertEqual(y.c_int, a[0])
+        self.assertFalse(y.init_called)
+
+        self.assertEqual(x[:], a.tolist())
+
+        a[0], a[-1] = 200, -200
+        self.assertEqual(x[:], a.tolist())
+
+        self.assertTrue(a in x._objects.values())
+
+        self.assertRaises(ValueError,
+                          c_int.from_buffer, a, -1)
+
+        expected = x[:]
+        del a; gc.collect(); gc.collect(); gc.collect()
+        self.assertEqual(x[:], expected)
+
+        self.assertRaises(TypeError,
+                          (c_char * 16).from_buffer, "a" * 16)
+
+    def test_fom_buffer_with_offset(self):
+        a = array.array("i", range(16))
+        x = (c_int * 15).from_buffer(a, sizeof(c_int))
+
+        self.assertEqual(x[:], a.tolist()[1:])
+        self.assertRaises(ValueError, lambda: (c_int * 16).from_buffer(a, sizeof(c_int)))
+        self.assertRaises(ValueError, lambda: (c_int * 1).from_buffer(a, 16 * sizeof(c_int)))
+
+    def test_from_buffer_copy(self):
+        a = array.array("i", range(16))
+        x = (c_int * 16).from_buffer_copy(a)
+
+        y = X.from_buffer_copy(a)
+        self.assertEqual(y.c_int, a[0])
+        self.assertFalse(y.init_called)
+
+        self.assertEqual(x[:], range(16))
+
+        a[0], a[-1] = 200, -200
+        self.assertEqual(x[:], range(16))
+
+        self.assertEqual(x._objects, None)
+
+        self.assertRaises(ValueError,
+                          c_int.from_buffer, a, -1)
+
+        del a; gc.collect(); gc.collect(); gc.collect()
+        self.assertEqual(x[:], range(16))
+
+        x = (c_char * 16).from_buffer_copy("a" * 16)
+        self.assertEqual(x[:], "a" * 16)
+
+    def test_fom_buffer_copy_with_offset(self):
+        a = array.array("i", range(16))
+        x = (c_int * 15).from_buffer_copy(a, sizeof(c_int))
+
+        self.assertEqual(x[:], a.tolist()[1:])
+        self.assertRaises(ValueError,
+                          (c_int * 16).from_buffer_copy, a, sizeof(c_int))
+        self.assertRaises(ValueError,
+                          (c_int * 1).from_buffer_copy, a, 16 * sizeof(c_int))
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_funcptr.py b/lib/python2.7/ctypes/test/test_funcptr.py
new file mode 100644
index 0000000..99af5ed
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_funcptr.py
@@ -0,0 +1,127 @@
+import os, unittest
+from ctypes import *
+
+try:
+    WINFUNCTYPE
+except NameError:
+    # fake to enable this test on Linux
+    WINFUNCTYPE = CFUNCTYPE
+
+import _ctypes_test
+lib = CDLL(_ctypes_test.__file__)
+
+class CFuncPtrTestCase(unittest.TestCase):
+    def test_basic(self):
+        X = WINFUNCTYPE(c_int, c_int, c_int)
+
+        def func(*args):
+            return len(args)
+
+        x = X(func)
+        self.assertEqual(x.restype, c_int)
+        self.assertEqual(x.argtypes, (c_int, c_int))
+        self.assertEqual(sizeof(x), sizeof(c_voidp))
+        self.assertEqual(sizeof(X), sizeof(c_voidp))
+
+    def test_first(self):
+        StdCallback = WINFUNCTYPE(c_int, c_int, c_int)
+        CdeclCallback = CFUNCTYPE(c_int, c_int, c_int)
+
+        def func(a, b):
+            return a + b
+
+        s = StdCallback(func)
+        c = CdeclCallback(func)
+
+        self.assertEqual(s(1, 2), 3)
+        self.assertEqual(c(1, 2), 3)
+        # The following no longer raises a TypeError - it is now
+        # possible, as in C, to call cdecl functions with more parameters.
+        #self.assertRaises(TypeError, c, 1, 2, 3)
+        self.assertEqual(c(1, 2, 3, 4, 5, 6), 3)
+        if not WINFUNCTYPE is CFUNCTYPE and os.name != "ce":
+            self.assertRaises(TypeError, s, 1, 2, 3)
+
+    def test_structures(self):
+        WNDPROC = WINFUNCTYPE(c_long, c_int, c_int, c_int, c_int)
+
+        def wndproc(hwnd, msg, wParam, lParam):
+            return hwnd + msg + wParam + lParam
+
+        HINSTANCE = c_int
+        HICON = c_int
+        HCURSOR = c_int
+        LPCTSTR = c_char_p
+
+        class WNDCLASS(Structure):
+            _fields_ = [("style", c_uint),
+                        ("lpfnWndProc", WNDPROC),
+                        ("cbClsExtra", c_int),
+                        ("cbWndExtra", c_int),
+                        ("hInstance", HINSTANCE),
+                        ("hIcon", HICON),
+                        ("hCursor", HCURSOR),
+                        ("lpszMenuName", LPCTSTR),
+                        ("lpszClassName", LPCTSTR)]
+
+        wndclass = WNDCLASS()
+        wndclass.lpfnWndProc = WNDPROC(wndproc)
+
+        WNDPROC_2 = WINFUNCTYPE(c_long, c_int, c_int, c_int, c_int)
+
+        # This is no longer true, now that WINFUNCTYPE caches created types internally.
+        ## # CFuncPtr subclasses are compared by identity, so this raises a TypeError:
+        ## self.assertRaises(TypeError, setattr, wndclass,
+        ##                  "lpfnWndProc", WNDPROC_2(wndproc))
+        # instead:
+
+        self.assertTrue(WNDPROC is WNDPROC_2)
+        # 'wndclass.lpfnWndProc' leaks 94 references.  Why?
+        self.assertEqual(wndclass.lpfnWndProc(1, 2, 3, 4), 10)
+
+
+        f = wndclass.lpfnWndProc
+
+        del wndclass
+        del wndproc
+
+        self.assertEqual(f(10, 11, 12, 13), 46)
+
+    def test_dllfunctions(self):
+
+        def NoNullHandle(value):
+            if not value:
+                raise WinError()
+            return value
+
+        strchr = lib.my_strchr
+        strchr.restype = c_char_p
+        strchr.argtypes = (c_char_p, c_char)
+        self.assertEqual(strchr("abcdefghi", "b"), "bcdefghi")
+        self.assertEqual(strchr("abcdefghi", "x"), None)
+
+
+        strtok = lib.my_strtok
+        strtok.restype = c_char_p
+        # Neither of this does work: strtok changes the buffer it is passed
+##        strtok.argtypes = (c_char_p, c_char_p)
+##        strtok.argtypes = (c_string, c_char_p)
+
+        def c_string(init):
+            size = len(init) + 1
+            return (c_char*size)(*init)
+
+        s = "a\nb\nc"
+        b = c_string(s)
+
+##        b = (c_char * (len(s)+1))()
+##        b.value = s
+
+##        b = c_string(s)
+        self.assertEqual(strtok(b, "\n"), "a")
+        self.assertEqual(strtok(None, "\n"), "b")
+        self.assertEqual(strtok(None, "\n"), "c")
+        self.assertEqual(strtok(None, "\n"), None)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_functions.py b/lib/python2.7/ctypes/test/test_functions.py
new file mode 100644
index 0000000..13bd3ec
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_functions.py
@@ -0,0 +1,412 @@
+"""
+Here is probably the place to write the docs, since the test-cases
+show how the type behave.
+
+Later...
+"""
+
+from ctypes import *
+import sys, unittest
+
+try:
+    WINFUNCTYPE
+except NameError:
+    # fake to enable this test on Linux
+    WINFUNCTYPE = CFUNCTYPE
+
+import _ctypes_test
+dll = CDLL(_ctypes_test.__file__)
+if sys.platform == "win32":
+    windll = WinDLL(_ctypes_test.__file__)
+
+class POINT(Structure):
+    _fields_ = [("x", c_int), ("y", c_int)]
+class RECT(Structure):
+    _fields_ = [("left", c_int), ("top", c_int),
+                ("right", c_int), ("bottom", c_int)]
+class FunctionTestCase(unittest.TestCase):
+
+    def test_mro(self):
+        # in Python 2.3, this raises TypeError: MRO conflict among bases classes,
+        # in Python 2.2 it works.
+        #
+        # But in early versions of _ctypes.c, the result of tp_new
+        # wasn't checked, and it even crashed Python.
+        # Found by Greg Chapman.
+
+        try:
+            class X(object, Array):
+                _length_ = 5
+                _type_ = "i"
+        except TypeError:
+            pass
+
+
+        from _ctypes import _Pointer
+        try:
+            class X(object, _Pointer):
+                pass
+        except TypeError:
+            pass
+
+        from _ctypes import _SimpleCData
+        try:
+            class X(object, _SimpleCData):
+                _type_ = "i"
+        except TypeError:
+            pass
+
+        try:
+            class X(object, Structure):
+                _fields_ = []
+        except TypeError:
+            pass
+
+
+    def test_wchar_parm(self):
+        try:
+            c_wchar
+        except NameError:
+            return
+        f = dll._testfunc_i_bhilfd
+        f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
+        result = f(1, u"x", 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 139)
+        self.assertEqual(type(result), int)
+
+    def test_wchar_result(self):
+        try:
+            c_wchar
+        except NameError:
+            return
+        f = dll._testfunc_i_bhilfd
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+        f.restype = c_wchar
+        result = f(0, 0, 0, 0, 0, 0)
+        self.assertEqual(result, u'\x00')
+
+    def test_voidresult(self):
+        f = dll._testfunc_v
+        f.restype = None
+        f.argtypes = [c_int, c_int, POINTER(c_int)]
+        result = c_int()
+        self.assertEqual(None, f(1, 2, byref(result)))
+        self.assertEqual(result.value, 3)
+
+    def test_intresult(self):
+        f = dll._testfunc_i_bhilfd
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+        f.restype = c_int
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), int)
+
+        result = f(-1, -2, -3, -4, -5.0, -6.0)
+        self.assertEqual(result, -21)
+        self.assertEqual(type(result), int)
+
+        # If we declare the function to return a short,
+        # is the high part split off?
+        f.restype = c_short
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), int)
+
+        result = f(1, 2, 3, 0x10004, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), int)
+
+        # You cannot assign character format codes as restype any longer
+        self.assertRaises(TypeError, setattr, f, "restype", "i")
+
+    def test_floatresult(self):
+        f = dll._testfunc_f_bhilfd
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+        f.restype = c_float
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), float)
+
+        result = f(-1, -2, -3, -4, -5.0, -6.0)
+        self.assertEqual(result, -21)
+        self.assertEqual(type(result), float)
+
+    def test_doubleresult(self):
+        f = dll._testfunc_d_bhilfd
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+        f.restype = c_double
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), float)
+
+        result = f(-1, -2, -3, -4, -5.0, -6.0)
+        self.assertEqual(result, -21)
+        self.assertEqual(type(result), float)
+
+    def test_longdoubleresult(self):
+        f = dll._testfunc_D_bhilfD
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_longdouble]
+        f.restype = c_longdouble
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+        self.assertEqual(type(result), float)
+
+        result = f(-1, -2, -3, -4, -5.0, -6.0)
+        self.assertEqual(result, -21)
+        self.assertEqual(type(result), float)
+
+    def test_longlongresult(self):
+        try:
+            c_longlong
+        except NameError:
+            return
+        f = dll._testfunc_q_bhilfd
+        f.restype = c_longlong
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
+        result = f(1, 2, 3, 4, 5.0, 6.0)
+        self.assertEqual(result, 21)
+
+        f = dll._testfunc_q_bhilfdq
+        f.restype = c_longlong
+        f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double, c_longlong]
+        result = f(1, 2, 3, 4, 5.0, 6.0, 21)
+        self.assertEqual(result, 42)
+
+    def test_stringresult(self):
+        f = dll._testfunc_p_p
+        f.argtypes = None
+        f.restype = c_char_p
+        result = f("123")
+        self.assertEqual(result, "123")
+
+        result = f(None)
+        self.assertEqual(result, None)
+
+    def test_pointers(self):
+        f = dll._testfunc_p_p
+        f.restype = POINTER(c_int)
+        f.argtypes = [POINTER(c_int)]
+
+        # This only works if the value c_int(42) passed to the
+        # function is still alive while the pointer (the result) is
+        # used.
+
+        v = c_int(42)
+
+        self.assertEqual(pointer(v).contents.value, 42)
+        result = f(pointer(v))
+        self.assertEqual(type(result), POINTER(c_int))
+        self.assertEqual(result.contents.value, 42)
+
+        # This on works...
+        result = f(pointer(v))
+        self.assertEqual(result.contents.value, v.value)
+
+        p = pointer(c_int(99))
+        result = f(p)
+        self.assertEqual(result.contents.value, 99)
+
+        arg = byref(v)
+        result = f(arg)
+        self.assertNotEqual(result.contents, v.value)
+
+        self.assertRaises(ArgumentError, f, byref(c_short(22)))
+
+        # It is dangerous, however, because you don't control the lifetime
+        # of the pointer:
+        result = f(byref(c_int(99)))
+        self.assertNotEqual(result.contents, 99)
+
+    def test_errors(self):
+        f = dll._testfunc_p_p
+        f.restype = c_int
+
+        class X(Structure):
+            _fields_ = [("y", c_int)]
+
+        self.assertRaises(TypeError, f, X()) #cannot convert parameter
+
+    ################################################################
+    def test_shorts(self):
+        f = dll._testfunc_callback_i_if
+
+        args = []
+        expected = [262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048,
+                    1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
+
+        def callback(v):
+            args.append(v)
+            return v
+
+        CallBack = CFUNCTYPE(c_int, c_int)
+
+        cb = CallBack(callback)
+        f(2**18, cb)
+        self.assertEqual(args, expected)
+
+    ################################################################
+
+
+    def test_callbacks(self):
+        f = dll._testfunc_callback_i_if
+        f.restype = c_int
+        f.argtypes = None
+
+        MyCallback = CFUNCTYPE(c_int, c_int)
+
+        def callback(value):
+            #print "called back with", value
+            return value
+
+        cb = MyCallback(callback)
+        result = f(-10, cb)
+        self.assertEqual(result, -18)
+
+        # test with prototype
+        f.argtypes = [c_int, MyCallback]
+        cb = MyCallback(callback)
+        result = f(-10, cb)
+        self.assertEqual(result, -18)
+
+        AnotherCallback = WINFUNCTYPE(c_int, c_int, c_int, c_int, c_int)
+
+        # check that the prototype works: we call f with wrong
+        # argument types
+        cb = AnotherCallback(callback)
+        self.assertRaises(ArgumentError, f, -10, cb)
+
+
+    def test_callbacks_2(self):
+        # Can also use simple datatypes as argument type specifiers
+        # for the callback function.
+        # In this case the call receives an instance of that type
+        f = dll._testfunc_callback_i_if
+        f.restype = c_int
+
+        MyCallback = CFUNCTYPE(c_int, c_int)
+
+        f.argtypes = [c_int, MyCallback]
+
+        def callback(value):
+            #print "called back with", value
+            self.assertEqual(type(value), int)
+            return value
+
+        cb = MyCallback(callback)
+        result = f(-10, cb)
+        self.assertEqual(result, -18)
+
+    def test_longlong_callbacks(self):
+
+        f = dll._testfunc_callback_q_qf
+        f.restype = c_longlong
+
+        MyCallback = CFUNCTYPE(c_longlong, c_longlong)
+
+        f.argtypes = [c_longlong, MyCallback]
+
+        def callback(value):
+            self.assertTrue(isinstance(value, (int, long)))
+            return value & 0x7FFFFFFF
+
+        cb = MyCallback(callback)
+
+        self.assertEqual(13577625587, f(1000000000000, cb))
+
+    def test_errors(self):
+        self.assertRaises(AttributeError, getattr, dll, "_xxx_yyy")
+        self.assertRaises(ValueError, c_int.in_dll, dll, "_xxx_yyy")
+
+    def test_byval(self):
+
+        # without prototype
+        ptin = POINT(1, 2)
+        ptout = POINT()
+        # EXPORT int _testfunc_byval(point in, point *pout)
+        result = dll._testfunc_byval(ptin, byref(ptout))
+        got = result, ptout.x, ptout.y
+        expected = 3, 1, 2
+        self.assertEqual(got, expected)
+
+        # with prototype
+        ptin = POINT(101, 102)
+        ptout = POINT()
+        dll._testfunc_byval.argtypes = (POINT, POINTER(POINT))
+        dll._testfunc_byval.restype = c_int
+        result = dll._testfunc_byval(ptin, byref(ptout))
+        got = result, ptout.x, ptout.y
+        expected = 203, 101, 102
+        self.assertEqual(got, expected)
+
+    def test_struct_return_2H(self):
+        class S2H(Structure):
+            _fields_ = [("x", c_short),
+                        ("y", c_short)]
+        dll.ret_2h_func.restype = S2H
+        dll.ret_2h_func.argtypes = [S2H]
+        inp = S2H(99, 88)
+        s2h = dll.ret_2h_func(inp)
+        self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
+
+    if sys.platform == "win32":
+        def test_struct_return_2H_stdcall(self):
+            class S2H(Structure):
+                _fields_ = [("x", c_short),
+                            ("y", c_short)]
+
+            windll.s_ret_2h_func.restype = S2H
+            windll.s_ret_2h_func.argtypes = [S2H]
+            s2h = windll.s_ret_2h_func(S2H(99, 88))
+            self.assertEqual((s2h.x, s2h.y), (99*2, 88*3))
+
+    # This is known cdecl incompatibility between GCC
+    # and MSVC. It is addressed in GCC issue #36834.
+    # Python libffi detect it and complain.
+    @unittest.skipIf(sys.platform == "win32" and sys.version.find("GCC") >= 0, 'XFAIL GCC(mingw)')
+    def test_struct_return_8H(self):
+        class S8I(Structure):
+            _fields_ = [("a", c_int),
+                        ("b", c_int),
+                        ("c", c_int),
+                        ("d", c_int),
+                        ("e", c_int),
+                        ("f", c_int),
+                        ("g", c_int),
+                        ("h", c_int)]
+        dll.ret_8i_func.restype = S8I
+        dll.ret_8i_func.argtypes = [S8I]
+        inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
+        s8i = dll.ret_8i_func(inp)
+        self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+                             (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
+
+    if sys.platform == "win32":
+        def test_struct_return_8H_stdcall(self):
+            class S8I(Structure):
+                _fields_ = [("a", c_int),
+                            ("b", c_int),
+                            ("c", c_int),
+                            ("d", c_int),
+                            ("e", c_int),
+                            ("f", c_int),
+                            ("g", c_int),
+                            ("h", c_int)]
+            windll.s_ret_8i_func.restype = S8I
+            windll.s_ret_8i_func.argtypes = [S8I]
+            inp = S8I(9, 8, 7, 6, 5, 4, 3, 2)
+            s8i = windll.s_ret_8i_func(inp)
+            self.assertEqual((s8i.a, s8i.b, s8i.c, s8i.d, s8i.e, s8i.f, s8i.g, s8i.h),
+                                 (9*2, 8*3, 7*4, 6*5, 5*6, 4*7, 3*8, 2*9))
+
+    def test_sf1651235(self):
+        # see http://www.python.org/sf/1651235
+
+        proto = CFUNCTYPE(c_int, RECT, POINT)
+        def callback(*args):
+            return 0
+
+        callback = proto(callback)
+        self.assertRaises(ArgumentError, lambda: callback((1, 2, 3, 4), POINT()))
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_incomplete.py b/lib/python2.7/ctypes/test/test_incomplete.py
new file mode 100644
index 0000000..1e03e9f
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_incomplete.py
@@ -0,0 +1,42 @@
+import unittest
+from ctypes import *
+
+################################################################
+#
+# The incomplete pointer example from the tutorial
+#
+
+class MyTestCase(unittest.TestCase):
+
+    def test_incomplete_example(self):
+        lpcell = POINTER("cell")
+        class cell(Structure):
+            _fields_ = [("name", c_char_p),
+                        ("next", lpcell)]
+
+        SetPointerType(lpcell, cell)
+
+        c1 = cell()
+        c1.name = "foo"
+        c2 = cell()
+        c2.name = "bar"
+
+        c1.next = pointer(c2)
+        c2.next = pointer(c1)
+
+        p = c1
+
+        result = []
+        for i in range(8):
+            result.append(p.name)
+            p = p.next[0]
+        self.assertEqual(result, ["foo", "bar"] * 4)
+
+        # to not leak references, we must clean _pointer_type_cache
+        from ctypes import _pointer_type_cache
+        del _pointer_type_cache[cell]
+
+################################################################
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_init.py b/lib/python2.7/ctypes/test/test_init.py
new file mode 100644
index 0000000..82bd1f9
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_init.py
@@ -0,0 +1,40 @@
+from ctypes import *
+import unittest
+
+class X(Structure):
+    _fields_ = [("a", c_int),
+                ("b", c_int)]
+    new_was_called = False
+
+    def __new__(cls):
+        result = super(X, cls).__new__(cls)
+        result.new_was_called = True
+        return result
+
+    def __init__(self):
+        self.a = 9
+        self.b = 12
+
+class Y(Structure):
+    _fields_ = [("x", X)]
+
+
+class InitTest(unittest.TestCase):
+    def test_get(self):
+        # make sure the only accessing a nested structure
+        # doesn't call the structure's __new__ and __init__
+        y = Y()
+        self.assertEqual((y.x.a, y.x.b), (0, 0))
+        self.assertEqual(y.x.new_was_called, False)
+
+        # But explicitly creating an X structure calls __new__ and __init__, of course.
+        x = X()
+        self.assertEqual((x.a, x.b), (9, 12))
+        self.assertEqual(x.new_was_called, True)
+
+        y.x = x
+        self.assertEqual((y.x.a, y.x.b), (9, 12))
+        self.assertEqual(y.x.new_was_called, False)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_integers.py b/lib/python2.7/ctypes/test/test_integers.py
new file mode 100644
index 0000000..5b6453a
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_integers.py
@@ -0,0 +1,5 @@
+# superseeded by test_numbers.py
+import unittest
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_internals.py b/lib/python2.7/ctypes/test/test_internals.py
new file mode 100644
index 0000000..2e5b1fe
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_internals.py
@@ -0,0 +1,103 @@
+# This tests the internal _objects attribute
+import unittest
+from ctypes import *
+from sys import getrefcount as grc
+
+# XXX This test must be reviewed for correctness!!!
+
+"""
+ctypes' types are container types.
+
+They have an internal memory block, which only consists of some bytes,
+but it has to keep references to other objects as well. This is not
+really needed for trivial C types like int or char, but it is important
+for aggregate types like strings or pointers in particular.
+
+What about pointers?
+
+"""
+
+class ObjectsTestCase(unittest.TestCase):
+    def assertSame(self, a, b):
+        self.assertEqual(id(a), id(b))
+
+    def test_ints(self):
+        i = 42000123
+        refcnt = grc(i)
+        ci = c_int(i)
+        self.assertEqual(refcnt, grc(i))
+        self.assertEqual(ci._objects, None)
+
+    def test_c_char_p(self):
+        s = "Hello, World"
+        refcnt = grc(s)
+        cs = c_char_p(s)
+        self.assertEqual(refcnt + 1, grc(s))
+        self.assertSame(cs._objects, s)
+
+    def test_simple_struct(self):
+        class X(Structure):
+            _fields_ = [("a", c_int), ("b", c_int)]
+
+        a = 421234
+        b = 421235
+        x = X()
+        self.assertEqual(x._objects, None)
+        x.a = a
+        x.b = b
+        self.assertEqual(x._objects, None)
+
+    def test_embedded_structs(self):
+        class X(Structure):
+            _fields_ = [("a", c_int), ("b", c_int)]
+
+        class Y(Structure):
+            _fields_ = [("x", X), ("y", X)]
+
+        y = Y()
+        self.assertEqual(y._objects, None)
+
+        x1, x2 = X(), X()
+        y.x, y.y = x1, x2
+        self.assertEqual(y._objects, {"0": {}, "1": {}})
+        x1.a, x2.b = 42, 93
+        self.assertEqual(y._objects, {"0": {}, "1": {}})
+
+    def test_xxx(self):
+        class X(Structure):
+            _fields_ = [("a", c_char_p), ("b", c_char_p)]
+
+        class Y(Structure):
+            _fields_ = [("x", X), ("y", X)]
+
+        s1 = "Hello, World"
+        s2 = "Hallo, Welt"
+
+        x = X()
+        x.a = s1
+        x.b = s2
+        self.assertEqual(x._objects, {"0": s1, "1": s2})
+
+        y = Y()
+        y.x = x
+        self.assertEqual(y._objects, {"0": {"0": s1, "1": s2}})
+##        x = y.x
+##        del y
+##        print x._b_base_._objects
+
+    def test_ptr_struct(self):
+        class X(Structure):
+            _fields_ = [("data", POINTER(c_int))]
+
+        A = c_int*4
+        a = A(11, 22, 33, 44)
+        self.assertEqual(a._objects, None)
+
+        x = X()
+        x.data = a
+##XXX        print x._objects
+##XXX        print x.data[0]
+##XXX        print x.data._objects
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_keeprefs.py b/lib/python2.7/ctypes/test/test_keeprefs.py
new file mode 100644
index 0000000..b504c0c
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_keeprefs.py
@@ -0,0 +1,152 @@
+from ctypes import *
+import unittest
+
+class SimpleTestCase(unittest.TestCase):
+    def test_cint(self):
+        x = c_int()
+        self.assertEqual(x._objects, None)
+        x.value = 42
+        self.assertEqual(x._objects, None)
+        x = c_int(99)
+        self.assertEqual(x._objects, None)
+
+    def test_ccharp(self):
+        x = c_char_p()
+        self.assertEqual(x._objects, None)
+        x.value = "abc"
+        self.assertEqual(x._objects, "abc")
+        x = c_char_p("spam")
+        self.assertEqual(x._objects, "spam")
+
+class StructureTestCase(unittest.TestCase):
+    def test_cint_struct(self):
+        class X(Structure):
+            _fields_ = [("a", c_int),
+                        ("b", c_int)]
+
+        x = X()
+        self.assertEqual(x._objects, None)
+        x.a = 42
+        x.b = 99
+        self.assertEqual(x._objects, None)
+
+    def test_ccharp_struct(self):
+        class X(Structure):
+            _fields_ = [("a", c_char_p),
+                        ("b", c_char_p)]
+        x = X()
+        self.assertEqual(x._objects, None)
+
+        x.a = "spam"
+        x.b = "foo"
+        self.assertEqual(x._objects, {"0": "spam", "1": "foo"})
+
+    def test_struct_struct(self):
+        class POINT(Structure):
+            _fields_ = [("x", c_int), ("y", c_int)]
+        class RECT(Structure):
+            _fields_ = [("ul", POINT), ("lr", POINT)]
+
+        r = RECT()
+        r.ul.x = 0
+        r.ul.y = 1
+        r.lr.x = 2
+        r.lr.y = 3
+        self.assertEqual(r._objects, None)
+
+        r = RECT()
+        pt = POINT(1, 2)
+        r.ul = pt
+        self.assertEqual(r._objects, {'0': {}})
+        r.ul.x = 22
+        r.ul.y = 44
+        self.assertEqual(r._objects, {'0': {}})
+        r.lr = POINT()
+        self.assertEqual(r._objects, {'0': {}, '1': {}})
+
+class ArrayTestCase(unittest.TestCase):
+    def test_cint_array(self):
+        INTARR = c_int * 3
+
+        ia = INTARR()
+        self.assertEqual(ia._objects, None)
+        ia[0] = 1
+        ia[1] = 2
+        ia[2] = 3
+        self.assertEqual(ia._objects, None)
+
+        class X(Structure):
+            _fields_ = [("x", c_int),
+                        ("a", INTARR)]
+
+        x = X()
+        x.x = 1000
+        x.a[0] = 42
+        x.a[1] = 96
+        self.assertEqual(x._objects, None)
+        x.a = ia
+        self.assertEqual(x._objects, {'1': {}})
+
+class PointerTestCase(unittest.TestCase):
+    def test_p_cint(self):
+        i = c_int(42)
+        x = pointer(i)
+        self.assertEqual(x._objects, {'1': i})
+
+class DeletePointerTestCase(unittest.TestCase):
+    def X_test(self):
+        class X(Structure):
+            _fields_ = [("p", POINTER(c_char_p))]
+        x = X()
+        i = c_char_p("abc def")
+        from sys import getrefcount as grc
+        print "2?", grc(i)
+        x.p = pointer(i)
+        print "3?", grc(i)
+        for i in range(320):
+            c_int(99)
+            x.p[0]
+        print x.p[0]
+##        del x
+##        print "2?", grc(i)
+##        del i
+        import gc
+        gc.collect()
+        for i in range(320):
+            c_int(99)
+            x.p[0]
+        print x.p[0]
+        print x.p.contents
+##        print x._objects
+
+        x.p[0] = "spam spam"
+##        print x.p[0]
+        print "+" * 42
+        print x._objects
+
+class PointerToStructure(unittest.TestCase):
+    def test(self):
+        class POINT(Structure):
+            _fields_ = [("x", c_int), ("y", c_int)]
+        class RECT(Structure):
+            _fields_ = [("a", POINTER(POINT)),
+                        ("b", POINTER(POINT))]
+        r = RECT()
+        p1 = POINT(1, 2)
+
+        r.a = pointer(p1)
+        r.b = pointer(p1)
+##        from pprint import pprint as pp
+##        pp(p1._objects)
+##        pp(r._objects)
+
+        r.a[0].x = 42
+        r.a[0].y = 99
+
+        # to avoid leaking when tests are run several times
+        # clean up the types left in the cache.
+        from ctypes import _pointer_type_cache
+        del _pointer_type_cache[POINT]
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_libc.py b/lib/python2.7/ctypes/test/test_libc.py
new file mode 100644
index 0000000..3dc463f
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_libc.py
@@ -0,0 +1,29 @@
+import unittest
+
+from ctypes import *
+import _ctypes_test
+
+lib = CDLL(_ctypes_test.__file__)
+
+class LibTest(unittest.TestCase):
+    def test_sqrt(self):
+        lib.my_sqrt.argtypes = c_double,
+        lib.my_sqrt.restype = c_double
+        self.assertEqual(lib.my_sqrt(4.0), 2.0)
+        import math
+        self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
+
+    def test_qsort(self):
+        comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
+        lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
+        lib.my_qsort.restype = None
+
+        def sort(a, b):
+            return cmp(a[0], b[0])
+
+        chars = create_string_buffer("spam, spam, and spam")
+        lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort))
+        self.assertEqual(chars.raw, "   ,,aaaadmmmnpppsss\x00")
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_loading.py b/lib/python2.7/ctypes/test/test_loading.py
new file mode 100644
index 0000000..26683d8
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_loading.py
@@ -0,0 +1,106 @@
+from ctypes import *
+import sys, unittest
+import os
+from ctypes.util import find_library
+from ctypes.test import is_resource_enabled
+
+libc_name = None
+if os.name == "nt":
+    libc_name = find_library("c")
+elif os.name == "ce":
+    libc_name = "coredll"
+elif sys.platform == "cygwin":
+    libc_name = "cygwin1.dll"
+else:
+    libc_name = find_library("c")
+
+if is_resource_enabled("printing"):
+    print "libc_name is", libc_name
+
+class LoaderTest(unittest.TestCase):
+
+    unknowndll = "xxrandomnamexx"
+
+    if libc_name is not None:
+        def test_load(self):
+            CDLL(libc_name)
+            CDLL(os.path.basename(libc_name))
+            self.assertRaises(OSError, CDLL, self.unknowndll)
+
+    if libc_name is not None and os.path.basename(libc_name) == "libc.so.6":
+        def test_load_version(self):
+            cdll.LoadLibrary("libc.so.6")
+            # linux uses version, libc 9 should not exist
+            self.assertRaises(OSError, cdll.LoadLibrary, "libc.so.9")
+            self.assertRaises(OSError, cdll.LoadLibrary, self.unknowndll)
+
+    def test_find(self):
+        for name in ("c", "m"):
+            lib = find_library(name)
+            if lib:
+                cdll.LoadLibrary(lib)
+                CDLL(lib)
+
+    if os.name in ("nt", "ce"):
+        def test_load_library(self):
+            self.assertFalse(libc_name is None)
+            if is_resource_enabled("printing"):
+                print find_library("kernel32")
+                print find_library("user32")
+
+            if os.name == "nt":
+                windll.kernel32.GetModuleHandleW
+                windll["kernel32"].GetModuleHandleW
+                windll.LoadLibrary("kernel32").GetModuleHandleW
+                WinDLL("kernel32").GetModuleHandleW
+            elif os.name == "ce":
+                windll.coredll.GetModuleHandleW
+                windll["coredll"].GetModuleHandleW
+                windll.LoadLibrary("coredll").GetModuleHandleW
+                WinDLL("coredll").GetModuleHandleW
+
+        def test_load_ordinal_functions(self):
+            import _ctypes_test
+            dll = WinDLL(_ctypes_test.__file__)
+            # We load the same function both via ordinal and name
+            func_ord = dll[2]
+            func_name = dll.GetString
+            # addressof gets the address where the function pointer is stored
+            a_ord = addressof(func_ord)
+            a_name = addressof(func_name)
+            f_ord_addr = c_void_p.from_address(a_ord).value
+            f_name_addr = c_void_p.from_address(a_name).value
+            self.assertEqual(hex(f_ord_addr), hex(f_name_addr))
+
+            self.assertRaises(AttributeError, dll.__getitem__, 1234)
+
+    if os.name == "nt":
+        def test_1703286_A(self):
+            from _ctypes import LoadLibrary, FreeLibrary
+            # On winXP 64-bit, advapi32 loads at an address that does
+            # NOT fit into a 32-bit integer.  FreeLibrary must be able
+            # to accept this address.
+
+            # These are tests for http://www.python.org/sf/1703286
+            handle = LoadLibrary("advapi32")
+            FreeLibrary(handle)
+
+        def test_1703286_B(self):
+            # Since on winXP 64-bit advapi32 loads like described
+            # above, the (arbitrarily selected) CloseEventLog function
+            # also has a high address.  'call_function' should accept
+            # addresses so large.
+            from _ctypes import call_function
+            advapi32 = windll.advapi32
+            # Calling CloseEventLog with a NULL argument should fail,
+            # but the call should not segfault or so.
+            self.assertEqual(0, advapi32.CloseEventLog(None))
+            windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p
+            windll.kernel32.GetProcAddress.restype = c_void_p
+            proc = windll.kernel32.GetProcAddress(advapi32._handle, "CloseEventLog")
+            self.assertTrue(proc)
+            # This is the real test: call the function via 'call_function'
+            self.assertEqual(0, call_function(proc, (None,)))
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_macholib.py b/lib/python2.7/ctypes/test/test_macholib.py
new file mode 100644
index 0000000..eda846d
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_macholib.py
@@ -0,0 +1,62 @@
+import os
+import sys
+import unittest
+
+# Bob Ippolito:
+"""
+Ok.. the code to find the filename for __getattr__ should look
+something like:
+
+import os
+from macholib.dyld import dyld_find
+
+def find_lib(name):
+     possible = ['lib'+name+'.dylib', name+'.dylib',
+     name+'.framework/'+name]
+     for dylib in possible:
+         try:
+             return os.path.realpath(dyld_find(dylib))
+         except ValueError:
+             pass
+     raise ValueError, "%s not found" % (name,)
+
+It'll have output like this:
+
+ >>> find_lib('pthread')
+'/usr/lib/libSystem.B.dylib'
+ >>> find_lib('z')
+'/usr/lib/libz.1.dylib'
+ >>> find_lib('IOKit')
+'/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit'
+
+-bob
+
+"""
+
+from ctypes.macholib.dyld import dyld_find
+
+def find_lib(name):
+    possible = ['lib'+name+'.dylib', name+'.dylib', name+'.framework/'+name]
+    for dylib in possible:
+        try:
+            return os.path.realpath(dyld_find(dylib))
+        except ValueError:
+            pass
+    raise ValueError("%s not found" % (name,))
+
+class MachOTest(unittest.TestCase):
+    if sys.platform == "darwin":
+        def test_find(self):
+
+            self.assertEqual(find_lib('pthread'),
+                                 '/usr/lib/libSystem.B.dylib')
+
+            result = find_lib('z')
+            self.assertTrue(result.startswith('/usr/lib/libz.1'))
+            self.assertTrue(result.endswith('.dylib'))
+
+            self.assertEqual(find_lib('IOKit'),
+                                 '/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit')
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_memfunctions.py b/lib/python2.7/ctypes/test/test_memfunctions.py
new file mode 100644
index 0000000..d072603
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_memfunctions.py
@@ -0,0 +1,79 @@
+import sys
+import unittest
+from ctypes import *
+
+class MemFunctionsTest(unittest.TestCase):
+##    def test_overflow(self):
+##        # string_at and wstring_at must use the Python calling
+##        # convention (which acquires the GIL and checks the Python
+##        # error flag).  Provoke an error and catch it; see also issue
+##        # #3554: <http://bugs.python.org/issue3554>
+##        self.assertRaises((OverflowError, MemoryError, SystemError),
+##                          lambda: wstring_at(u"foo", sys.maxint - 1))
+##        self.assertRaises((OverflowError, MemoryError, SystemError),
+##                          lambda: string_at("foo", sys.maxint - 1))
+
+    def test_memmove(self):
+        # large buffers apparently increase the chance that the memory
+        # is allocated in high address space.
+        a = create_string_buffer(1000000)
+        p = "Hello, World"
+        result = memmove(a, p, len(p))
+        self.assertEqual(a.value, "Hello, World")
+
+        self.assertEqual(string_at(result), "Hello, World")
+        self.assertEqual(string_at(result, 5), "Hello")
+        self.assertEqual(string_at(result, 16), "Hello, World\0\0\0\0")
+        self.assertEqual(string_at(result, 0), "")
+
+    def test_memset(self):
+        a = create_string_buffer(1000000)
+        result = memset(a, ord('x'), 16)
+        self.assertEqual(a.value, "xxxxxxxxxxxxxxxx")
+
+        self.assertEqual(string_at(result), "xxxxxxxxxxxxxxxx")
+        self.assertEqual(string_at(a), "xxxxxxxxxxxxxxxx")
+        self.assertEqual(string_at(a, 20), "xxxxxxxxxxxxxxxx\0\0\0\0")
+
+    def test_cast(self):
+        a = (c_ubyte * 32)(*map(ord, "abcdef"))
+        self.assertEqual(cast(a, c_char_p).value, "abcdef")
+        self.assertEqual(cast(a, POINTER(c_byte))[:7],
+                             [97, 98, 99, 100, 101, 102, 0])
+        self.assertEqual(cast(a, POINTER(c_byte))[:7:],
+                             [97, 98, 99, 100, 101, 102, 0])
+        self.assertEqual(cast(a, POINTER(c_byte))[6:-1:-1],
+                             [0, 102, 101, 100, 99, 98, 97])
+        self.assertEqual(cast(a, POINTER(c_byte))[:7:2],
+                             [97, 99, 101, 0])
+        self.assertEqual(cast(a, POINTER(c_byte))[:7:7],
+                             [97])
+
+    def test_string_at(self):
+        s = string_at("foo bar")
+        # XXX The following may be wrong, depending on how Python
+        # manages string instances
+        self.assertEqual(2, sys.getrefcount(s))
+        self.assertTrue(s, "foo bar")
+
+        self.assertEqual(string_at("foo bar", 8), "foo bar\0")
+        self.assertEqual(string_at("foo bar", 3), "foo")
+
+    try:
+        create_unicode_buffer
+    except NameError:
+        pass
+    else:
+        def test_wstring_at(self):
+            p = create_unicode_buffer("Hello, World")
+            a = create_unicode_buffer(1000000)
+            result = memmove(a, p, len(p) * sizeof(c_wchar))
+            self.assertEqual(a.value, "Hello, World")
+
+            self.assertEqual(wstring_at(a), "Hello, World")
+            self.assertEqual(wstring_at(a, 5), "Hello")
+            self.assertEqual(wstring_at(a, 16), "Hello, World\0\0\0\0")
+            self.assertEqual(wstring_at(a, 0), "")
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_numbers.py b/lib/python2.7/ctypes/test/test_numbers.py
new file mode 100644
index 0000000..7923906
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_numbers.py
@@ -0,0 +1,286 @@
+from ctypes import *
+import unittest
+import struct
+
+def valid_ranges(*types):
+    # given a sequence of numeric types, collect their _type_
+    # attribute, which is a single format character compatible with
+    # the struct module, use the struct module to calculate the
+    # minimum and maximum value allowed for this format.
+    # Returns a list of (min, max) values.
+    result = []
+    for t in types:
+        fmt = t._type_
+        size = struct.calcsize(fmt)
+        a = struct.unpack(fmt, ("\x00"*32)[:size])[0]
+        b = struct.unpack(fmt, ("\xFF"*32)[:size])[0]
+        c = struct.unpack(fmt, ("\x7F"+"\x00"*32)[:size])[0]
+        d = struct.unpack(fmt, ("\x80"+"\xFF"*32)[:size])[0]
+        result.append((min(a, b, c, d), max(a, b, c, d)))
+    return result
+
+ArgType = type(byref(c_int(0)))
+
+unsigned_types = [c_ubyte, c_ushort, c_uint, c_ulong]
+signed_types = [c_byte, c_short, c_int, c_long, c_longlong]
+
+bool_types = []
+
+float_types = [c_double, c_float]
+
+try:
+    c_ulonglong
+    c_longlong
+except NameError:
+    pass
+else:
+    unsigned_types.append(c_ulonglong)
+    signed_types.append(c_longlong)
+
+try:
+    c_bool
+except NameError:
+    pass
+else:
+    bool_types.append(c_bool)
+
+unsigned_ranges = valid_ranges(*unsigned_types)
+signed_ranges = valid_ranges(*signed_types)
+bool_values = [True, False, 0, 1, -1, 5000, 'test', [], [1]]
+
+################################################################
+
+class NumberTestCase(unittest.TestCase):
+
+    def test_default_init(self):
+        # default values are set to zero
+        for t in signed_types + unsigned_types + float_types:
+            self.assertEqual(t().value, 0)
+
+    def test_unsigned_values(self):
+        # the value given to the constructor is available
+        # as the 'value' attribute
+        for t, (l, h) in zip(unsigned_types, unsigned_ranges):
+            self.assertEqual(t(l).value, l)
+            self.assertEqual(t(h).value, h)
+
+    def test_signed_values(self):
+        # see above
+        for t, (l, h) in zip(signed_types, signed_ranges):
+            self.assertEqual(t(l).value, l)
+            self.assertEqual(t(h).value, h)
+
+    def test_bool_values(self):
+        from operator import truth
+        for t, v in zip(bool_types, bool_values):
+            self.assertEqual(t(v).value, truth(v))
+
+    def test_typeerror(self):
+        # Only numbers are allowed in the contructor,
+        # otherwise TypeError is raised
+        for t in signed_types + unsigned_types + float_types:
+            self.assertRaises(TypeError, t, "")
+            self.assertRaises(TypeError, t, None)
+
+##    def test_valid_ranges(self):
+##        # invalid values of the correct type
+##        # raise ValueError (not OverflowError)
+##        for t, (l, h) in zip(unsigned_types, unsigned_ranges):
+##            self.assertRaises(ValueError, t, l-1)
+##            self.assertRaises(ValueError, t, h+1)
+
+    def test_from_param(self):
+        # the from_param class method attribute always
+        # returns PyCArgObject instances
+        for t in signed_types + unsigned_types + float_types:
+            self.assertEqual(ArgType, type(t.from_param(0)))
+
+    def test_byref(self):
+        # calling byref returns also a PyCArgObject instance
+        for t in signed_types + unsigned_types + float_types + bool_types:
+            parm = byref(t())
+            self.assertEqual(ArgType, type(parm))
+
+
+    def test_floats(self):
+        # c_float and c_double can be created from
+        # Python int, long and float
+        class FloatLike(object):
+            def __float__(self):
+                return 2.0
+        f = FloatLike()
+        for t in float_types:
+            self.assertEqual(t(2.0).value, 2.0)
+            self.assertEqual(t(2).value, 2.0)
+            self.assertEqual(t(2L).value, 2.0)
+            self.assertEqual(t(f).value, 2.0)
+
+    def test_integers(self):
+        class FloatLike(object):
+            def __float__(self):
+                return 2.0
+        f = FloatLike()
+        class IntLike(object):
+            def __int__(self):
+                return 2
+        i = IntLike()
+        # integers cannot be constructed from floats,
+        # but from integer-like objects
+        for t in signed_types + unsigned_types:
+            self.assertRaises(TypeError, t, 3.14)
+            self.assertRaises(TypeError, t, f)
+            self.assertEqual(t(i).value, 2)
+
+    def test_sizes(self):
+        for t in signed_types + unsigned_types + float_types + bool_types:
+            try:
+                size = struct.calcsize(t._type_)
+            except struct.error:
+                continue
+            # sizeof of the type...
+            self.assertEqual(sizeof(t), size)
+            # and sizeof of an instance
+            self.assertEqual(sizeof(t()), size)
+
+    def test_alignments(self):
+        for t in signed_types + unsigned_types + float_types:
+            code = t._type_ # the typecode
+            align = struct.calcsize("c%c" % code) - struct.calcsize(code)
+
+            # alignment of the type...
+            self.assertEqual((code, alignment(t)),
+                                 (code, align))
+            # and alignment of an instance
+            self.assertEqual((code, alignment(t())),
+                                 (code, align))
+
+    def test_int_from_address(self):
+        from array import array
+        for t in signed_types + unsigned_types:
+            # the array module doesn't support all format codes
+            # (no 'q' or 'Q')
+            try:
+                array(t._type_)
+            except ValueError:
+                continue
+            a = array(t._type_, [100])
+
+            # v now is an integer at an 'external' memory location
+            v = t.from_address(a.buffer_info()[0])
+            self.assertEqual(v.value, a[0])
+            self.assertEqual(type(v), t)
+
+            # changing the value at the memory location changes v's value also
+            a[0] = 42
+            self.assertEqual(v.value, a[0])
+
+
+    def test_float_from_address(self):
+        from array import array
+        for t in float_types:
+            a = array(t._type_, [3.14])
+            v = t.from_address(a.buffer_info()[0])
+            self.assertEqual(v.value, a[0])
+            self.assertTrue(type(v) is t)
+            a[0] = 2.3456e17
+            self.assertEqual(v.value, a[0])
+            self.assertTrue(type(v) is t)
+
+    def test_char_from_address(self):
+        from ctypes import c_char
+        from array import array
+
+        a = array('c', 'x')
+        v = c_char.from_address(a.buffer_info()[0])
+        self.assertEqual(v.value, a[0])
+        self.assertTrue(type(v) is c_char)
+
+        a[0] = '?'
+        self.assertEqual(v.value, a[0])
+
+    # array does not support c_bool / 't'
+    # def test_bool_from_address(self):
+    #     from ctypes import c_bool
+    #     from array import array
+    #     a = array(c_bool._type_, [True])
+    #     v = t.from_address(a.buffer_info()[0])
+    #     self.assertEqual(v.value, a[0])
+    #     self.assertEqual(type(v) is t)
+    #     a[0] = False
+    #     self.assertEqual(v.value, a[0])
+    #     self.assertEqual(type(v) is t)
+
+    def test_init(self):
+        # c_int() can be initialized from Python's int, and c_int.
+        # Not from c_long or so, which seems strange, abd should
+        # probably be changed:
+        self.assertRaises(TypeError, c_int, c_long(42))
+
+    def test_float_overflow(self):
+        import sys
+        big_int = int(sys.float_info.max) * 2
+        for t in float_types + [c_longdouble]:
+            self.assertRaises(OverflowError, t, big_int)
+            if (hasattr(t, "__ctype_be__")):
+                self.assertRaises(OverflowError, t.__ctype_be__, big_int)
+            if (hasattr(t, "__ctype_le__")):
+                self.assertRaises(OverflowError, t.__ctype_le__, big_int)
+
+##    def test_perf(self):
+##        check_perf()
+
+from ctypes import _SimpleCData
+class c_int_S(_SimpleCData):
+    _type_ = "i"
+    __slots__ = []
+
+def run_test(rep, msg, func, arg=None):
+##    items = [None] * rep
+    items = range(rep)
+    from time import clock
+    if arg is not None:
+        start = clock()
+        for i in items:
+            func(arg); func(arg); func(arg); func(arg); func(arg)
+        stop = clock()
+    else:
+        start = clock()
+        for i in items:
+            func(); func(); func(); func(); func()
+        stop = clock()
+    print "%15s: %.2f us" % (msg, ((stop-start)*1e6/5/rep))
+
+def check_perf():
+    # Construct 5 objects
+    from ctypes import c_int
+
+    REP = 200000
+
+    run_test(REP, "int()", int)
+    run_test(REP, "int(999)", int)
+    run_test(REP, "c_int()", c_int)
+    run_test(REP, "c_int(999)", c_int)
+    run_test(REP, "c_int_S()", c_int_S)
+    run_test(REP, "c_int_S(999)", c_int_S)
+
+# Python 2.3 -OO, win2k, P4 700 MHz:
+#
+#          int(): 0.87 us
+#       int(999): 0.87 us
+#        c_int(): 3.35 us
+#     c_int(999): 3.34 us
+#      c_int_S(): 3.23 us
+#   c_int_S(999): 3.24 us
+
+# Python 2.2 -OO, win2k, P4 700 MHz:
+#
+#          int(): 0.89 us
+#       int(999): 0.89 us
+#        c_int(): 9.99 us
+#     c_int(999): 10.02 us
+#      c_int_S(): 9.87 us
+#   c_int_S(999): 9.85 us
+
+if __name__ == '__main__':
+##    check_perf()
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_objects.py b/lib/python2.7/ctypes/test/test_objects.py
new file mode 100644
index 0000000..4d921d2
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_objects.py
@@ -0,0 +1,70 @@
+r'''
+This tests the '_objects' attribute of ctypes instances.  '_objects'
+holds references to objects that must be kept alive as long as the
+ctypes instance, to make sure that the memory buffer is valid.
+
+WARNING: The '_objects' attribute is exposed ONLY for debugging ctypes itself,
+it MUST NEVER BE MODIFIED!
+
+'_objects' is initialized to a dictionary on first use, before that it
+is None.
+
+Here is an array of string pointers:
+
+>>> from ctypes import *
+>>> array = (c_char_p * 5)()
+>>> print array._objects
+None
+>>>
+
+The memory block stores pointers to strings, and the strings itself
+assigned from Python must be kept.
+
+>>> array[4] = 'foo bar'
+>>> array._objects
+{'4': 'foo bar'}
+>>> array[4]
+'foo bar'
+>>>
+
+It gets more complicated when the ctypes instance itself is contained
+in a 'base' object.
+
+>>> class X(Structure):
+...     _fields_ = [("x", c_int), ("y", c_int), ("array", c_char_p * 5)]
+...
+>>> x = X()
+>>> print x._objects
+None
+>>>
+
+The'array' attribute of the 'x' object shares part of the memory buffer
+of 'x' ('_b_base_' is either None, or the root object owning the memory block):
+
+>>> print x.array._b_base_ # doctest: +ELLIPSIS
+<ctypes.test.test_objects.X object at 0x...>
+>>>
+
+>>> x.array[0] = 'spam spam spam'
+>>> x._objects
+{'0:2': 'spam spam spam'}
+>>> x.array._b_base_._objects
+{'0:2': 'spam spam spam'}
+>>>
+
+'''
+
+import unittest, doctest, sys
+
+import ctypes.test.test_objects
+
+class TestCase(unittest.TestCase):
+    if sys.hexversion > 0x02040000:
+        # Python 2.3 has no ELLIPSIS flag, so we don't test with this
+        # version:
+        def test(self):
+            doctest.testmod(ctypes.test.test_objects)
+
+if __name__ == '__main__':
+    if sys.hexversion > 0x02040000:
+        doctest.testmod(ctypes.test.test_objects)
diff --git a/lib/python2.7/ctypes/test/test_parameters.py b/lib/python2.7/ctypes/test/test_parameters.py
new file mode 100644
index 0000000..82704d5
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_parameters.py
@@ -0,0 +1,188 @@
+import unittest, sys
+
+class SimpleTypesTestCase(unittest.TestCase):
+
+    def setUp(self):
+        import ctypes
+        try:
+            from _ctypes import set_conversion_mode
+        except ImportError:
+            pass
+        else:
+            self.prev_conv_mode = set_conversion_mode("ascii", "strict")
+
+    def tearDown(self):
+        try:
+            from _ctypes import set_conversion_mode
+        except ImportError:
+            pass
+        else:
+            set_conversion_mode(*self.prev_conv_mode)
+
+
+    def test_subclasses(self):
+        from ctypes import c_void_p, c_char_p
+        # ctypes 0.9.5 and before did overwrite from_param in SimpleType_new
+        class CVOIDP(c_void_p):
+            def from_param(cls, value):
+                return value * 2
+            from_param = classmethod(from_param)
+
+        class CCHARP(c_char_p):
+            def from_param(cls, value):
+                return value * 4
+            from_param = classmethod(from_param)
+
+        self.assertEqual(CVOIDP.from_param("abc"), "abcabc")
+        self.assertEqual(CCHARP.from_param("abc"), "abcabcabcabc")
+
+        try:
+            from ctypes import c_wchar_p
+        except ImportError:
+            return
+
+        class CWCHARP(c_wchar_p):
+            def from_param(cls, value):
+                return value * 3
+            from_param = classmethod(from_param)
+
+        self.assertEqual(CWCHARP.from_param("abc"), "abcabcabc")
+
+    # XXX Replace by c_char_p tests
+    def test_cstrings(self):
+        from ctypes import c_char_p, byref
+
+        # c_char_p.from_param on a Python String packs the string
+        # into a cparam object
+        s = "123"
+        self.assertTrue(c_char_p.from_param(s)._obj is s)
+
+        # new in 0.9.1: convert (encode) unicode to ascii
+        self.assertEqual(c_char_p.from_param(u"123")._obj, "123")
+        self.assertRaises(UnicodeEncodeError, c_char_p.from_param, u"123\377")
+
+        self.assertRaises(TypeError, c_char_p.from_param, 42)
+
+        # calling c_char_p.from_param with a c_char_p instance
+        # returns the argument itself:
+        a = c_char_p("123")
+        self.assertTrue(c_char_p.from_param(a) is a)
+
+    def test_cw_strings(self):
+        from ctypes import byref
+        try:
+            from ctypes import c_wchar_p
+        except ImportError:
+##            print "(No c_wchar_p)"
+            return
+        s = u"123"
+        if sys.platform == "win32":
+            self.assertTrue(c_wchar_p.from_param(s)._obj is s)
+            self.assertRaises(TypeError, c_wchar_p.from_param, 42)
+
+            # new in 0.9.1: convert (decode) ascii to unicode
+            self.assertEqual(c_wchar_p.from_param("123")._obj, u"123")
+        self.assertRaises(UnicodeDecodeError, c_wchar_p.from_param, "123\377")
+
+        pa = c_wchar_p.from_param(c_wchar_p(u"123"))
+        self.assertEqual(type(pa), c_wchar_p)
+
+    def test_int_pointers(self):
+        from ctypes import c_short, c_uint, c_int, c_long, POINTER, pointer
+        LPINT = POINTER(c_int)
+
+##        p = pointer(c_int(42))
+##        x = LPINT.from_param(p)
+        x = LPINT.from_param(pointer(c_int(42)))
+        self.assertEqual(x.contents.value, 42)
+        self.assertEqual(LPINT(c_int(42)).contents.value, 42)
+
+        self.assertEqual(LPINT.from_param(None), None)
+
+        if c_int != c_long:
+            self.assertRaises(TypeError, LPINT.from_param, pointer(c_long(42)))
+        self.assertRaises(TypeError, LPINT.from_param, pointer(c_uint(42)))
+        self.assertRaises(TypeError, LPINT.from_param, pointer(c_short(42)))
+
+    def test_byref_pointer(self):
+        # The from_param class method of POINTER(typ) classes accepts what is
+        # returned by byref(obj), it type(obj) == typ
+        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
+        LPINT = POINTER(c_int)
+
+        LPINT.from_param(byref(c_int(42)))
+
+        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
+        if c_int != c_long:
+            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
+        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
+
+    def test_byref_pointerpointer(self):
+        # See above
+        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
+
+        LPLPINT = POINTER(POINTER(c_int))
+        LPLPINT.from_param(byref(pointer(c_int(42))))
+
+        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
+        if c_int != c_long:
+            self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
+        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
+
+    def test_array_pointers(self):
+        from ctypes import c_short, c_uint, c_int, c_long, POINTER
+        INTARRAY = c_int * 3
+        ia = INTARRAY()
+        self.assertEqual(len(ia), 3)
+        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])
+
+        # Pointers are only compatible with arrays containing items of
+        # the same type!
+        LPINT = POINTER(c_int)
+        LPINT.from_param((c_int*3)())
+        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
+        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
+        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)
+
+##    def test_performance(self):
+##        check_perf()
+
+    def test_noctypes_argtype(self):
+        import _ctypes_test
+        from ctypes import CDLL, c_void_p, ArgumentError
+
+        func = CDLL(_ctypes_test.__file__)._testfunc_p_p
+        func.restype = c_void_p
+        # TypeError: has no from_param method
+        self.assertRaises(TypeError, setattr, func, "argtypes", (object,))
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                return None
+
+        func.argtypes = (Adapter(),)
+        self.assertEqual(func(None), None)
+        self.assertEqual(func(object()), None)
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                return obj
+
+        func.argtypes = (Adapter(),)
+        # don't know how to convert parameter 1
+        self.assertRaises(ArgumentError, func, object())
+        self.assertEqual(func(c_void_p(42)), 42)
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                raise ValueError(obj)
+
+        func.argtypes = (Adapter(),)
+        # ArgumentError: argument 1: ValueError: 99
+        self.assertRaises(ArgumentError, func, 99)
+
+
+################################################################
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_pep3118.py b/lib/python2.7/ctypes/test/test_pep3118.py
new file mode 100644
index 0000000..976473c
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_pep3118.py
@@ -0,0 +1,196 @@
+import unittest
+from ctypes import *
+import re, sys
+
+if sys.byteorder == "little":
+    THIS_ENDIAN = "<"
+    OTHER_ENDIAN = ">"
+else:
+    THIS_ENDIAN = ">"
+    OTHER_ENDIAN = "<"
+
+def normalize(format):
+    # Remove current endian specifier and white space from a format
+    # string
+    if format is None:
+        return ""
+    format = format.replace(OTHER_ENDIAN, THIS_ENDIAN)
+    return re.sub(r"\s", "", format)
+
+class Test(unittest.TestCase):
+
+    def test_native_types(self):
+        for tp, fmt, shape, itemtp in native_types:
+            ob = tp()
+            v = memoryview(ob)
+            try:
+                self.assertEqual(normalize(v.format), normalize(fmt))
+                if shape is not None:
+                    self.assertEqual(len(v), shape[0])
+                else:
+                    self.assertEqual(len(v) * sizeof(itemtp), sizeof(ob))
+                self.assertEqual(v.itemsize, sizeof(itemtp))
+                self.assertEqual(v.shape, shape)
+                # ctypes object always have a non-strided memory block
+                self.assertEqual(v.strides, None)
+                # they are always read/write
+                self.assertFalse(v.readonly)
+
+                if v.shape:
+                    n = 1
+                    for dim in v.shape:
+                        n = n * dim
+                    self.assertEqual(n * v.itemsize, len(v.tobytes()))
+            except:
+                # so that we can see the failing type
+                print(tp)
+                raise
+
+    def test_endian_types(self):
+        for tp, fmt, shape, itemtp in endian_types:
+            ob = tp()
+            v = memoryview(ob)
+            try:
+                self.assertEqual(v.format, fmt)
+                if shape is not None:
+                    self.assertEqual(len(v), shape[0])
+                else:
+                    self.assertEqual(len(v) * sizeof(itemtp), sizeof(ob))
+                self.assertEqual(v.itemsize, sizeof(itemtp))
+                self.assertEqual(v.shape, shape)
+                # ctypes object always have a non-strided memory block
+                self.assertEqual(v.strides, None)
+                # they are always read/write
+                self.assertFalse(v.readonly)
+
+                if v.shape:
+                    n = 1
+                    for dim in v.shape:
+                        n = n * dim
+                    self.assertEqual(n, len(v))
+            except:
+                # so that we can see the failing type
+                print(tp)
+                raise
+
+# define some structure classes
+
+class Point(Structure):
+    _fields_ = [("x", c_long), ("y", c_long)]
+
+class PackedPoint(Structure):
+    _pack_ = 2
+    _fields_ = [("x", c_long), ("y", c_long)]
+
+class Point2(Structure):
+    pass
+Point2._fields_ = [("x", c_long), ("y", c_long)]
+
+class EmptyStruct(Structure):
+    _fields_ = []
+
+class aUnion(Union):
+    _fields_ = [("a", c_int)]
+
+class Incomplete(Structure):
+    pass
+
+class Complete(Structure):
+    pass
+PComplete = POINTER(Complete)
+Complete._fields_ = [("a", c_long)]
+
+################################################################
+#
+# This table contains format strings as they look on little endian
+# machines.  The test replaces '<' with '>' on big endian machines.
+#
+native_types = [
+    # type                      format                  shape           calc itemsize
+
+    ## simple types
+
+    (c_char,                    "<c",                   None,           c_char),
+    (c_byte,                    "<b",                   None,           c_byte),
+    (c_ubyte,                   "<B",                   None,           c_ubyte),
+    (c_short,                   "<h",                   None,           c_short),
+    (c_ushort,                  "<H",                   None,           c_ushort),
+
+    # c_int and c_uint may be aliases to c_long
+    #(c_int,                     "<i",                   None,           c_int),
+    #(c_uint,                    "<I",                   None,           c_uint),
+
+    (c_long,                    "<l",                   None,           c_long),
+    (c_ulong,                   "<L",                   None,           c_ulong),
+
+    # c_longlong and c_ulonglong are aliases on 64-bit platforms
+    #(c_longlong,                "<q",                   None,           c_longlong),
+    #(c_ulonglong,               "<Q",                   None,           c_ulonglong),
+
+    (c_float,                   "<f",                   None,           c_float),
+    (c_double,                  "<d",                   None,           c_double),
+    # c_longdouble may be an alias to c_double
+
+    (c_bool,                    "<?",                   None,           c_bool),
+    (py_object,                 "<O",                   None,           py_object),
+
+    ## pointers
+
+    (POINTER(c_byte),           "&<b",                  None,           POINTER(c_byte)),
+    (POINTER(POINTER(c_long)),  "&&<l",                 None,           POINTER(POINTER(c_long))),
+
+    ## arrays and pointers
+
+    (c_double * 4,              "(4)<d",                (4,),           c_double),
+    (c_float * 4 * 3 * 2,       "(2,3,4)<f",            (2,3,4),        c_float),
+    (POINTER(c_short) * 2,      "(2)&<h",               (2,),           POINTER(c_short)),
+    (POINTER(c_short) * 2 * 3,  "(3,2)&<h",             (3,2,),         POINTER(c_short)),
+    (POINTER(c_short * 2),      "&(2)<h",               None,           POINTER(c_short)),
+
+    ## structures and unions
+
+    (Point,                     "T{<l:x:<l:y:}",        None,           Point),
+    # packed structures do not implement the pep
+    (PackedPoint,               "B",                    None,           PackedPoint),
+    (Point2,                    "T{<l:x:<l:y:}",        None,           Point2),
+    (EmptyStruct,               "T{}",                  None,           EmptyStruct),
+    # the pep does't support unions
+    (aUnion,                    "B",                    None,           aUnion),
+
+    ## pointer to incomplete structure
+    (Incomplete,                "B",                    None,           Incomplete),
+    (POINTER(Incomplete),       "&B",                   None,           POINTER(Incomplete)),
+
+    # 'Complete' is a structure that starts incomplete, but is completed after the
+    # pointer type to it has been created.
+    (Complete,                  "T{<l:a:}",             None,           Complete),
+    # Unfortunately the pointer format string is not fixed...
+    (POINTER(Complete),         "&B",                   None,           POINTER(Complete)),
+
+    ## other
+
+    # function signatures are not implemented
+    (CFUNCTYPE(None),           "X{}",                  None,           CFUNCTYPE(None)),
+
+    ]
+
+class BEPoint(BigEndianStructure):
+    _fields_ = [("x", c_long), ("y", c_long)]
+
+class LEPoint(LittleEndianStructure):
+    _fields_ = [("x", c_long), ("y", c_long)]
+
+################################################################
+#
+# This table contains format strings as they really look, on both big
+# and little endian machines.
+#
+endian_types = [
+    (BEPoint,                   "T{>l:x:>l:y:}",        None,           BEPoint),
+    (LEPoint,                   "T{<l:x:<l:y:}",        None,           LEPoint),
+    (POINTER(BEPoint),          "&T{>l:x:>l:y:}",       None,           POINTER(BEPoint)),
+    (POINTER(LEPoint),          "&T{<l:x:<l:y:}",       None,           POINTER(LEPoint)),
+    ]
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_pickling.py b/lib/python2.7/ctypes/test/test_pickling.py
new file mode 100644
index 0000000..136cbe9
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_pickling.py
@@ -0,0 +1,83 @@
+import unittest
+import pickle
+from ctypes import *
+import _ctypes_test
+dll = CDLL(_ctypes_test.__file__)
+
+class X(Structure):
+    _fields_ = [("a", c_int), ("b", c_double)]
+    init_called = 0
+    def __init__(self, *args, **kw):
+        X.init_called += 1
+        self.x = 42
+
+class Y(X):
+    _fields_ = [("str", c_char_p)]
+
+class PickleTest(unittest.TestCase):
+    def dumps(self, item):
+        return pickle.dumps(item)
+
+    def loads(self, item):
+        return pickle.loads(item)
+
+    def test_simple(self):
+        for src in [
+            c_int(42),
+            c_double(3.14),
+            ]:
+            dst = self.loads(self.dumps(src))
+            self.assertEqual(src.__dict__, dst.__dict__)
+            self.assertEqual(memoryview(src).tobytes(),
+                                 memoryview(dst).tobytes())
+
+    def test_struct(self):
+        X.init_called = 0
+
+        x = X()
+        x.a = 42
+        self.assertEqual(X.init_called, 1)
+
+        y = self.loads(self.dumps(x))
+
+        # loads must NOT call __init__
+        self.assertEqual(X.init_called, 1)
+
+        # ctypes instances are identical when the instance __dict__
+        # and the memory buffer are identical
+        self.assertEqual(y.__dict__, x.__dict__)
+        self.assertEqual(memoryview(y).tobytes(),
+                             memoryview(x).tobytes())
+
+    def test_unpickable(self):
+        # ctypes objects that are pointers or contain pointers are
+        # unpickable.
+        self.assertRaises(ValueError, lambda: self.dumps(Y()))
+
+        prototype = CFUNCTYPE(c_int)
+
+        for item in [
+            c_char_p(),
+            c_wchar_p(),
+            c_void_p(),
+            pointer(c_int(42)),
+            dll._testfunc_p_p,
+            prototype(lambda: 42),
+            ]:
+            self.assertRaises(ValueError, lambda: self.dumps(item))
+
+    def test_wchar(self):
+        pickle.dumps(c_char("x"))
+        # Issue 5049
+        pickle.dumps(c_wchar(u"x"))
+
+class PickleTest_1(PickleTest):
+    def dumps(self, item):
+        return pickle.dumps(item, 1)
+
+class PickleTest_2(PickleTest):
+    def dumps(self, item):
+        return pickle.dumps(item, 2)
+
+if __name__ == "__main__":
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_pointers.py b/lib/python2.7/ctypes/test/test_pointers.py
new file mode 100644
index 0000000..92b8ce6
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_pointers.py
@@ -0,0 +1,192 @@
+import unittest, sys
+
+from ctypes import *
+import _ctypes_test
+
+ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
+                 c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
+python_types = [int, int, int, int, int, long,
+                int, long, long, long, float, float]
+
+class PointersTestCase(unittest.TestCase):
+
+    def test_pointer_crash(self):
+
+        class A(POINTER(c_ulong)):
+            pass
+
+        POINTER(c_ulong)(c_ulong(22))
+        # Pointer can't set contents: has no _type_
+        self.assertRaises(TypeError, A, c_ulong(33))
+
+    def test_pass_pointers(self):
+        dll = CDLL(_ctypes_test.__file__)
+        func = dll._testfunc_p_p
+        func.restype = c_long
+
+        i = c_int(12345678)
+##        func.argtypes = (POINTER(c_int),)
+        address = func(byref(i))
+        self.assertEqual(c_int.from_address(address).value, 12345678)
+
+        func.restype = POINTER(c_int)
+        res = func(pointer(i))
+        self.assertEqual(res.contents.value, 12345678)
+        self.assertEqual(res[0], 12345678)
+
+    def test_change_pointers(self):
+        dll = CDLL(_ctypes_test.__file__)
+        func = dll._testfunc_p_p
+
+        i = c_int(87654)
+        func.restype = POINTER(c_int)
+        func.argtypes = (POINTER(c_int),)
+
+        res = func(pointer(i))
+        self.assertEqual(res[0], 87654)
+        self.assertEqual(res.contents.value, 87654)
+
+        # C code: *res = 54345
+        res[0] = 54345
+        self.assertEqual(i.value, 54345)
+
+        # C code:
+        #   int x = 12321;
+        #   res = &x
+        res.contents = c_int(12321)
+        self.assertEqual(i.value, 54345)
+
+    def test_callbacks_with_pointers(self):
+        # a function type receiving a pointer
+        PROTOTYPE = CFUNCTYPE(c_int, POINTER(c_int))
+
+        self.result = []
+
+        def func(arg):
+            for i in range(10):
+##                print arg[i],
+                self.result.append(arg[i])
+##            print
+            return 0
+        callback = PROTOTYPE(func)
+
+        dll = CDLL(_ctypes_test.__file__)
+        # This function expects a function pointer,
+        # and calls this with an integer pointer as parameter.
+        # The int pointer points to a table containing the numbers 1..10
+        doit = dll._testfunc_callback_with_pointer
+
+##        i = c_int(42)
+##        callback(byref(i))
+##        self.assertTrue(i.value == 84)
+
+        doit(callback)
+##        print self.result
+        doit(callback)
+##        print self.result
+
+    def test_basics(self):
+        from operator import delitem
+        for ct, pt in zip(ctype_types, python_types):
+            i = ct(42)
+            p = pointer(i)
+##            print type(p.contents), ct
+            self.assertTrue(type(p.contents) is ct)
+            # p.contents is the same as p[0]
+##            print p.contents
+##            self.assertTrue(p.contents == 42)
+##            self.assertTrue(p[0] == 42)
+
+            self.assertRaises(TypeError, delitem, p, 0)
+
+    def test_from_address(self):
+        from array import array
+        a = array('i', [100, 200, 300, 400, 500])
+        addr = a.buffer_info()[0]
+
+        p = POINTER(POINTER(c_int))
+##        print dir(p)
+##        print p.from_address
+##        print p.from_address(addr)[0][0]
+
+    def test_other(self):
+        class Table(Structure):
+            _fields_ = [("a", c_int),
+                        ("b", c_int),
+                        ("c", c_int)]
+
+        pt = pointer(Table(1, 2, 3))
+
+        self.assertEqual(pt.contents.a, 1)
+        self.assertEqual(pt.contents.b, 2)
+        self.assertEqual(pt.contents.c, 3)
+
+        pt.contents.c = 33
+
+        from ctypes import _pointer_type_cache
+        del _pointer_type_cache[Table]
+
+    def test_basic(self):
+        p = pointer(c_int(42))
+        # Although a pointer can be indexed, it ha no length
+        self.assertRaises(TypeError, len, p)
+        self.assertEqual(p[0], 42)
+        self.assertEqual(p.contents.value, 42)
+
+    def test_charpp(self):
+        """Test that a character pointer-to-pointer is correctly passed"""
+        dll = CDLL(_ctypes_test.__file__)
+        func = dll._testfunc_c_p_p
+        func.restype = c_char_p
+        argv = (c_char_p * 2)()
+        argc = c_int( 2 )
+        argv[0] = 'hello'
+        argv[1] = 'world'
+        result = func( byref(argc), argv )
+        assert result == 'world', result
+
+    def test_bug_1467852(self):
+        # http://sourceforge.net/tracker/?func=detail&atid=532154&aid=1467852&group_id=71702
+        x = c_int(5)
+        dummy = []
+        for i in range(32000):
+            dummy.append(c_int(i))
+        y = c_int(6)
+        p = pointer(x)
+        pp = pointer(p)
+        q = pointer(y)
+        pp[0] = q         # <==
+        self.assertEqual(p[0], 6)
+    def test_c_void_p(self):
+        # http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=105470
+        if sizeof(c_void_p) == 4:
+            self.assertEqual(c_void_p(0xFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+            self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+        elif sizeof(c_void_p) == 8:
+            self.assertEqual(c_void_p(0xFFFFFFFFL).value,
+                                 0xFFFFFFFFL)
+            self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+            self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+
+        self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
+        self.assertRaises(TypeError, c_void_p, object()) # nor other objects
+
+    def test_pointers_bool(self):
+        # NULL pointers have a boolean False value, non-NULL pointers True.
+        self.assertEqual(bool(POINTER(c_int)()), False)
+        self.assertEqual(bool(pointer(c_int())), True)
+
+        self.assertEqual(bool(CFUNCTYPE(None)(0)), False)
+        self.assertEqual(bool(CFUNCTYPE(None)(42)), True)
+
+        # COM methods are boolean True:
+        if sys.platform == "win32":
+            mth = WINFUNCTYPE(None)(42, "name", (), None)
+            self.assertEqual(bool(mth), True)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_prototypes.py b/lib/python2.7/ctypes/test/test_prototypes.py
new file mode 100644
index 0000000..09ba655
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_prototypes.py
@@ -0,0 +1,221 @@
+from ctypes import *
+import unittest
+
+# IMPORTANT INFO:
+#
+# Consider this call:
+#    func.restype = c_char_p
+#    func(c_char_p("123"))
+# It returns
+#    "123"
+#
+# WHY IS THIS SO?
+#
+# argument tuple (c_char_p("123"), ) is destroyed after the function
+# func is called, but NOT before the result is actually built.
+#
+# If the arglist would be destroyed BEFORE the result has been built,
+# the c_char_p("123") object would already have a zero refcount,
+# and the pointer passed to (and returned by) the function would
+# probably point to deallocated space.
+#
+# In this case, there would have to be an additional reference to the argument...
+
+import _ctypes_test
+testdll = CDLL(_ctypes_test.__file__)
+
+# Return machine address `a` as a (possibly long) non-negative integer.
+# Starting with Python 2.5, id(anything) is always non-negative, and
+# the ctypes addressof() inherits that via PyLong_FromVoidPtr().
+def positive_address(a):
+    if a >= 0:
+        return a
+    # View the bits in `a` as unsigned instead.
+    import struct
+    num_bits = struct.calcsize("P") * 8 # num bits in native machine address
+    a += 1L << num_bits
+    assert a >= 0
+    return a
+
+def c_wbuffer(init):
+    n = len(init) + 1
+    return (c_wchar * n)(*init)
+
+class CharPointersTestCase(unittest.TestCase):
+
+    def setUp(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_long
+        func.argtypes = None
+
+    def test_paramflags(self):
+        # function returns c_void_p result,
+        # and has a required parameter named 'input'
+        prototype = CFUNCTYPE(c_void_p, c_void_p)
+        func = prototype(("_testfunc_p_p", testdll),
+                         ((1, "input"),))
+
+        try:
+            func()
+        except TypeError, details:
+            self.assertEqual(str(details), "required argument 'input' missing")
+        else:
+            self.fail("TypeError not raised")
+
+        self.assertEqual(func(None), None)
+        self.assertEqual(func(input=None), None)
+
+
+    def test_int_pointer_arg(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_long
+        self.assertEqual(0, func(0))
+
+        ci = c_int(0)
+
+        func.argtypes = POINTER(c_int),
+        self.assertEqual(positive_address(addressof(ci)),
+                             positive_address(func(byref(ci))))
+
+        func.argtypes = c_char_p,
+        self.assertRaises(ArgumentError, func, byref(ci))
+
+        func.argtypes = POINTER(c_short),
+        self.assertRaises(ArgumentError, func, byref(ci))
+
+        func.argtypes = POINTER(c_double),
+        self.assertRaises(ArgumentError, func, byref(ci))
+
+    def test_POINTER_c_char_arg(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_char_p
+        func.argtypes = POINTER(c_char),
+
+        self.assertEqual(None, func(None))
+        self.assertEqual("123", func("123"))
+        self.assertEqual(None, func(c_char_p(None)))
+        self.assertEqual("123", func(c_char_p("123")))
+
+        self.assertEqual("123", func(c_buffer("123")))
+        ca = c_char("a")
+        self.assertEqual("a", func(pointer(ca))[0])
+        self.assertEqual("a", func(byref(ca))[0])
+
+    def test_c_char_p_arg(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_char_p
+        func.argtypes = c_char_p,
+
+        self.assertEqual(None, func(None))
+        self.assertEqual("123", func("123"))
+        self.assertEqual(None, func(c_char_p(None)))
+        self.assertEqual("123", func(c_char_p("123")))
+
+        self.assertEqual("123", func(c_buffer("123")))
+        ca = c_char("a")
+        self.assertEqual("a", func(pointer(ca))[0])
+        self.assertEqual("a", func(byref(ca))[0])
+
+    def test_c_void_p_arg(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_char_p
+        func.argtypes = c_void_p,
+
+        self.assertEqual(None, func(None))
+        self.assertEqual("123", func("123"))
+        self.assertEqual("123", func(c_char_p("123")))
+        self.assertEqual(None, func(c_char_p(None)))
+
+        self.assertEqual("123", func(c_buffer("123")))
+        ca = c_char("a")
+        self.assertEqual("a", func(pointer(ca))[0])
+        self.assertEqual("a", func(byref(ca))[0])
+
+        func(byref(c_int()))
+        func(pointer(c_int()))
+        func((c_int * 3)())
+
+        try:
+            func.restype = c_wchar_p
+        except NameError:
+            pass
+        else:
+            self.assertEqual(None, func(c_wchar_p(None)))
+            self.assertEqual(u"123", func(c_wchar_p(u"123")))
+
+    def test_instance(self):
+        func = testdll._testfunc_p_p
+        func.restype = c_void_p
+
+        class X:
+            _as_parameter_ = None
+
+        func.argtypes = c_void_p,
+        self.assertEqual(None, func(X()))
+
+        func.argtypes = None
+        self.assertEqual(None, func(X()))
+
+try:
+    c_wchar
+except NameError:
+    pass
+else:
+    class WCharPointersTestCase(unittest.TestCase):
+
+        def setUp(self):
+            func = testdll._testfunc_p_p
+            func.restype = c_int
+            func.argtypes = None
+
+
+        def test_POINTER_c_wchar_arg(self):
+            func = testdll._testfunc_p_p
+            func.restype = c_wchar_p
+            func.argtypes = POINTER(c_wchar),
+
+            self.assertEqual(None, func(None))
+            self.assertEqual(u"123", func(u"123"))
+            self.assertEqual(None, func(c_wchar_p(None)))
+            self.assertEqual(u"123", func(c_wchar_p(u"123")))
+
+            self.assertEqual(u"123", func(c_wbuffer(u"123")))
+            ca = c_wchar("a")
+            self.assertEqual(u"a", func(pointer(ca))[0])
+            self.assertEqual(u"a", func(byref(ca))[0])
+
+        def test_c_wchar_p_arg(self):
+            func = testdll._testfunc_p_p
+            func.restype = c_wchar_p
+            func.argtypes = c_wchar_p,
+
+            c_wchar_p.from_param(u"123")
+
+            self.assertEqual(None, func(None))
+            self.assertEqual("123", func(u"123"))
+            self.assertEqual(None, func(c_wchar_p(None)))
+            self.assertEqual("123", func(c_wchar_p("123")))
+
+            # XXX Currently, these raise TypeErrors, although they shouldn't:
+            self.assertEqual("123", func(c_wbuffer("123")))
+            ca = c_wchar("a")
+            self.assertEqual("a", func(pointer(ca))[0])
+            self.assertEqual("a", func(byref(ca))[0])
+
+class ArrayTest(unittest.TestCase):
+    def test(self):
+        func = testdll._testfunc_ai8
+        func.restype = POINTER(c_int)
+        func.argtypes = c_int * 8,
+
+        func((c_int * 8)(1, 2, 3, 4, 5, 6, 7, 8))
+
+        # This did crash before:
+
+        def func(): pass
+        CFUNCTYPE(None, c_int * 3)(func)
+
+################################################################
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/lib/python2.7/ctypes/test/test_python_api.py b/lib/python2.7/ctypes/test/test_python_api.py
new file mode 100644
index 0000000..698170f
--- /dev/null
+++ b/lib/python2.7/ctypes/test/test_python_api.py
@@ -0,0 +1,90 @@
+from ctypes import *
+import unittest, sys
+from ctypes.test import is_resource_enabled
+
+################################################################
+# This section should be moved into ctypes\__init__.py, when it's ready.
+
+from _ctypes import PyObj_FromPtr
+
+################################################################
+
+from sys import getrefcount as grc
+if sys.version_info > (2, 4):
+    c_py_ssize_t = c_size_t
+else:
+    c_py_ssize_t = c_int
+
+class PythonAPITestCase(unittest.TestCase):
+
+    def test_PyString_FromStringAndSize(self):
+        PyString_FromStringAndSize = pythonapi.PyString_FromStringAndSize
+
+        PyString_FromStringAndSize.restype = py_object
+        PyString_FromStringAndSize.argtypes = c_char_p, c_py_ssize_t
+
+        self.assertEqual(PyString_FromStringAndSize("abcdefghi", 3), "abc")
+
+    def test_PyString_FromString(self):
+        pythonapi.PyString_FromString.restype = py_object
+        pythonapi.PyString_FromString.argtypes = (c_char_p,)
+
+        s = "abc"
+        refcnt = grc(s)
+        pyob = pythonapi.PyString_FromString(s)
+        self.assertEqual(grc(s), refcnt)
+        self.assertEqual(s, pyob)
+        del pyob
+        self.assertEqual(grc(s), refcnt)
+
+    if is_resource_enabled("refcount"):
+        # This test is unreliable, because it is possible that code in
+        # unittest changes the refcount of the '42' integer.  So, it
+        # is disabled by default.
+        def test_PyInt_Long(self):
+            ref42 = grc(42)
+            pythonapi.PyInt_FromLong.restype = py_object
+            self.assertEqual(pythonapi.PyInt_FromLong(42), 42)
+
+            self.assertEqual(grc(42), ref42)
+
+            pythonapi.PyInt_AsLong.argtypes = (py_object,)
+            pythonapi.PyInt_AsLong.restype = c_long