Merged revisions 60990-61002 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60990 | eric.smith | 2008-02-23 17:05:26 +0100 (Sat, 23 Feb 2008) | 1 line

  Removed duplicate Py_CHARMASK define.  It's already defined in Python.h.
........
  r60991 | andrew.kuchling | 2008-02-23 17:23:05 +0100 (Sat, 23 Feb 2008) | 4 lines

  #1330538: Improve comparison of xmlrpclib.DateTime and datetime instances.
  Remove automatic handling of datetime.date and datetime.time.
  This breaks backward compatibility, but python-dev discussion was strongly
  against this automatic conversion; see the bug for a link.
........
  r60994 | andrew.kuchling | 2008-02-23 17:39:43 +0100 (Sat, 23 Feb 2008) | 1 line

  #835521: Add index entries for various pickle-protocol methods and attributes
........
  r60995 | andrew.kuchling | 2008-02-23 18:10:46 +0100 (Sat, 23 Feb 2008) | 2 lines

  #1433694: minidom's .normalize() failed to set .nextSibling for last element.
  Fix by Malte Helmert
........
  r61000 | christian.heimes | 2008-02-23 18:40:11 +0100 (Sat, 23 Feb 2008) | 1 line

  Patch #2167 from calvin: Remove unused imports
........
  r61001 | christian.heimes | 2008-02-23 18:42:31 +0100 (Sat, 23 Feb 2008) | 1 line

  Patch #1957: syslogmodule: Release GIL when calling syslog(3)
........
  r61002 | christian.heimes | 2008-02-23 18:52:07 +0100 (Sat, 23 Feb 2008) | 2 lines

  Issue #2051 and patch from Alexander Belopolsky:
  Permission for pyc and pyo files are inherited from the py file.
........
This commit is contained in:
Christian Heimes 2008-02-23 18:30:17 +00:00
parent 5abe9125f9
commit 05e8be17fd
161 changed files with 160 additions and 288 deletions

View File

