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
--- 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__`
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
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
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.
You can control exactly what gets unpickled and what gets called by customizing
your unpickler. Unfortunately, exactly how you do this is different depending
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
be presented as :class:`datetime.datetime` objects; this is false by default.
- :class:`datetime.datetime`, :class:`datetime.date` and :class:`datetime.time`
- 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.
+ :class:`datetime.datetime` objects may be passed to calls.
Both the HTTP and HTTPS transports support the URL syntax extension for HTTP
Basic Authentication: ``http://user:pass@host:port/path``. The ``user:pass``
+---------------------------------+---------------------------------------------+
| :const:`dates` | in seconds since the epoch (pass in an |
| | instance of the :class:`DateTime` class) or |
- | | a :class:`datetime.datetime`, |
- | | :class:`datetime.date` or |
- | | :class:`datetime.time` instance |
+ | | a :class:`datetime.datetime` instance. |
+---------------------------------+---------------------------------------------+
| :const:`binary data` | pass in an instance of the :class:`Binary` |
| | wrapper class |
DateTime Objects
----------------
-This class may be initialized with seconds since the epoch, a time tuple, an ISO
-8601 time/date string, or a :class:`datetime.datetime`, :class:`datetime.date`
-or :class:`datetime.time` instance. It has the following methods, supported
-mainly for internal use by the marshalling/unmarshalling code:
+This class may be initialized with seconds since the epoch, a time
+tuple, an ISO 8601 time/date string, or a :class:`datetime.datetime`
+instance. It has the following methods, supported mainly for internal
+use by the marshalling/unmarshalling code:
.. method:: DateTime.decode(string)
``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.
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
- 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.
+ :class:`datetime.datetime` objects; this is false by default.
.. _xmlrpc-client-example:
.. 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
+
.. ======================================================================
import posixpath
import BaseHTTPServer
import urllib
-import urlparse
import cgi
import shutil
import mimetypes
-import glob, os, sys, unittest, getopt, time
+import os, sys, unittest, getopt, time
use_resources = []
import unittest
-import sys
from ctypes import *
import unittest
-import os, sys
+import sys
from ctypes import *
from ctypes.util import find_library
from ctypes.test import is_resource_enabled
-import sys, os
import unittest
from ctypes import *
from ctypes import *
import unittest
-import sys, struct
+import struct
def valid_ranges(*types):
# given a sequence of numeric types, collect their _type_
"""
-import sys, curses
+import curses
def wrapper(func, *args, **kwds):
"""Wrapper function that initializes curses and calls another function,
__revision__ = "$Id$"
-import sys, os
+import os
from distutils.errors import \
DistutilsExecError, DistutilsPlatformError, \
CompileError, LibError, LinkError, UnknownFileError
import os
from distutils.core import Command
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.sysconfig import get_python_version
from distutils import log
__revision__ = "$Id$"
import sys, os
-import glob
from distutils.core import Command
from distutils.debug import DEBUG
from distutils.util import get_platform
__revision__ = "$Id$"
-import sys, os, re
+import os, re
from stat import ST_MODE
from distutils import sysconfig
from distutils.core import Command
from distutils.file_util import write_file
from distutils.util import convert_path, subst_vars, change_root
from distutils.errors import DistutilsOptionError
-from glob import glob
if sys.version < "2.2":
WINDOWS_SCHEME = {
__revision__ = "$Id$"
-import os
from distutils.core import Command
__revision__ = "$Id$"
-import sys, os, urllib2, getpass, urlparse
+import os, string, urllib2, getpass, urlparse
import io, ConfigParser
from distutils.core import Command
import os, re
import fnmatch
-from glob import glob
from distutils.util import convert_path
from distutils.errors import DistutilsTemplateError, DistutilsInternalError
from distutils import log
import distutils.cmd
import distutils.dist
import os
-import shutil
import io
import sys
-import tempfile
import unittest
from test.test_support import TESTFN
from distutils import sysconfig
import os
-import sys
import unittest
from test.test_support import TESTFN
__revision__ = "$Id$"
import os, sys
-from copy import copy
from distutils import sysconfig
from distutils.dep_util import newer
'header_length',
]
-import re
from base64 import b64encode
from binascii import b2a_base64, a2b_base64
Req-sent-unread-response _CS_REQ_SENT <response_class>
"""
-import errno
import io
import mimetools
import socket
"""
import sys
-import os
import re
import Tkinter
"""
-import sys
import types
from idlelib import rpc
from idlelib import Debugger
# - optimize tree redraw after expand of subnode
import os
-import sys
from Tkinter import *
import imp
-import sys
import string
from Tkinter import *
"""
from Tkinter import *
import tkMessageBox
-import string, os
+import string
class GetKeysDialog(Toplevel):
def __init__(self,parent,title,action,currentKeySequences):
import sys
-import os
import linecache
import time
import socket
'''
from Tkinter import *
-import os
class Dialog(Toplevel):
To use, simply 'import logging' and log away!
"""
-import sys, logging, socket, os, struct, time, glob
-import pickle
+import logging, socket, os, pickle, struct, time, glob
from stat import ST_DEV, ST_INO
try:
"""
import os
-import stat
import sys
+import stat
import genericpath
from genericpath import *
only suitable for the simplest of AppleEvent servers.
"""
-import sys
import traceback
import MacOS
from Carbon import AE
import io
import aetypes
from aetypes import mkenum, ObjectSpecifier
-import os
# These ones seem to be missing from AppleEvents
# (they're in AERegistry.h)
# but mac-style for MacPython, whether running on OS9 or OSX.
#
-import sys, os
+import os
Error = "bgenlocations.Error"
#
from Carbon import Res
from Carbon import File, Files
import os
-import sys
import MacOS
-import time
try:
openrf = MacOS.openrf
except AttributeError:
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-import os, unittest
+import unittest
import sqlite3 as sqlite
class CollationTests(unittest.TestCase):
PROTOCOL_TLSv1
"""
-import os, sys, textwrap
+import textwrap
import _ssl # if we can't import it, let the error propagate
"""
import os, sys, time, thread, unittest
-from test.test_support import TestSkipped
LONGSLEEP = 2
SHORTSLEEP = 0.5
import sys
import os
-import unittest
from test import test_support, seq_tests
def CmpToKey(mycmp):
"""
import unittest
-from test import test_support
import sys
# Various iterables
import unittest
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
import sys
"""Unit tests for abc.py."""
-import sys
import unittest
from test import test_support
import Carbon.File
import MacOS
import os
-import sys
from test import test_support
import struct
import applesingle
"Test the functionality of Python classes implementing operators."
import unittest
-import sys
from test import test_support
"""
-from test import test_support
import cmd
import sys
import trace
-import sys
import unittest
from test import test_support
"""Unit tests for the copy module."""
-import sys
import copy
import copy_reg
"""
import os
-import sys
import pickle
import unittest
Roger E. Masse
"""
import os
-import random
import dbm
from dbm import error
from test.test_support import verbose, verify, TestSkipped, TESTFN
# Minimal tests for dis module
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
import unittest
import sys
import dis
# Create a bunch of threads, let each do some work, wait until all are done
from test.test_support import verbose
-import random
import dummy_threading as _threading
import time
# Copyright (C) 2001-2007 Python Software Foundation
# email package unit tests
-import unittest
# The specific tests now live in Lib/email/test
from email.test.test_email import suite
from test import test_support
#! /usr/bin/env python
"""test script for a few new invalid token catches"""
-import os
import unittest
from test import test_support
-from test.test_support import verify, verbose, TestFailed, sortdict
+from test.test_support import verify, TestFailed, sortdict
from collections import UserDict, UserList
def e(a, b):
import unittest
from test.test_support import verbose, TESTFN, run_unittest
from test.test_support import unlink as safe_unlink
-import sys, os, re
+import sys, re
from io import StringIO
from fileinput import FileInput, hook_encoded
"""Tests for Lib/fractions.py."""
from decimal import Decimal
-from test.test_support import run_unittest, verbose
+from test.test_support import run_unittest
import math
import operator
import fractions
import unittest
from test import test_support
-import sys
-import warnings, re
+import warnings
warnings.filterwarnings("ignore",
category=DeprecationWarning,
message=".*integer argument expected, got float",
import unittest
from test import test_support
-import sys, os
+import os
import gzip
import HTMLParser
import pprint
-import sys
import unittest
from test import test_support
import httplib
import io
-import sys
import socket
from unittest import TestCase
import imp
-import thread
import unittest
from test import test_support
import unittest
from test import test_support
import operator
-import sys
maxsize = test_support.MAX_Py_ssize_t
minsize = -maxsize-1
-import unittest
import sys
from test import test_support, list_tests
import os
import sys
import pickle
-import traceback
from io import StringIO
from test.test_support import verbose, run_unittest, TestSkipped
import unittest
"testNormalize -- single empty node removed")
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):
doc = parseString("<doc><?pi?>text?<elm/></doc>")
root = doc.documentElement
# Test the module type
import unittest
-from test.test_support import verbose, run_unittest
+from test.test_support import run_unittest
import sys
ModuleType = type(sys)
import __future__
-import sys, os
+import os
import unittest
import distutils.dir_util
import tempfile
# Common Unittest Routines for CJK codecs
#
-import sys, codecs, os.path
+import sys, codecs
import unittest, re
from test import test_support
from io import BytesIO
import unittest
from io import StringIO
-from pprint import pprint
from test import test_support
from test import test_support
test_support.requires('audio')
-from test.test_support import verbose, findfile, TestSkipped
+from test.test_support import findfile, TestSkipped
import errno
-import fcntl
import ossaudiodev
-import os
import sys
-import select
import sunaudio
import time
import audioop
import pickle
-import unittest
import io
from test import test_support
import os
import tempfile
import textwrap
-import traceback
import unittest
from test import test_support
import unittest
import plistlib
import os
-import time
import datetime
from test import test_support
# 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
try:
import time
import os
-import sys
import unittest
import warnings
warnings.filterwarnings('ignore', '.* potential security risk .*',
Nick Mathewson
'''
from test.test_support import run_unittest
-import unittest, sys
+import sys
from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr
from unittest import TestCase
import unittest
from test import test_support
-import os
import resource
import time
import rfc822
-import sys
import unittest
from test import test_support
# Copyright (C) 2003 Python Software Foundation
import unittest
-import os
-import sys
-import tempfile
from test import test_support
import aetools
-import htmlentitydefs
import pprint
import re
import sgmllib
try:
events = self.get_events(source)
except:
- import sys
+ #import sys
#print >>sys.stderr, pprint.pformat(self.events)
raise
if events != expected_events:
"""
import unittest
-from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN
+from test.test_support import TestSkipped, run_unittest, TESTFN
import builtins
import os
import sys
import encodings
-import tempfile
# 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
# already.
import select
import time
import threading
-from functools import wraps
import unittest
import SocketServer
from test.test_support import run_unittest, TestSkipped
-import unittest
try:
import _sqlite3
# Sanity checker for time.strftime
-import time, calendar, sys, os, re
+import time, calendar, sys, re
from test.test_support import verbose
def main():
import os
import os.path
import warnings
-import types
import unittest
class Error(Exception):
-import unittest
from test import test_support, seq_tests
class TupleTest(seq_tests.CommonTest):
__test__ = {'doctests' : doctests}
def test_main(verbose=False):
- import sys
from test import test_support
from test import test_unpack
test_support.run_doctest(test_unpack, verbose)
import os
import mimetools
import tempfile
-import ftplib
-import threading
-import socket
-import time
def hexescape(char):
"""Escape char as RFC 2396 specifies"""
import unittest
from test import test_support
-import os, socket
+import os
import io
import urllib2
self.assertEqual(int(headers["Content-length"]), len(data))
def test_file(self):
- import time, rfc822, socket
+ import rfc822, socket
h = urllib2.FileHandler()
o = h.parent = MockOpener()
def _test_basic_auth(self, opener, auth_handler, auth_header,
realm, http_handler, password_manager,
request_url, protected_url):
- import base64, httplib
+ import base64
user, password = "wile", "coyote"
# .add_password() fed through to password manager
#!/usr/bin/env python
-import sys
import threading
import urlparse
import urllib2
# Check every path through every method of UserDict
-import unittest
from test import test_support, mapping_tests
import collections
# Check every path through every method of UserList
from collections import UserList
-import unittest
from test import test_support, list_tests
class UserListTest(list_tests.CommonTest):
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
-import unittest
import string
from test import test_support, string_tests
import unittest
import whichdb
import anydbm
-import tempfile
import glob
from test.test_anydbm import delete_files, dbm_iterator
# all included components work as they should. For a more extensive
# test suite, see the selftest script in the ElementTree distribution.
-import doctest, sys
+import doctest
+import sys
from test import test_support
# xml.etree test for cElementTree
-import doctest, sys
+import doctest
+import sys
from test import test_support
(2005, 2, 10, 11, 41, 23, 0, 1, -1)),
'datetime3': xmlrpclib.DateTime(
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):
(newdt,), m = xmlrpclib.loads(s, use_datetime=0)
self.assertEquals(newdt, xmlrpclib.DateTime('20050210T11:41:23'))
- def test_dump_bare_date(self):
- # This checks that an unwrapped datetime.date object can be handled
- # by the marshalling code. This can't be done via test_dump_load()
- # since the unmarshaller produces a datetime object
- d = datetime.datetime(2005, 2, 10, 11, 41, 23).date()
- s = xmlrpclib.dumps((d,))
- (newd,), m = xmlrpclib.loads(s, use_datetime=1)
- self.assertEquals(newd.date(), d)
- 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_cmp_datetime_DateTime(self):
+ now = datetime.datetime.now()
+ dt = xmlrpclib.DateTime(now.timetuple())
+ self.assert_(dt == now)
+ self.assert_(now == dt)
+ then = now + datetime.timedelta(seconds=4)
+ self.assert_(then >= dt)
+ self.assert_(dt < then)
def test_bug_1164912 (self):
d = xmlrpclib.DateTime()
t = xmlrpclib.DateTime(d)
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):
d = datetime.datetime(2007,1,2,3,4,5)
t = xmlrpclib.DateTime(d)
L.append(child)
if child.nodeType == Node.ELEMENT_NODE:
child.normalize()
+ if L:
+ L[-1].nextSibling = None
self.childNodes[:] = L
def cloneNode(self, deep):
if datetime and isinstance(value, datetime.datetime):
self.value = value.strftime("%Y%m%dT%H:%M:%S")
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 value == 0:
value = time.time()
value = time.strftime("%Y%m%dT%H:%M:%S", value)
self.value = value
- def __eq__(self, other):
+ def make_comparable(self, other):
if isinstance(other, DateTime):
- other = other.value
- return self.value == other
+ s = self.value
+ 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):
- if isinstance(other, DateTime):
- other = other.value
- return self.value != other
+ s, o = self.make_comparable(other)
+ return s != o
+
+ 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.
write("</dateTime.iso8601></value>\n")
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):
# check for special wrappers
if value.__class__ in WRAPPERS:
from Carbon import Win
from Carbon import Controls
from Carbon import List
-import sys
-import struct
from Carbon import Icn
import macresource
from Carbon import Win
from Carbon import Controls
from Carbon import List
-import sys
import struct
import macresource
from Carbon import Win
from Carbon import Controls
from Carbon import List
-import sys
import struct
import macresource
from Carbon import Win
from Carbon import Controls
from Carbon import List
-import sys
-import struct
from Carbon import Icn
import macresource
from Carbon import Qd
from Carbon import Win
from Carbon import List
-import sys
import struct
import macresource
import EasyDialogs
from Carbon import Res
from Carbon import Dlg
-import sys
import socket
import string
import macresource
import EasyDialogs
from Carbon import Res
from Carbon import Dlg
-import sys
import socket
import string
import macresource
from Carbon import QuickDraw
from Carbon import Win
#ifrom Carbon mport List
-import sys
import struct
import img
import imgformat
-import struct
import mac_image
"""mac_image - Helper routines (hacks) for images"""
import imgformat
from Carbon import Qd
-import time
import struct
import MacOS
# (Should learn how to tell the compiler to compile it as well.)
import sys
-import os
-import string
import MacOS
from bgenlocations import TOOLBOXDIR, BGENDIR
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# IBCarbonscan.py
import sys
-import os
-import string
import MacOS
import sys
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan <Controls.h>, generating ctlgen.py.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan <Drag.h>, generating draggen.py.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR, INCLUDEDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# IBCarbonscan.py
import sys
-import os
-import string
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan <Menus.h>, generating menugen.py.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner_OSX
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# (Should learn how to tell the compiler to compile it as well.)
import sys
-import os
-import string
import MacOS
from bgenlocations import TOOLBOXDIR, BGENDIR
# generates a boilerplate to be edited by hand.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# (Should learn how to tell the compiler to compile it as well.)
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
# Scan an Apple header file, generating a Python file of generator calls.
import sys
-import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
Jochen Hayek
Christian Heimes
Thomas Heller
+Malte Helmert
Lance Finn Helsten
Jonathan Hendry
James Henstridge
message = PyUnicode_AsString(message_object);
if (message == NULL)
return NULL;
+ Py_BEGIN_ALLOW_THREADS;
syslog(priority, "%s", message);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_END_ALLOW_THREADS;
+ Py_RETURN_NONE;
}
static PyObject *
import os
import sys
-import shutil
here = os.path.abspath(os.path.dirname(__file__))
par = os.path.pardir
import os
import sys
-import shutil
here = os.path.abspath(os.path.dirname(__file__))
par = os.path.pardir
# TO DO
# handle fields that have a type but no name
-import os, sys, traceback
+import os, sys
import asdl
__version__ = 'SPARK-0.7 (pre-alpha-5)'
import re
-import sys
# Compatability with older pythons.
def output(string='', end='\n'):
/*
- __version__ 57783.
+ __version__ 60978.
This module must be committed separately after each AST grammar change;
The __version__ number is set to the revision number of the commit
if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
return;
- if (PyModule_AddStringConstant(m, "__version__", "57783") < 0)
+ if (PyModule_AddStringConstant(m, "__version__", "60978") < 0)
return;
if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
/* Helper to open a bytecode file for writing in exclusive mode */
static FILE *
-open_exclusive(char *filename)
+open_exclusive(char *filename, mode_t mode)
{
#if defined(O_EXCL)&&defined(O_CREAT)&&defined(O_WRONLY)&&defined(O_TRUNC)
/* Use O_EXCL to avoid a race condition when another process tries to
|O_BINARY /* necessary for Windows */
#endif
#ifdef __VMS
- , 0666, "ctxt=bin", "shr=nil"
+ , mode, "ctxt=bin", "shr=nil"
#else
- , 0666
+ , mode
#endif
);
if (fd < 0)
remove the file. */
static void
-write_compiled_module(PyCodeObject *co, char *cpathname, time_t mtime)
+write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat)
{
FILE *fp;
+ time_t mtime = srcstat->st_mtime;
+ mode_t mode = srcstat->st_mode;
- fp = open_exclusive(cpathname);
+ fp = open_exclusive(cpathname, mode);
if (fp == NULL) {
if (Py_VerboseFlag)
PySys_WriteStderr(
static PyObject *
load_source_module(char *name, char *pathname, FILE *fp)
{
- time_t mtime;
+ struct stat st;
FILE *fpc;
char buf[MAXPATHLEN+1];
char *cpathname;
PyCodeObject *co;
PyObject *m;
-
- mtime = PyOS_GetLastModificationTime(pathname, fp);
- if (mtime == (time_t)(-1)) {
+
+ if (fstat(fileno(fp), &st) != 0) {
PyErr_Format(PyExc_RuntimeError,
- "unable to get modification time from '%s'",
+ "unable to get file status from '%s'",
pathname);
return NULL;
}
in 4 bytes. This will be fine until sometime in the year 2038,
when a 4-byte signed time_t will overflow.
*/
- if (mtime >> 32) {
+ if (st.st_mtime >> 32) {
PyErr_SetString(PyExc_OverflowError,
"modification time overflows a 4 byte field");
return NULL;
cpathname = make_compiled_pathname(pathname, buf,
(size_t)MAXPATHLEN + 1);
if (cpathname != NULL &&
- (fpc = check_compiled_module(pathname, mtime, cpathname))) {
+ (fpc = check_compiled_module(pathname, st.st_mtime, cpathname))) {
co = read_compiled_module(cpathname, fpc);
fclose(fpc);
if (co == NULL)
if (cpathname) {
PyObject *ro = PySys_GetObject("dont_write_bytecode");
if (ro == NULL || !PyObject_IsTrue(ro))
- write_compiled_module(co, cpathname, mtime);
+ write_compiled_module(co, cpathname, &st);
}
}
m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname);
#define _SGI_MP_SOURCE
#endif
-/* Convert a possibly signed character to a nonnegative int */
-/* XXX This assumes characters are 8 bits wide */
-#ifdef __CHAR_UNSIGNED__
-#define Py_CHARMASK(c) (c)
-#else
-#define Py_CHARMASK(c) ((c) & 0xff)
-#endif
-
/* strtol and strtoul, renamed to avoid conflicts */
try:
FAQDIR = "/usr/people/guido/python/FAQ"
SRCDIR = "/usr/people/guido/python/src/Tools/faqwiz"
- import os, sys, time, operator
+ import os, sys
os.chdir(FAQDIR)
sys.path.insert(0, SRCDIR)
import faqwiz
0, 'Save', 'Save as text'))
def _test():
- import sys
global mainWidget
mainWidget = Frame()
Pack.config(mainWidget)
the author. All Rights Reserved.
"""
-import time, sys, struct
+import time, sys
#
# Note: Please keep this module compatible to Python 1.5.2.
selected and nearest ChipWidgets.
"""
-from types import StringType
from Tkinter import *
import ColorDB
you must hit Return or Tab to select the color.
"""
-import sys
-import re
from Tkinter import *
from their output.
"""
-import os, sys, errno, getopt, re
+import sys, errno, getopt, re
sep1 = '='*77 + '\n' # file separator
sep2 = '-'*28 + '\n' # revision separator
option to produce this format (since it is the original v7 Unix format).
"""
-import os,re,sys
+import os, sys
PYTHONLIB = 'libpython'+sys.version[:3]+'.a'
PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll'
TABSIZE = 8
EXPANDTABS = 0
-import os
import re
import sys
__all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"]
-import sys, os, re
+import os, re
binary_re = re.compile('[\x00-\x08\x0E-\x1F\x7F]')
import sys
import os
from stat import *
-import commands
import fnmatch
EXECMAGIC = '\001\140\000\010'
#
# By Bill Janssen.
-import sys, os
+import sys
def fetch_server_certificate (host, port):
"""#"
-import re, os, time, marshal, codecs
+import re, os, marshal, codecs
# Maximum allowed size of charmap tables
MAX_TABLE_SIZE = 8192
from Tkinter import *
import tktools
import webchecker
-import random
# Override some for a weaker platform
if sys.platform == 'mac':
"""
from Tkinter import *
-import Tkinter
import websucker
-import sys
import os
import threading
import Queue