@ -451,6 +451,11 @@ can do what they want. [#]_
Pickling and unpickling extension types Pickling and unpickling extension types
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. index::
single: __reduce__() (pickle protocol)
single: __reduce_ex__() (pickle protocol)
single: __safe_for_unpickling__ (pickle protocol)
When the :class:`Pickler` encounters an object of a type it knows nothing about When the :class:`Pickler` encounters an object of a type it knows nothing about
--- such as an extension type --- it looks in two places for a hint of how to --- such as an extension type --- it looks in two places for a hint of how to
pickle it. One alternative is for the object to implement a :meth:`__reduce__` pickle it. One alternative is for the object to implement a :meth:`__reduce__`
@ -526,6 +531,10 @@ unpickling as described above.
Pickling and unpickling external objects Pickling and unpickling external objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. index::
single: persistent_id (pickle protocol)
single: persistent_load (pickle protocol)
For the benefit of object persistence, the :mod:`pickle` module supports the For the benefit of object persistence, the :mod:`pickle` module supports the
notion of a reference to an object outside the pickled data stream. Such notion of a reference to an object outside the pickled data stream. Such
objects are referenced by a "persistent id", which is just an arbitrary string objects are referenced by a "persistent id", which is just an arbitrary string
@ -615,6 +624,10 @@ with the :meth:`noload` method on the Unpickler.
Subclassing Unpicklers Subclassing Unpicklers
---------------------- ----------------------
.. index::
single: load_global() (pickle protocol)
single: find_global() (pickle protocol)
By default, unpickling will import any class that it finds in the pickle data. By default, unpickling will import any class that it finds in the pickle data.
You can control exactly what gets unpickled and what gets called by customizing You can control exactly what gets unpickled and what gets called by customizing
your unpickler. Unfortunately, exactly how you do this is different depending your unpickler. Unfortunately, exactly how you do this is different depending

View File

@ -32,10 +32,7 @@ between conformable Python objects and XML on the wire.
all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a all clients and servers; see http://ontosys.com/xml-rpc/extensions.php for a
description. The *use_datetime* flag can be used to cause date/time values to description. The *use_datetime* flag can be used to cause date/time values to
be presented as :class:`datetime.datetime` objects; this is false by default. be presented as :class:`datetime.datetime` objects; this is false by default.
:class:`datetime.datetime`, :class:`datetime.date` and :class:`datetime.time` :class:`datetime.datetime` objects may be passed to calls.
objects may be passed to calls. :class:`datetime.date` objects are converted
with a time of "00:00:00". :class:`datetime.time` objects are converted using
today's date.
Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Both the HTTP and HTTPS transports support the URL syntax extension for HTTP
Basic Authentication: ``http://user:pass@host:port/path``. The ``user:pass`` Basic Authentication: ``http://user:pass@host:port/path``. The ``user:pass``
@ -79,9 +76,7 @@ between conformable Python objects and XML on the wire.
+---------------------------------+---------------------------------------------+ +---------------------------------+---------------------------------------------+
| :const:`dates` | in seconds since the epoch (pass in an | | :const:`dates` | in seconds since the epoch (pass in an |
| | instance of the :class:`DateTime` class) or | | | instance of the :class:`DateTime` class) or |
| | a :class:`datetime.datetime`, | | | a :class:`datetime.datetime` instance. |
| | :class:`datetime.date` or |
| | :class:`datetime.time` instance |
+---------------------------------+---------------------------------------------+ +---------------------------------+---------------------------------------------+
| :const:`binary data` | pass in an instance of the :class:`Binary` | | :const:`binary data` | pass in an instance of the :class:`Binary` |
| | wrapper class | | | wrapper class |
@ -211,10 +206,10 @@ The client code for the preceding server::
DateTime Objects DateTime Objects
---------------- ----------------
This class may be initialized with seconds since the epoch, a time tuple, an ISO This class may be initialized with seconds since the epoch, a time
8601 time/date string, or a :class:`datetime.datetime`, :class:`datetime.date` tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime`
or :class:`datetime.time` instance. It has the following methods, supported instance. It has the following methods, supported mainly for internal
mainly for internal use by the marshalling/unmarshalling code: use by the marshalling/unmarshalling code:
.. method:: DateTime.decode(string) .. method:: DateTime.decode(string)
@ -495,10 +490,7 @@ Convenience Functions
``None`` if no method name is present in the packet. If the XML-RPC packet ``None`` if no method name is present in the packet. If the XML-RPC packet
represents a fault condition, this function will raise a :exc:`Fault` exception. represents a fault condition, this function will raise a :exc:`Fault` exception.
The *use_datetime* flag can be used to cause date/time values to be presented as The *use_datetime* flag can be used to cause date/time values to be presented as
:class:`datetime.datetime` objects; this is false by default. Note that even if :class:`datetime.datetime` objects; this is false by default.
you call an XML-RPC method with :class:`datetime.date` or :class:`datetime.time`
objects, they are converted to :class:`DateTime` objects internally, so only
:class:`datetime.datetime` objects will be returned.
.. _xmlrpc-client-example: .. _xmlrpc-client-example:

View File

@ -1511,6 +1511,15 @@ code:
.. Issue 1706815 .. Issue 1706815
* The :mod:`xmlrpclib` module no longer automatically converts
:class:`datetime.date` and :class:`datetime.time` to the
:class:`xmlrpclib.DateTime` type; the conversion semantics were
not necessarily correct for all applications. Code using
:mod:`xmlrpclib` should convert :class:`date` and :class:`time`
instances.
.. Issue 1330538
.. ====================================================================== .. ======================================================================

View File

@ -14,7 +14,6 @@ import os
import posixpath import posixpath
import BaseHTTPServer import BaseHTTPServer
import urllib import urllib
import urlparse
import cgi import cgi
import shutil import shutil
import mimetypes import mimetypes

View File

@ -1,4 +1,4 @@
import glob, os, sys, unittest, getopt, time import os, sys, unittest, getopt, time
use_resources = [] use_resources = []

View File

@ -1,5 +1,4 @@
import unittest import unittest
import sys
from ctypes import * from ctypes import *

View File

@ -1,5 +1,5 @@
import unittest import unittest
import os, sys import sys
from ctypes import * from ctypes import *
from ctypes.util import find_library from ctypes.util import find_library
from ctypes.test import is_resource_enabled from ctypes.test import is_resource_enabled

View File

@ -1,4 +1,3 @@
import sys, os
import unittest import unittest
from ctypes import * from ctypes import *

View File

@ -1,6 +1,6 @@
from ctypes import * from ctypes import *
import unittest import unittest
import sys, struct import struct
def valid_ranges(*types): def valid_ranges(*types):
# given a sequence of numeric types, collect their _type_ # given a sequence of numeric types, collect their _type_

View File

@ -7,7 +7,7 @@ to a sane state so you can read the resulting traceback.
""" """
import sys, curses import curses
def wrapper(func, *args, **kwds): def wrapper(func, *args, **kwds):
"""Wrapper function that initializes curses and calls another function, """Wrapper function that initializes curses and calls another function,

View File

@ -14,7 +14,7 @@ for the Borland C++ compiler.
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os import os
from distutils.errors import \ from distutils.errors import \
DistutilsExecError, DistutilsPlatformError, \ DistutilsExecError, DistutilsPlatformError, \
CompileError, LibError, LinkError, UnknownFileError CompileError, LibError, LinkError, UnknownFileError

View File

@ -9,7 +9,7 @@ __revision__ = "$Id$"
import os import os
from distutils.core import Command from distutils.core import Command
from distutils.util import get_platform from distutils.util import get_platform
from distutils.dir_util import create_tree, remove_tree, ensure_relative from distutils.dir_util import remove_tree, ensure_relative
from distutils.errors import * from distutils.errors import *
from distutils.sysconfig import get_python_version from distutils.sysconfig import get_python_version
from distutils import log from distutils import log

View File

@ -6,7 +6,6 @@ distributions)."""
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os import sys, os
import glob
from distutils.core import Command from distutils.core import Command
from distutils.debug import DEBUG from distutils.debug import DEBUG
from distutils.util import get_platform from distutils.util import get_platform

View File

@ -4,7 +4,7 @@ Implements the Distutils 'build_scripts' command."""
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os, re import os, re
from stat import ST_MODE from stat import ST_MODE
from distutils import sysconfig from distutils import sysconfig
from distutils.core import Command from distutils.core import Command

View File

@ -14,7 +14,6 @@ from distutils.errors import DistutilsPlatformError
from distutils.file_util import write_file from distutils.file_util import write_file
from distutils.util import convert_path, subst_vars, change_root from distutils.util import convert_path, subst_vars, change_root
from distutils.errors import DistutilsOptionError from distutils.errors import DistutilsOptionError
from glob import glob
if sys.version < "2.2": if sys.version < "2.2":
WINDOWS_SCHEME = { WINDOWS_SCHEME = {

View File

@ -5,7 +5,6 @@ files to the Python include directory."""
__revision__ = "$Id$" __revision__ = "$Id$"
import os
from distutils.core import Command from distutils.core import Command

View File

@ -7,7 +7,7 @@ Implements the Distutils 'register' command (register with the repository).
__revision__ = "$Id$" __revision__ = "$Id$"
import sys, os, urllib2, getpass, urlparse import os, string, urllib2, getpass, urlparse
import io, ConfigParser import io, ConfigParser
from distutils.core import Command from distutils.core import Command

View File

@ -8,7 +8,6 @@ __revision__ = "$Id$"
import os, re import os, re
import fnmatch import fnmatch
from glob import glob
from distutils.util import convert_path from distutils.util import convert_path
from distutils.errors import DistutilsTemplateError, DistutilsInternalError from distutils.errors import DistutilsTemplateError, DistutilsInternalError
from distutils import log from distutils import log

View File

@ -3,10 +3,8 @@
import distutils.cmd import distutils.cmd
import distutils.dist import distutils.dist
import os import os
import shutil
import io import io
import sys import sys
import tempfile
import unittest import unittest
from test.test_support import TESTFN from test.test_support import TESTFN

View File

@ -2,7 +2,6 @@
from distutils import sysconfig from distutils import sysconfig
import os import os
import sys
import unittest import unittest
from test.test_support import TESTFN from test.test_support import TESTFN

View File

@ -16,7 +16,6 @@ the "typical" Unix-style command-line C compiler:
__revision__ = "$Id$" __revision__ = "$Id$"
import os, sys import os, sys
from copy import copy
from distutils import sysconfig from distutils import sysconfig
from distutils.dep_util import newer from distutils.dep_util import newer

View File

@ -35,7 +35,6 @@ __all__ = [
'header_length', 'header_length',
] ]
import re
from base64 import b64encode from base64 import b64encode
from binascii import b2a_base64, a2b_base64 from binascii import b2a_base64, a2b_base64

View File

@ -66,7 +66,6 @@ Req-started-unread-response _CS_REQ_STARTED <response_class>
Req-sent-unread-response _CS_REQ_SENT <response_class> Req-sent-unread-response _CS_REQ_SENT <response_class>
""" """
import errno
import io import io
import mimetools import mimetools
import socket import socket

View File

@ -30,7 +30,6 @@ Each function will be called at most once for each event.
""" """
import sys import sys
import os
import re import re
import Tkinter import Tkinter

View File

@ -20,7 +20,6 @@ barrier, in particular frame and traceback objects.
""" """
import sys
import types import types
from idlelib import rpc from idlelib import rpc
from idlelib import Debugger from idlelib import Debugger

View File

@ -15,7 +15,6 @@
# - optimize tree redraw after expand of subnode # - optimize tree redraw after expand of subnode
import os import os
import sys
from Tkinter import * from Tkinter import *
import imp import imp

View File

@ -1,4 +1,3 @@
import sys
import string import string
from Tkinter import * from Tkinter import *

View File

@ -3,7 +3,7 @@ Dialog for building Tkinter accelerator key bindings
""" """
from Tkinter import * from Tkinter import *
import tkMessageBox import tkMessageBox
import string, os import string
class GetKeysDialog(Toplevel): class GetKeysDialog(Toplevel):
def __init__(self,parent,title,action,currentKeySequences): def __init__(self,parent,title,action,currentKeySequences):

View File

@ -1,5 +1,4 @@
import sys import sys
import os
import linecache import linecache
import time import time
import socket import socket

View File

@ -26,7 +26,6 @@ askstring -- get a string from the user
''' '''
from Tkinter import * from Tkinter import *
import os
class Dialog(Toplevel): class Dialog(Toplevel):

View File

@ -24,8 +24,7 @@ Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away! To use, simply 'import logging' and log away!
""" """
import sys, logging, socket, os, struct, time, glob import logging, socket, os, pickle, struct, time, glob
import pickle
from stat import ST_DEV, ST_INO from stat import ST_DEV, ST_INO
try: try:

View File

@ -6,8 +6,8 @@ module as os.path.
""" """
import os import os
import stat
import sys import sys
import stat
import genericpath import genericpath
from genericpath import * from genericpath import *

View File

@ -6,7 +6,6 @@ There are two classes:
only suitable for the simplest of AppleEvent servers. only suitable for the simplest of AppleEvent servers.
""" """
import sys
import traceback import traceback
import MacOS import MacOS
from Carbon import AE from Carbon import AE

View File

@ -20,7 +20,6 @@ import Carbon.File
import io import io
import aetypes import aetypes
from aetypes import mkenum, ObjectSpecifier from aetypes import mkenum, ObjectSpecifier
import os
# These ones seem to be missing from AppleEvents # These ones seem to be missing from AppleEvents
# (they're in AERegistry.h) # (they're in AERegistry.h)

View File

@ -5,7 +5,7 @@
# but mac-style for MacPython, whether running on OS9 or OSX. # but mac-style for MacPython, whether running on OS9 or OSX.
# #
import sys, os import os
Error = "bgenlocations.Error" Error = "bgenlocations.Error"
# #

View File

@ -7,9 +7,7 @@ copy(src, dst) - Full copy of 'src' to 'dst'
from Carbon import Res from Carbon import Res
from Carbon import File, Files from Carbon import File, Files
import os import os
import sys
import MacOS import MacOS
import time
try: try:
openrf = MacOS.openrf openrf = MacOS.openrf
except AttributeError: except AttributeError:

View File

@ -21,7 +21,7 @@
# misrepresented as being the original software. # misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution. # 3. This notice may not be removed or altered from any source distribution.
import os, unittest import unittest
import sqlite3 as sqlite import sqlite3 as sqlite
class CollationTests(unittest.TestCase): class CollationTests(unittest.TestCase):

View File

@ -54,7 +54,7 @@ PROTOCOL_SSLv23
PROTOCOL_TLSv1 PROTOCOL_TLSv1
""" """
import os, sys, textwrap import textwrap
import _ssl # if we can't import it, let the error propagate import _ssl # if we can't import it, let the error propagate

View File

@ -10,7 +10,6 @@ active threads survive in the child after a fork(); this is an error.
""" """
import os, sys, time, thread, unittest import os, sys, time, thread, unittest
from test.test_support import TestSkipped
LONGSLEEP = 2 LONGSLEEP = 2
SHORTSLEEP = 0.5 SHORTSLEEP = 0.5

View File

@ -5,7 +5,6 @@ Tests common to list and UserList.UserList
import sys import sys
import os import os
import unittest
from test import test_support, seq_tests from test import test_support, seq_tests
def CmpToKey(mycmp): def CmpToKey(mycmp):

View File

@ -3,7 +3,6 @@ Tests common to tuple, list and UserList.UserList
""" """
import unittest import unittest
from test import test_support
import sys import sys
# Various iterables # Various iterables

View File

@ -1,5 +1,5 @@
import unittest import unittest
from test.test_support import verbose, run_unittest from test.test_support import run_unittest
import sys import sys

View File

@ -3,7 +3,6 @@
"""Unit tests for abc.py.""" """Unit tests for abc.py."""
import sys
import unittest import unittest
from test import test_support from test import test_support

View File

@ -5,7 +5,6 @@ import macostools
import Carbon.File import Carbon.File
import MacOS import MacOS
import os import os
import sys
from test import test_support from test import test_support
import struct import struct
import applesingle import applesingle

View File

@ -1,7 +1,6 @@
"Test the functionality of Python classes implementing operators." "Test the functionality of Python classes implementing operators."
import unittest import unittest
import sys
from test import test_support from test import test_support

View File

@ -5,7 +5,6 @@ Original by Michael Schneider
""" """
from test import test_support
import cmd import cmd
import sys import sys
import trace import trace

View File

@ -1,4 +1,3 @@
import sys
import unittest import unittest
from test import test_support from test import test_support

View File

@ -1,6 +1,5 @@
"""Unit tests for the copy module.""" """Unit tests for the copy module."""
import sys
import copy import copy
import copy_reg import copy_reg

View File

@ -4,7 +4,6 @@ See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
""" """
import os import os
import sys
import pickle import pickle
import unittest import unittest

View File

@ -3,7 +3,6 @@
Roger E. Masse Roger E. Masse
""" """
import os import os
import random
import dbm import dbm
from dbm import error from dbm import error
from test.test_support import verbose, verify, TestSkipped, TESTFN from test.test_support import verbose, verify, TestSkipped, TESTFN

View File

@ -1,6 +1,6 @@
# Minimal tests for dis module # Minimal tests for dis module
from test.test_support import verbose, run_unittest from test.test_support import run_unittest
import unittest import unittest
import sys import sys
import dis import dis

View File

@ -3,7 +3,6 @@
# Create a bunch of threads, let each do some work, wait until all are done # Create a bunch of threads, let each do some work, wait until all are done
from test.test_support import verbose from test.test_support import verbose
import random
import dummy_threading as _threading import dummy_threading as _threading
import time import time

View File

@ -1,7 +1,6 @@
# Copyright (C) 2001-2007 Python Software Foundation # Copyright (C) 2001-2007 Python Software Foundation
# email package unit tests # email package unit tests
import unittest
# The specific tests now live in Lib/email/test # The specific tests now live in Lib/email/test
from email.test.test_email import suite from email.test.test_email import suite
from test import test_support from test import test_support

View File

@ -1,7 +1,6 @@
#! /usr/bin/env python #! /usr/bin/env python
"""test script for a few new invalid token catches""" """test script for a few new invalid token catches"""
import os
import unittest import unittest
from test import test_support from test import test_support

View File

@ -1,4 +1,4 @@
from test.test_support import verify, verbose, TestFailed, sortdict from test.test_support import verify, TestFailed, sortdict
from collections import UserDict, UserList from collections import UserDict, UserList
def e(a, b): def e(a, b):

View File

@ -6,7 +6,7 @@ Nick Mathewson
import unittest import unittest
from test.test_support import verbose, TESTFN, run_unittest from test.test_support import verbose, TESTFN, run_unittest
from test.test_support import unlink as safe_unlink from test.test_support import unlink as safe_unlink
import sys, os, re import sys, re
from io import StringIO from io import StringIO
from fileinput import FileInput, hook_encoded from fileinput import FileInput, hook_encoded

View File

@ -1,7 +1,7 @@
"""Tests for Lib/fractions.py.""" """Tests for Lib/fractions.py."""
from decimal import Decimal from decimal import Decimal
from test.test_support import run_unittest, verbose from test.test_support import run_unittest
import math import math
import operator import operator
import fractions import fractions

View File

@ -1,8 +1,7 @@
import unittest import unittest
from test import test_support from test import test_support
import sys
import warnings, re import warnings
warnings.filterwarnings("ignore", warnings.filterwarnings("ignore",
category=DeprecationWarning, category=DeprecationWarning,
message=".*integer argument expected, got float", message=".*integer argument expected, got float",

View File

@ -4,7 +4,7 @@
import unittest import unittest
from test import test_support from test import test_support
import sys, os import os
import gzip import gzip

View File

@ -2,7 +2,6 @@
import HTMLParser import HTMLParser
import pprint import pprint
import sys
import unittest import unittest
from test import test_support from test import test_support

View File

@ -1,6 +1,5 @@
import httplib import httplib
import io import io
import sys
import socket import socket
from unittest import TestCase from unittest import TestCase

View File

@ -1,5 +1,4 @@
import imp import imp
import thread
import unittest import unittest
from test import test_support from test import test_support

View File

@ -1,7 +1,6 @@
import unittest import unittest
from test import test_support from test import test_support
import operator import operator
import sys
maxsize = test_support.MAX_Py_ssize_t maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1 minsize = -maxsize-1

View File

@ -1,4 +1,3 @@
import unittest
import sys import sys
from test import test_support, list_tests from test import test_support, list_tests

View File

@ -3,7 +3,6 @@
import os import os
import sys import sys
import pickle import pickle
import traceback
from io import StringIO from io import StringIO
from test.test_support import verbose, run_unittest, TestSkipped from test.test_support import verbose, run_unittest, TestSkipped
import unittest import unittest
@ -791,6 +790,14 @@ class MinidomTest(unittest.TestCase):
"testNormalize -- single empty node removed") "testNormalize -- single empty node removed")
doc.unlink() doc.unlink()
def testBug1433694(self):
doc = parseString("<o><i/>t</o>")
node = doc.documentElement
node.childNodes[1].nodeValue = ""
node.normalize()
self.confirm(node.childNodes[-1].nextSibling == None,
"Final child's .nextSibling should be None")
def testSiblings(self): def testSiblings(self):
doc = parseString("<doc><?pi?>text?<elm/></doc>") doc = parseString("<doc><?pi?>text?<elm/></doc>")
root = doc.documentElement root = doc.documentElement

View File

@ -1,6 +1,6 @@
# Test the module type # Test the module type
import unittest import unittest
from test.test_support import verbose, run_unittest from test.test_support import run_unittest
import sys import sys
ModuleType = type(sys) ModuleType = type(sys)

View File

@ -1,5 +1,5 @@
import __future__ import __future__
import sys, os import os
import unittest import unittest
import distutils.dir_util import distutils.dir_util
import tempfile import tempfile

View File

@ -4,7 +4,7 @@
# Common Unittest Routines for CJK codecs # Common Unittest Routines for CJK codecs
# #
import sys, codecs, os.path import sys, codecs
import unittest, re import unittest, re
from test import test_support from test import test_support
from io import BytesIO from io import BytesIO

View File

@ -15,7 +15,6 @@ import copy
import unittest import unittest
from io import StringIO from io import StringIO
from pprint import pprint
from test import test_support from test import test_support

View File

@ -1,14 +1,11 @@
from test import test_support from test import test_support
test_support.requires('audio') test_support.requires('audio')
from test.test_support import verbose, findfile, TestSkipped from test.test_support import findfile, TestSkipped
import errno import errno
import fcntl
import ossaudiodev import ossaudiodev
import os
import sys import sys
import select
import sunaudio import sunaudio
import time import time
import audioop import audioop

View File

@ -1,5 +1,4 @@
import pickle import pickle
import unittest
import io import io
from test import test_support from test import test_support

View File

@ -4,7 +4,6 @@ import sys
import os import os
import tempfile import tempfile
import textwrap import textwrap
import traceback
import unittest import unittest
from test import test_support from test import test_support

View File

@ -3,7 +3,6 @@
import unittest import unittest
import plistlib import plistlib
import os import os
import time
import datetime import datetime
from test import test_support from test import test_support

View File

@ -1,6 +1,6 @@
# Test case for the os.poll() function # Test case for the os.poll() function
import sys, os, select, random, unittest import os, select, random, unittest
from test.test_support import TestSkipped, TESTFN, run_unittest from test.test_support import TestSkipped, TESTFN, run_unittest
try: try:

View File

@ -9,7 +9,6 @@ except ImportError:
import time import time
import os import os
import sys
import unittest import unittest
import warnings import warnings
warnings.filterwarnings('ignore', '.* potential security risk .*', warnings.filterwarnings('ignore', '.* potential security risk .*',

View File

@ -3,7 +3,7 @@
Nick Mathewson Nick Mathewson
''' '''
from test.test_support import run_unittest from test.test_support import run_unittest
import unittest, sys import sys
from types import FunctionType, MethodType, BuiltinFunctionType from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr import pyclbr
from unittest import TestCase from unittest import TestCase

View File

@ -1,7 +1,6 @@
import unittest import unittest
from test import test_support from test import test_support
import os
import resource import resource
import time import time

View File

@ -1,5 +1,4 @@
import rfc822 import rfc822
import sys
import unittest import unittest
from test import test_support from test import test_support

View File

@ -1,9 +1,6 @@
# Copyright (C) 2003 Python Software Foundation # Copyright (C) 2003 Python Software Foundation
import unittest import unittest
import os
import sys
import tempfile
from test import test_support from test import test_support
import aetools import aetools

View File

@ -1,4 +1,3 @@
import htmlentitydefs
import pprint import pprint
import re import re
import sgmllib import sgmllib
@ -116,7 +115,7 @@ class SGMLParserTestCase(unittest.TestCase):
try: try:
events = self.get_events(source) events = self.get_events(source)
except: except:
import sys #import sys
#print >>sys.stderr, pprint.pformat(self.events) #print >>sys.stderr, pprint.pformat(self.events)
raise raise
if events != expected_events: if events != expected_events:

View File

@ -5,12 +5,11 @@ executing have not been removed.
""" """
import unittest import unittest
from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN from test.test_support import TestSkipped, run_unittest, TESTFN
import builtins import builtins
import os import os
import sys import sys
import encodings import encodings
import tempfile
# Need to make sure to not import 'site' if someone specified ``-S`` at the # Need to make sure to not import 'site' if someone specified ``-S`` at the
# command-line. Detect this by just making sure 'site' has not been imported # command-line. Detect this by just making sure 'site' has not been imported
# already. # already.

View File

@ -9,7 +9,6 @@ import imp
import select import select
import time import time
import threading import threading
from functools import wraps
import unittest import unittest
import SocketServer import SocketServer

View File

@ -1,5 +1,4 @@
from test.test_support import run_unittest, TestSkipped from test.test_support import run_unittest, TestSkipped
import unittest
try: try:
import _sqlite3 import _sqlite3

View File

@ -2,7 +2,7 @@
# Sanity checker for time.strftime # Sanity checker for time.strftime
import time, calendar, sys, os, re import time, calendar, sys, re
from test.test_support import verbose from test.test_support import verbose
def main(): def main():

View File

@ -10,7 +10,6 @@ import sys
import os import os
import os.path import os.path
import warnings import warnings
import types
import unittest import unittest
class Error(Exception): class Error(Exception):

View File

@ -1,4 +1,3 @@
import unittest
from test import test_support, seq_tests from test import test_support, seq_tests
class TupleTest(seq_tests.CommonTest): class TupleTest(seq_tests.CommonTest):

View File

@ -122,7 +122,6 @@ error)
__test__ = {'doctests' : doctests} __test__ = {'doctests' : doctests}
def test_main(verbose=False): def test_main(verbose=False):
import sys
from test import test_support from test import test_support
from test import test_unpack from test import test_unpack
test_support.run_doctest(test_unpack, verbose) test_support.run_doctest(test_unpack, verbose)

View File

@ -8,10 +8,6 @@ from test import test_support
import os import os
import mimetools import mimetools
import tempfile import tempfile
import ftplib
import threading
import socket
import time
def hexescape(char): def hexescape(char):
"""Escape char as RFC 2396 specifies""" """Escape char as RFC 2396 specifies"""

View File

@ -1,7 +1,7 @@
import unittest import unittest
from test import test_support from test import test_support
import os, socket import os
import io import io
import urllib2 import urllib2
@ -584,7 +584,7 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(int(headers["Content-length"]), len(data)) self.assertEqual(int(headers["Content-length"]), len(data))
def test_file(self): def test_file(self):
import time, rfc822, socket import rfc822, socket
h = urllib2.FileHandler() h = urllib2.FileHandler()
o = h.parent = MockOpener() o = h.parent = MockOpener()
@ -988,7 +988,7 @@ class HandlerTests(unittest.TestCase):
def _test_basic_auth(self, opener, auth_handler, auth_header, def _test_basic_auth(self, opener, auth_handler, auth_header,
realm, http_handler, password_manager, realm, http_handler, password_manager,
request_url, protected_url): request_url, protected_url):
import base64, httplib import base64
user, password = "wile", "coyote" user, password = "wile", "coyote"
# .add_password() fed through to password manager # .add_password() fed through to password manager

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys
import threading import threading
import urlparse import urlparse
import urllib2 import urllib2

View File

@ -1,6 +1,5 @@
# Check every path through every method of UserDict # Check every path through every method of UserDict
import unittest
from test import test_support, mapping_tests from test import test_support, mapping_tests
import collections import collections

View File

@ -1,7 +1,6 @@
# Check every path through every method of UserList # Check every path through every method of UserList
from collections import UserList from collections import UserList
import unittest
from test import test_support, list_tests from test import test_support, list_tests
class UserListTest(list_tests.CommonTest): class UserListTest(list_tests.CommonTest):

View File

@ -2,7 +2,6 @@
# UserString is a wrapper around the native builtin string type. # UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects. # UserString instances should behave similar to builtin string objects.
import unittest
import string import string
from test import test_support, string_tests from test import test_support, string_tests

View File

@ -8,7 +8,6 @@ import test.test_support
import unittest import unittest
import whichdb import whichdb
import anydbm import anydbm
import tempfile
import glob import glob
from test.test_anydbm import delete_files, dbm_iterator from test.test_anydbm import delete_files, dbm_iterator

View File

@ -2,7 +2,8 @@
# all included components work as they should. For a more extensive # all included components work as they should. For a more extensive
# test suite, see the selftest script in the ElementTree distribution. # test suite, see the selftest script in the ElementTree distribution.
import doctest, sys import doctest
import sys
from test import test_support from test import test_support

View File

@ -1,6 +1,7 @@
# xml.etree test for cElementTree # xml.etree test for cElementTree
import doctest, sys import doctest
import sys
from test import test_support from test import test_support

View File

@ -26,10 +26,6 @@ alist = [{'astring': 'foo@bar.baz.spam',
(2005, 2, 10, 11, 41, 23, 0, 1, -1)), (2005, 2, 10, 11, 41, 23, 0, 1, -1)),
'datetime3': xmlrpclib.DateTime( 'datetime3': xmlrpclib.DateTime(
datetime.datetime(2005, 2, 10, 11, 41, 23)), datetime.datetime(2005, 2, 10, 11, 41, 23)),
'datetime4': xmlrpclib.DateTime(
datetime.date(2005, 2, 10)),
'datetime5': xmlrpclib.DateTime(
datetime.time(11, 41, 23)),
}] }]
class XMLRPCTestCase(unittest.TestCase): class XMLRPCTestCase(unittest.TestCase):
@ -53,34 +49,14 @@ class XMLRPCTestCase(unittest.TestCase):
(newdt,), m = xmlrpclib.loads(s, use_datetime=0) (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23')) self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))
def test_dump_bare_date(self): def test_cmp_datetime_DateTime(self):
# This checks that an unwrapped datetime.date object can be handled now = datetime.datetime.now()
# by the marshalling code. This can't be done via test_dump_load() dt = xmlrpclib.DateTime(now.timetuple())
# since the unmarshaller produces a datetime object self.assert_(dt == now)
d = datetime.datetime(2005, 2, 10, 11, 41, 23).date() self.assert_(now == dt)
s = xmlrpclib.dumps((d,)) then = now + datetime.timedelta(seconds=4)
(newd,), m = xmlrpclib.loads(s, use_datetime=1) self.assert_(then >= dt)
self.assertEquals(newd.date(), d) self.assert_(dt < then)
self.assertEquals(newd.time(), datetime.time(0, 0, 0))
self.assertEquals(m, None)
(newdt,), m = xmlrpclib.loads(s, use_datetime=0)
self.assertEquals(newdt, xmlrpclib.DateTime('20050210T00:00:00'))
def test_dump_bare_time(self):
# This checks that an unwrapped datetime.time object can be handled
# by the marshalling code. This can't be done via test_dump_load()
# since the unmarshaller produces a datetime object
t = datetime.datetime(2005, 2, 10, 11, 41, 23).time()
s = xmlrpclib.dumps((t,))
(newt,), m = xmlrpclib.loads(s, use_datetime=1)
today = datetime.datetime.now().date().strftime("%Y%m%d")
self.assertEquals(newt.time(), t)
self.assertEquals(newt.date(), datetime.datetime.now().date())
self.assertEquals(m, None)
(newdt,), m = xmlrpclib.loads(s, use_datetime=0)
self.assertEquals(newdt, xmlrpclib.DateTime('%sT11:41:23'%today))
def test_bug_1164912 (self): def test_bug_1164912 (self):
d = xmlrpclib.DateTime() d = xmlrpclib.DateTime()
@ -201,21 +177,6 @@ class DateTimeTestCase(unittest.TestCase):
t = xmlrpclib.DateTime(d) t = xmlrpclib.DateTime(d)
self.assertEqual(str(t), '20070102T03:04:05') self.assertEqual(str(t), '20070102T03:04:05')
def test_datetime_date(self):
d = datetime.date(2007,9,8)
t = xmlrpclib.DateTime(d)
self.assertEqual(str(t), '20070908T00:00:00')
def test_datetime_time(self):
d = datetime.time(13,17,19)
# allow for date rollover by checking today's or tomorrow's dates
dd1 = datetime.datetime.now().date()
dd2 = dd1 + datetime.timedelta(days=1)
vals = (dd1.strftime('%Y%m%dT13:17:19'),
dd2.strftime('%Y%m%dT13:17:19'))
t = xmlrpclib.DateTime(d)
self.assertEqual(str(t) in vals, True)
def test_repr(self): def test_repr(self):
d = datetime.datetime(2007,1,2,3,4,5) d = datetime.datetime(2007,1,2,3,4,5)
t = xmlrpclib.DateTime(d) t = xmlrpclib.DateTime(d)

View File

@ -204,6 +204,8 @@ class Node(xml.dom.Node):
L.append(child) L.append(child)
if child.nodeType == Node.ELEMENT_NODE: if child.nodeType == Node.ELEMENT_NODE:
child.normalize() child.normalize()
if L:
L[-1].nextSibling = None
self.childNodes[:] = L self.childNodes[:] = L
def cloneNode(self, deep): def cloneNode(self, deep):

View File

@ -298,13 +298,6 @@ class DateTime:
if datetime and isinstance(value, datetime.datetime): if datetime and isinstance(value, datetime.datetime):
self.value = value.strftime("%Y%m%dT%H:%M:%S") self.value = value.strftime("%Y%m%dT%H:%M:%S")
return return
if datetime and isinstance(value, datetime.date):
self.value = value.strftime("%Y%m%dT%H:%M:%S")
return
if datetime and isinstance(value, datetime.time):
today = datetime.datetime.now().strftime("%Y%m%d")
self.value = value.strftime(today+"T%H:%M:%S")
return
if not isinstance(value, (tuple, time.struct_time)): if not isinstance(value, (tuple, time.struct_time)):
if value == 0: if value == 0:
value = time.time() value = time.time()
@ -312,15 +305,57 @@ class DateTime:
value = time.strftime("%Y%m%dT%H:%M:%S", value) value = time.strftime("%Y%m%dT%H:%M:%S", value)
self.value = value self.value = value
def __eq__(self, other): def make_comparable(self, other):
if isinstance(other, DateTime): if isinstance(other, DateTime):
other = other.value s = self.value
return self.value == other o = other.value
elif datetime and isinstance(other, datetime.datetime):
s = self.value
o = other.strftime("%Y%m%dT%H:%M:%S")
elif isinstance(other, (str, unicode)):
s = self.value
o = other
elif hasattr(other, "timetuple"):
s = self.timetuple()
o = other.timetuple()
else:
otype = (hasattr(other, "__class__")
and other.__class__.__name__
or type(other))
raise TypeError("Can't compare %s and %s" %
(self.__class__.__name__, otype))
return s, o
def __lt__(self, other):
s, o = self.make_comparable(other)
return s < o
def __le__(self, other):
s, o = self.make_comparable(other)
return s <= o
def __gt__(self, other):
s, o = self.make_comparable(other)
return s > o
def __ge__(self, other):
s, o = self.make_comparable(other)
return s >= o
def __eq__(self, other):
s, o = self.make_comparable(other)
return s == o
def __ne__(self, other): def __ne__(self, other):
if isinstance(other, DateTime): s, o = self.make_comparable(other)
other = other.value return s != o
return self.value != other
def timetuple(self):
return time.strptime(self.value, "%Y%m%dT%H:%M:%S")
def __cmp__(self, other):
s, o = self.make_comparable(other)
return cmp(s, o)
## ##
# Get date/time value. # Get date/time value.
@ -669,19 +704,6 @@ class Marshaller:
write("</dateTime.iso8601></value>\n") write("</dateTime.iso8601></value>\n")
dispatch[datetime.datetime] = dump_datetime dispatch[datetime.datetime] = dump_datetime
def dump_date(self, value, write):
write("<value><dateTime.iso8601>")
write(value.strftime("%Y%m%dT00:00:00"))
write("</dateTime.iso8601></value>\n")
dispatch[datetime.date] = dump_date
def dump_time(self, value, write):
write("<value><dateTime.iso8601>")
write(datetime.datetime.now().date().strftime("%Y%m%dT"))
write(value.strftime("%H:%M:%S"))
write("</dateTime.iso8601></value>\n")
dispatch[datetime.time] = dump_time
def dump_instance(self, value, write): def dump_instance(self, value, write):
# check for special wrappers # check for special wrappers
if value.__class__ in WRAPPERS: if value.__class__ in WRAPPERS:

View File

@ -7,8 +7,6 @@ from Carbon import Qd
from Carbon import Win from Carbon import Win
from Carbon import Controls from Carbon import Controls
from Carbon import List from Carbon import List
import sys
import struct
from Carbon import Icn from Carbon import Icn
import macresource import macresource

Some files were not shown because too many files have changed in this diff Show More