Merged revisions 55817-55961 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/branches/p3yk

................
  r55837 | guido.van.rossum | 2007-06-08 16:04:42 -0700 (Fri, 08 Jun 2007) | 2 lines

  PEP 3119 -- the abc module.
................
  r55838 | guido.van.rossum | 2007-06-08 17:38:55 -0700 (Fri, 08 Jun 2007) | 2 lines

  Implement part of PEP 3119 -- One Trick Ponies.
................
  r55847 | guido.van.rossum | 2007-06-09 08:28:06 -0700 (Sat, 09 Jun 2007) | 2 lines

  Different way to do one trick ponies, allowing registration (per PEP strawman).
................
  r55849 | guido.van.rossum | 2007-06-09 18:06:38 -0700 (Sat, 09 Jun 2007) | 3 lines

  Make sure that the magic looking for __hash__ (etc.) doesn't apply to
  real subclasses of Hashable.
................
  r55852 | guido.van.rossum | 2007-06-10 08:29:51 -0700 (Sun, 10 Jun 2007) | 2 lines

  Add some more examples, e.g. generators and dict views.
................
  r55853 | guido.van.rossum | 2007-06-10 08:31:59 -0700 (Sun, 10 Jun 2007) | 2 lines

  keys() and items() *are* containers -- just values() isn't.
................
  r55864 | georg.brandl | 2007-06-10 15:29:40 -0700 (Sun, 10 Jun 2007) | 2 lines

  PEP 3127: new octal literals, binary literals.
................
  r55865 | georg.brandl | 2007-06-10 15:31:37 -0700 (Sun, 10 Jun 2007) | 2 lines

  Some octal literal fixes in Tools.
................
  r55866 | georg.brandl | 2007-06-10 15:37:43 -0700 (Sun, 10 Jun 2007) | 2 lines

  Tokenizer changes for PEP 3127.
................
  r55867 | georg.brandl | 2007-06-10 15:37:55 -0700 (Sun, 10 Jun 2007) | 2 lines

  Some docs for PEP 3127.
................
  r55868 | georg.brandl | 2007-06-10 15:44:39 -0700 (Sun, 10 Jun 2007) | 2 lines

  Missed a place in intobject.c. Is that used anymore anyway?
................
  r55871 | neal.norwitz | 2007-06-10 18:31:49 -0700 (Sun, 10 Jun 2007) | 182 lines

  Merged revisions 55729-55868 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r55731 | neal.norwitz | 2007-06-01 00:29:12 -0700 (Fri, 01 Jun 2007) | 7 lines

    SF 1668596/1720897: distutils now copies data files
    even if package_dir is empty.

    This needs to be backported.  I'm too tired tonight.  It would be great
    if someone backports this if the buildbots are ok with it.  Otherwise,
    I will try to get to it tomorrow.
  ........
    r55732 | georg.brandl | 2007-06-01 04:33:33 -0700 (Fri, 01 Jun 2007) | 2 lines

    Bug #1722484: remove docstrings again when running with -OO.
  ........
    r55735 | georg.brandl | 2007-06-01 12:20:27 -0700 (Fri, 01 Jun 2007) | 2 lines

    Fix wrong issue number.
  ........
    r55739 | brett.cannon | 2007-06-01 20:02:29 -0700 (Fri, 01 Jun 2007) | 3 lines

    Have configure raise an error when building on AtheOS.  Code specific to AtheOS
    will be removed in Python 2.7.
  ........
    r55746 | neal.norwitz | 2007-06-02 11:33:53 -0700 (Sat, 02 Jun 2007) | 1 line

    Update expected birthday of 2.6
  ........
    r55751 | neal.norwitz | 2007-06-03 13:32:50 -0700 (Sun, 03 Jun 2007) | 10 lines

    Backout the original 'fix' to 1721309 which had no effect.
    Different versions of Berkeley DB handle this differently.
    The comments and bug report should have the details.  Memory is allocated
    in 4.4 (and presumably earlier), but not in 4.5.  Thus
    4.5 has the free error, but not earlier versions.

    Mostly update comments, plus make the free conditional.

    This fix was already applied to the 2.5 branch.
  ........
    r55752 | brett.cannon | 2007-06-03 16:13:41 -0700 (Sun, 03 Jun 2007) | 6 lines

    Make _strptime.TimeRE().pattern() use ``\s+`` for matching whitespace instead
    of ``\s*``.  This prevents patterns from "stealing" bits from other patterns in
    order to make a match work.

    Closes bug #1730389.  Will be backported.
  ........
    r55766 | hyeshik.chang | 2007-06-05 11:16:52 -0700 (Tue, 05 Jun 2007) | 4 lines

    Fix build on FreeBSD.  Bluetooth HCI API in FreeBSD is quite different
    from Linux's.  Just fix the build for now but the code doesn't
    support the complete capability of HCI on FreeBSD yet.
  ........
    r55770 | hyeshik.chang | 2007-06-05 11:58:51 -0700 (Tue, 05 Jun 2007) | 4 lines

    Bug #1728403: Fix a bug that CJKCodecs StreamReader hangs when it
    reads a file that ends with incomplete sequence and sizehint argument
    for .read() is specified.
  ........
    r55775 | hyeshik.chang | 2007-06-05 12:28:15 -0700 (Tue, 05 Jun 2007) | 2 lines

    Fix for Windows: close a temporary file before trying to delete it.
  ........
    r55783 | guido.van.rossum | 2007-06-05 14:24:47 -0700 (Tue, 05 Jun 2007) | 2 lines

    Patch by Tim Delany (missing DECREF). SF #1731330.
  ........
    r55785 | collin.winter | 2007-06-05 17:17:35 -0700 (Tue, 05 Jun 2007) | 3 lines

    Patch #1731049: make threading.py use a proper "raise" when checking internal state, rather than assert statements (which get stripped out by -O).
  ........
    r55786 | facundo.batista | 2007-06-06 08:13:37 -0700 (Wed, 06 Jun 2007) | 4 lines


    FTP.ntransfercmd method now uses create_connection when passive,
    using the timeout received in connection time.
  ........
    r55792 | facundo.batista | 2007-06-06 10:15:23 -0700 (Wed, 06 Jun 2007) | 7 lines


    Added an optional timeout parameter to function urllib2.urlopen,
    with tests in test_urllib2net.py (must have network resource
    enabled to execute them). Also modified test_urllib2.py because
    testing mock classes must take it into acount. Docs are also
    updated.
  ........
    r55793 | thomas.heller | 2007-06-06 13:19:19 -0700 (Wed, 06 Jun 2007) | 1 line

    Build _ctypes and _ctypes_test in the ReleaseAMD64 configuration.
  ........
    r55802 | georg.brandl | 2007-06-07 06:23:24 -0700 (Thu, 07 Jun 2007) | 3 lines

    Disallow function calls like foo(None=1).
    Backport from py3k rev. 55708 by Guido.
  ........
    r55804 | georg.brandl | 2007-06-07 06:30:24 -0700 (Thu, 07 Jun 2007) | 2 lines

    Make reindent.py executable.
  ........
    r55805 | georg.brandl | 2007-06-07 06:34:10 -0700 (Thu, 07 Jun 2007) | 2 lines

    Patch #1667860: Fix UnboundLocalError in urllib2.
  ........
    r55821 | kristjan.jonsson | 2007-06-07 16:53:49 -0700 (Thu, 07 Jun 2007) | 1 line

    Fixing changes to getbuildinfo.c that broke linux builds
  ........
    r55828 | thomas.heller | 2007-06-08 09:10:27 -0700 (Fri, 08 Jun 2007) | 1 line

    Make this test work with older Python releases where struct has no 't' format character.
  ........
    r55829 | martin.v.loewis | 2007-06-08 10:29:20 -0700 (Fri, 08 Jun 2007) | 3 lines

    Bug #1733488: Fix compilation of bufferobject.c on AIX.
    Will backport to 2.5.
  ........
    r55831 | thomas.heller | 2007-06-08 11:20:09 -0700 (Fri, 08 Jun 2007) | 2 lines

    [ 1715718 ] x64 clean compile patch for _ctypes, by Kristj?n Valur
    with small modifications.
  ........
    r55832 | thomas.heller | 2007-06-08 12:01:06 -0700 (Fri, 08 Jun 2007) | 1 line

    Fix gcc warnings intruduced by passing Py_ssize_t to PyErr_Format calls.
  ........
    r55833 | thomas.heller | 2007-06-08 12:08:31 -0700 (Fri, 08 Jun 2007) | 2 lines

    Fix wrong documentation, and correct the punktuation.
    Closes [1700455].
  ........
    r55834 | thomas.heller | 2007-06-08 12:14:23 -0700 (Fri, 08 Jun 2007) | 1 line

    Fix warnings by using proper function prototype.
  ........
    r55839 | neal.norwitz | 2007-06-08 20:36:34 -0700 (Fri, 08 Jun 2007) | 7 lines

    Prevent expandtabs() on string and unicode objects from causing a segfault when
    a large width is passed on 32-bit platforms.  Found by Google.

    It would be good for people to review this especially carefully and verify
    I don't have an off by one error and there is no other way to cause overflow.
  ........
    r55841 | neal.norwitz | 2007-06-08 21:48:22 -0700 (Fri, 08 Jun 2007) | 1 line

    Use macro version of GET_SIZE to avoid Coverity warning (#150) about a possible error.
  ........
    r55842 | martin.v.loewis | 2007-06-09 00:42:52 -0700 (Sat, 09 Jun 2007) | 3 lines

    Patch #1733960: Allow T_LONGLONG to accept ints.
    Will backport to 2.5.
  ........
    r55843 | martin.v.loewis | 2007-06-09 00:58:05 -0700 (Sat, 09 Jun 2007) | 2 lines

    Fix Windows build.
  ........
    r55845 | martin.v.loewis | 2007-06-09 03:10:26 -0700 (Sat, 09 Jun 2007) | 2 lines

    Provide LLONG_MAX for S390.
  ........
    r55854 | thomas.heller | 2007-06-10 08:59:17 -0700 (Sun, 10 Jun 2007) | 4 lines


    First version of build scripts for Windows/AMD64 (no external
    components are built yet, and 'kill_python' is disabled).
  ........
    r55855 | thomas.heller | 2007-06-10 10:55:51 -0700 (Sun, 10 Jun 2007) | 3 lines

    For now, disable the _bsddb, _sqlite3, _ssl, _testcapi, _tkinter
    modules in the ReleaseAMD64 configuration because they do not compile.
  ........
    r55856 | thomas.heller | 2007-06-10 11:27:54 -0700 (Sun, 10 Jun 2007) | 1 line

    Need to set the environment variables, otherwise devenv.com is not found.
  ........
    r55860 | thomas.heller | 2007-06-10 14:01:17 -0700 (Sun, 10 Jun 2007) | 1 line

    Revert commit 55855.
  ........
................
  r55880 | neal.norwitz | 2007-06-10 22:07:36 -0700 (Sun, 10 Jun 2007) | 5 lines

  Fix the refleak counter on test_collections.  The ABC metaclass creates
  a registry which must be cleared on each run.  Otherwise, there *seem*
  to be refleaks when there really aren't any.  (The class is held within
  the registry even though it's no longer needed.)
................
  r55884 | neal.norwitz | 2007-06-10 22:46:33 -0700 (Sun, 10 Jun 2007) | 1 line

  These tests have been removed, so they are no longer needed here
................
  r55886 | georg.brandl | 2007-06-11 00:26:37 -0700 (Mon, 11 Jun 2007) | 3 lines

  Optimize access to True and False in the compiler (if True)
  and the peepholer (LOAD_NAME True).
................
  r55905 | georg.brandl | 2007-06-11 10:02:26 -0700 (Mon, 11 Jun 2007) | 5 lines

  Remove __oct__ and __hex__ and use __index__ for converting
  non-ints before formatting in a base.

  Add a bin() builtin.
................
  r55906 | georg.brandl | 2007-06-11 10:04:44 -0700 (Mon, 11 Jun 2007) | 2 lines

  int(x, 0) does not "guess".
................
  r55907 | georg.brandl | 2007-06-11 10:05:47 -0700 (Mon, 11 Jun 2007) | 2 lines

  Add a comment to explain that nb_oct and nb_hex are nonfunctional.
................
  r55908 | guido.van.rossum | 2007-06-11 10:49:18 -0700 (Mon, 11 Jun 2007) | 2 lines

  Get rid of unused imports and comment.
................
  r55910 | guido.van.rossum | 2007-06-11 13:05:17 -0700 (Mon, 11 Jun 2007) | 2 lines

  _Abstract.__new__ now requires either no arguments or __init__ overridden.
................
  r55911 | guido.van.rossum | 2007-06-11 13:07:49 -0700 (Mon, 11 Jun 2007) | 7 lines

  Move the collections ABCs to a separate file, _abcoll.py, in order to avoid
  needing to import _collections.so during the bootstrap (this will become
  apparent in the next submit of os.py).

  Add (plain and mutable) ABCs for Set, Mapping, Sequence.
................
  r55912 | guido.van.rossum | 2007-06-11 13:09:31 -0700 (Mon, 11 Jun 2007) | 2 lines

  Rewrite the _Environ class to use the new collections ABCs.
................
  r55913 | guido.van.rossum | 2007-06-11 13:59:45 -0700 (Mon, 11 Jun 2007) | 72 lines

  Merged revisions 55869-55912 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r55869 | neal.norwitz | 2007-06-10 17:42:11 -0700 (Sun, 10 Jun 2007) | 1 line

    Add Atul Varma for patch # 1667860
  ........
    r55870 | neal.norwitz | 2007-06-10 18:22:03 -0700 (Sun, 10 Jun 2007) | 1 line

    Ignore valgrind problems on Ubuntu from ld
  ........
    r55872 | neal.norwitz | 2007-06-10 18:48:46 -0700 (Sun, 10 Jun 2007) | 2 lines

    Ignore config.status.lineno which seems new (new autoconf?)
  ........
    r55873 | neal.norwitz | 2007-06-10 19:14:39 -0700 (Sun, 10 Jun 2007) | 1 line

    Prevent these tests from running on Win64 since they don\'t apply there either
  ........
    r55874 | neal.norwitz | 2007-06-10 19:16:10 -0700 (Sun, 10 Jun 2007) | 5 lines

    Fix a bug when there was a newline in the string expandtabs was called on.
    This also catches another condition that can overflow.

    Will backport.
  ........
    r55879 | neal.norwitz | 2007-06-10 21:52:37 -0700 (Sun, 10 Jun 2007) | 1 line

    Prevent hang if the port cannot be opened.
  ........
    r55881 | neal.norwitz | 2007-06-10 22:28:45 -0700 (Sun, 10 Jun 2007) | 4 lines

    Add all of the distuils modules that don't seem to have explicit tests. :-(
    Move an import in mworkscompiler so that this module can be imported on
    any platform.  Hopefully this works on all platforms.
  ........
    r55882 | neal.norwitz | 2007-06-10 22:35:10 -0700 (Sun, 10 Jun 2007) | 4 lines

    SF #1734732, lower case the module names per PEP 8.

    Will backport.
  ........
    r55885 | neal.norwitz | 2007-06-10 23:16:48 -0700 (Sun, 10 Jun 2007) | 4 lines

    Not sure why this only fails sometimes on Unix machines. Better
    to disable it and only import msvccompiler on Windows since that's
    the only place it can work anyways.
  ........
    r55887 | neal.norwitz | 2007-06-11 00:29:43 -0700 (Mon, 11 Jun 2007) | 4 lines

    Bug #1734723: Fix repr.Repr() so it doesn't ignore the maxtuple attribute.

    Will backport
  ........
    r55889 | neal.norwitz | 2007-06-11 00:36:24 -0700 (Mon, 11 Jun 2007) | 1 line

    Reflow long line
  ........
    r55896 | thomas.heller | 2007-06-11 08:58:33 -0700 (Mon, 11 Jun 2007) | 3 lines

    Use "O&" in calls to PyArg_Parse when we need a 'void*' instead of "k"
    or "K" codes.
  ........
    r55901 | facundo.batista | 2007-06-11 09:27:08 -0700 (Mon, 11 Jun 2007) | 5 lines


    Added versionchanged flag to all the methods which received
    a new optional timeout parameter, and a versionadded flag to
    the socket.create_connection function.
  ........
................
  r55914 | guido.van.rossum | 2007-06-11 14:19:50 -0700 (Mon, 11 Jun 2007) | 3 lines

  New super() implementation, for PEP 3135 (though the PEP is not yet updated
  to this design, and small tweaks may still be made later).
................
  r55923 | guido.van.rossum | 2007-06-11 21:15:24 -0700 (Mon, 11 Jun 2007) | 4 lines

  I'm guessing this module broke when Neal ripped out the types module --
  it used 'list' both as a local variable and as the built-in list type.
  Renamed the local variable since that was easier.
................
  r55924 | guido.van.rossum | 2007-06-11 21:20:05 -0700 (Mon, 11 Jun 2007) | 5 lines

  Change all occurrences of super(<thisclass>, <firstarg>) to super().
  Seems to have worked, all the tests still pass.
  Exception: test_descr and test_descrtut, which have tons of these
  and are there to test the various usages.
................
  r55939 | collin.winter | 2007-06-12 13:57:33 -0700 (Tue, 12 Jun 2007) | 1 line

  Patch #1735485: remove StandardError from the exception hierarchy.
................
  r55954 | neal.norwitz | 2007-06-12 21:56:32 -0700 (Tue, 12 Jun 2007) | 51 lines

  Merged revisions 55913-55950 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r55926 | marc-andre.lemburg | 2007-06-12 02:09:58 -0700 (Tue, 12 Jun 2007) | 3 lines

    Apply patch #1734945 to support TurboLinux as distribution.
  ........
    r55927 | marc-andre.lemburg | 2007-06-12 02:26:49 -0700 (Tue, 12 Jun 2007) | 3 lines

    Add patch #1726668: Windows Vista support.
  ........
    r55929 | thomas.heller | 2007-06-12 08:36:22 -0700 (Tue, 12 Jun 2007) | 1 line

    Checkout, but do not yet try to build, exernal sources.
  ........
    r55930 | thomas.heller | 2007-06-12 09:08:27 -0700 (Tue, 12 Jun 2007) | 6 lines

    Add bufferoverflowU.lib to the libraries needed by _ssl (is this the
    right thing to do?).

    Set the /XP64 /RETAIL build enviroment in the makefile when building
    ReleaseAMD64.
  ........
    r55931 | thomas.heller | 2007-06-12 09:23:19 -0700 (Tue, 12 Jun 2007) | 5 lines

    Revert this change, since it breaks the win32 build:

    Add bufferoverflowU.lib to the libraries needed by _ssl (is this the
    right thing to do?).
  ........
    r55934 | thomas.heller | 2007-06-12 10:28:31 -0700 (Tue, 12 Jun 2007) | 3 lines

    Specify the bufferoverflowU.lib to the makefile on the command line
    (for ReleaseAMD64 builds).
  ........
    r55937 | thomas.heller | 2007-06-12 12:02:59 -0700 (Tue, 12 Jun 2007) | 3 lines

    Add bufferoverflowU.lib to PCBuild\_bsddb.vcproj.
    Build sqlite3.dll and bsddb.
  ........
    r55938 | thomas.heller | 2007-06-12 12:56:12 -0700 (Tue, 12 Jun 2007) | 2 lines

    Don't rebuild Berkeley DB if not needed (this was committed by accident).
  ........
    r55948 | martin.v.loewis | 2007-06-12 20:42:19 -0700 (Tue, 12 Jun 2007) | 3 lines

    Provide PY_LLONG_MAX on all systems having long long.
    Will backport to 2.5.
  ........
................
  r55959 | guido.van.rossum | 2007-06-13 09:22:41 -0700 (Wed, 13 Jun 2007) | 2 lines

  Fix a compilation warning.
................
This commit is contained in:
Guido van Rossum 2007-06-13 18:07:49 +00:00
parent 6374bb5a69
commit cd16bf6404
195 changed files with 3365 additions and 1472 deletions

View file

@ -1713,6 +1713,7 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs)
PyObject* dataobj;
PyObject* retval = NULL;
DBT key, data;
void *orig_data;
DB_TXN *txn = NULL;
static char* kwnames[] = { "key", "data", "txn", "flags", NULL };
@ -1724,7 +1725,6 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs)
CHECK_DB_NOT_CLOSED(self);
if (!make_key_dbt(self, keyobj, &key, NULL))
return NULL;
CLEAR_DBT(data);
if ( !make_dbt(dataobj, &data) ||
!checkTxnObj(txnobj, &txn) )
{
@ -1733,13 +1733,12 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs)
}
flags |= DB_GET_BOTH;
orig_data = data.data;
if (CHECK_DBFLAG(self, DB_THREAD)) {
/* Tell BerkeleyDB to malloc the return value (thread safe) */
/* XXX(nnorwitz): At least 4.4.20 and 4.5.20 require this flag. */
data.flags = DB_DBT_MALLOC;
/* TODO: Is this flag needed? We're passing a data object that should
match what's in the DB, so there should be no need to malloc.
We run the risk of freeing something twice! Check this. */
}
MYDB_BEGIN_ALLOW_THREADS;
@ -1753,8 +1752,13 @@ DB_get_both(DBObject* self, PyObject* args, PyObject* kwargs)
retval = Py_None;
}
else if (!err) {
/* XXX(nnorwitz): can we do: retval = dataobj; Py_INCREF(retval); */
retval = PyString_FromStringAndSize((char*)data.data, data.size);
FREE_DBT(data); /* Only if retrieval was successful */
/* Even though the flags require DB_DBT_MALLOC, data is not always
allocated. 4.4: allocated, 4.5: *not* allocated. :-( */
if (data.data != orig_data)
FREE_DBT(data);
}
FREE_DBT(key);

View file

@ -789,7 +789,7 @@ static int
CharArray_set_value(CDataObject *self, PyObject *value)
{
char *ptr;
int size;
Py_ssize_t size;
if (PyUnicode_Check(value)) {
value = PyUnicode_AsEncodedString(value,
@ -844,7 +844,7 @@ WCharArray_get_value(CDataObject *self)
static int
WCharArray_set_value(CDataObject *self, PyObject *value)
{
int result = 0;
Py_ssize_t result = 0;
if (PyString_Check(value)) {
value = PyUnicode_FromEncodedObject(value,
@ -868,14 +868,12 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
result = PyUnicode_AsWideChar((PyUnicodeObject *)value,
(wchar_t *)self->b_ptr,
self->b_size/sizeof(wchar_t));
if (result >= 0 && (unsigned)result < self->b_size/sizeof(wchar_t))
if (result >= 0 && (size_t)result < self->b_size/sizeof(wchar_t))
((wchar_t *)self->b_ptr)[result] = (wchar_t)0;
if (result > 0)
result = 0;
done:
Py_DECREF(value);
return result;
return result >= 0 ? 0 : -1;
}
static PyGetSetDef WCharArray_getsets[] = {
@ -966,7 +964,7 @@ ArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *typedict;
int length;
int itemsize, itemalign;
Py_ssize_t itemsize, itemalign;
typedict = PyTuple_GetItem(args, 2);
if (!typedict)
@ -1737,8 +1735,8 @@ static PyObject *
converters_from_argtypes(PyObject *ob)
{
PyObject *converters;
int i;
int nArgs;
Py_ssize_t i;
Py_ssize_t nArgs;
ob = PySequence_Tuple(ob); /* new reference */
if (!ob) {
@ -1771,7 +1769,12 @@ converters_from_argtypes(PyObject *ob)
Py_XDECREF(converters);
Py_DECREF(ob);
PyErr_Format(PyExc_TypeError,
"item %d in _argtypes_ has no from_param method", i+1);
#if (PY_VERSION_HEX < 0x02050000)
"item %d in _argtypes_ has no from_param method",
#else
"item %zd in _argtypes_ has no from_param method",
#endif
i+1);
return NULL;
}
@ -2591,18 +2594,18 @@ static PyGetSetDef CFuncPtr_getsets[] = {
#ifdef MS_WIN32
static PPROC FindAddress(void *handle, char *name, PyObject *type)
{
#ifdef MS_WIN64
/* win64 has no stdcall calling conv, so it should
also not have the name mangling of it.
*/
return (PPROC)GetProcAddress(handle, name);
#else
PPROC address;
char *mangled_name;
int i;
StgDictObject *dict;
address = (PPROC)GetProcAddress(handle, name);
#ifdef _WIN64
/* win64 has no stdcall calling conv, so it should
also not have the name mangling of it.
*/
return address;
#else
if (address)
return address;
if (((size_t)name & ~0xFFFF) == 0) {
@ -2634,7 +2637,7 @@ static PPROC FindAddress(void *handle, char *name, PyObject *type)
/* Return 1 if usable, 0 else and exception set. */
static int
_check_outarg_type(PyObject *arg, int index)
_check_outarg_type(PyObject *arg, Py_ssize_t index)
{
StgDictObject *dict;
@ -2655,7 +2658,7 @@ _check_outarg_type(PyObject *arg, int index)
PyErr_Format(PyExc_TypeError,
"'out' parameter %d must be a pointer type, not %s",
index,
Py_SAFE_DOWNCAST(index, Py_ssize_t, int),
PyType_Check(arg) ?
((PyTypeObject *)arg)->tp_name :
arg->ob_type->tp_name);
@ -2666,7 +2669,7 @@ _check_outarg_type(PyObject *arg, int index)
static int
_validate_paramflags(PyTypeObject *type, PyObject *paramflags)
{
int i, len;
Py_ssize_t i, len;
StgDictObject *dict;
PyObject *argtypes;
@ -3051,12 +3054,12 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
PyObject *paramflags = self->paramflags;
PyObject *callargs;
StgDictObject *dict;
int i, len;
Py_ssize_t i, len;
int inargs_index = 0;
/* It's a little bit difficult to determine how many arguments the
function call requires/accepts. For simplicity, we count the consumed
args and compare this to the number of supplied args. */
int actual_args;
Py_ssize_t actual_args;
*poutmask = 0;
*pinoutmask = 0;
@ -3093,7 +3096,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
/* This way seems to be ~2 us faster than the PyArg_ParseTuple
calls below. */
/* We HAVE already checked that the tuple can be parsed with "i|zO", so... */
int tsize = PyTuple_GET_SIZE(item);
Py_ssize_t tsize = PyTuple_GET_SIZE(item);
flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0));
name = tsize > 1 ? PyString_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL;
defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL;
@ -3193,7 +3196,11 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
message is misleading. See unittests/test_paramflags.py
*/
PyErr_Format(PyExc_TypeError,
#if (PY_VERSION_HEX < 0x02050000)
"call takes exactly %d arguments (%d given)",
#else
"call takes exactly %d arguments (%zd given)",
#endif
inargs_index, actual_args);
goto error;
}
@ -3339,8 +3346,10 @@ CFuncPtr_call(CFuncPtrObject *self, PyObject *inargs, PyObject *kwds)
return NULL;
if (converters) {
int required = PyTuple_GET_SIZE(converters);
int actual = PyTuple_GET_SIZE(callargs);
int required = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(converters),
Py_ssize_t, int);
int actual = Py_SAFE_DOWNCAST(PyTuple_GET_SIZE(callargs),
Py_ssize_t, int);
if ((dict->flags & FUNCFLAG_CDECL) == FUNCFLAG_CDECL) {
/* For cdecl functions, we allow more actual arguments
@ -3679,8 +3688,8 @@ static PyTypeObject Union_Type = {
static int
Array_init(CDataObject *self, PyObject *args, PyObject *kw)
{
int i;
int n;
Py_ssize_t i;
Py_ssize_t n;
if (!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError,
@ -3701,7 +3710,7 @@ static PyObject *
Array_item(PyObject *_self, Py_ssize_t index)
{
CDataObject *self = (CDataObject *)_self;
int offset, size;
Py_ssize_t offset, size;
StgDictObject *stgdict;
@ -3773,7 +3782,7 @@ static int
Array_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
int size, offset;
Py_ssize_t size, offset;
StgDictObject *stgdict;
char *ptr;
@ -3802,7 +3811,7 @@ static int
Array_ass_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
int i, len;
Py_ssize_t i, len;
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
@ -4163,7 +4172,7 @@ static PyObject *
Pointer_item(PyObject *_self, Py_ssize_t index)
{
CDataObject *self = (CDataObject *)_self;
int size;
Py_ssize_t size;
Py_ssize_t offset;
StgDictObject *stgdict, *itemdict;
PyObject *proto;
@ -4194,7 +4203,7 @@ static int
Pointer_ass_item(PyObject *_self, Py_ssize_t index, PyObject *value)
{
CDataObject *self = (CDataObject *)_self;
int size;
Py_ssize_t size;
Py_ssize_t offset;
StgDictObject *stgdict, *itemdict;
PyObject *proto;
@ -4627,9 +4636,10 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
static PyObject *
wstring_at(const wchar_t *ptr, int size)
{
if (size == -1)
size = wcslen(ptr);
return PyUnicode_FromWideChar(ptr, size);
Py_ssize_t ssize = size;
if (ssize == -1)
ssize = wcslen(ptr);
return PyUnicode_FromWideChar(ptr, ssize);
}
#endif
@ -4829,7 +4839,7 @@ PyObject *My_PyUnicode_FromWideChar(register const wchar_t *w,
return (PyObject *)unicode;
}
int My_PyUnicode_AsWideChar(PyUnicodeObject *unicode,
Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *unicode,
register wchar_t *w,
Py_ssize_t size)
{

View file

@ -124,10 +124,10 @@ static void _CallPythonObject(void *mem,
PyObject *converters,
void **pArgs)
{
int i;
Py_ssize_t i;
PyObject *result;
PyObject *arglist = NULL;
int nArgs;
Py_ssize_t nArgs;
#ifdef WITH_THREAD
PyGILState_STATE state = PyGILState_Ensure();
#endif
@ -265,7 +265,7 @@ ffi_info *AllocFunctionCallback(PyObject *callable,
{
int result;
ffi_info *p;
int nArgs, i;
Py_ssize_t nArgs, i;
ffi_abi cc;
nArgs = PySequence_Size(converters);
@ -308,7 +308,8 @@ ffi_info *AllocFunctionCallback(PyObject *callable,
if (is_cdecl == 0)
cc = FFI_STDCALL;
#endif
result = ffi_prep_cif(&p->cif, cc, nArgs,
result = ffi_prep_cif(&p->cif, cc,
Py_SAFE_DOWNCAST(nArgs, Py_ssize_t, int),
GetType(restype),
&p->atypes[0]);
if (result != FFI_OK) {

View file

@ -361,13 +361,13 @@ PyCArg_repr(PyCArgObject *self)
case 'z':
case 'Z':
case 'P':
sprintf(buffer, "<cparam '%c' (%08lx)>",
self->tag, (long)self->value.p);
sprintf(buffer, "<cparam '%c' (%p)>",
self->tag, self->value.p);
break;
default:
sprintf(buffer, "<cparam '%c' at %08lx>",
self->tag, (long)self);
sprintf(buffer, "<cparam '%c' at %p>",
self->tag, self);
break;
}
return PyUnicode_FromString(buffer);
@ -464,7 +464,7 @@ struct argument {
/*
* Convert a single Python object into a PyCArgObject and return it.
*/
static int ConvParam(PyObject *obj, int index, struct argument *pa)
static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
{
StgDictObject *dict;
pa->keep = NULL; /* so we cannot forget it later */
@ -566,7 +566,8 @@ static int ConvParam(PyObject *obj, int index, struct argument *pa)
return result;
}
PyErr_Format(PyExc_TypeError,
"Don't know how to convert parameter %d", index);
"Don't know how to convert parameter %d",
Py_SAFE_DOWNCAST(index, Py_ssize_t, int));
return -1;
}
}
@ -906,7 +907,7 @@ PyObject *_CallProc(PPROC pProc,
PyObject *restype,
PyObject *checker)
{
int i, n, argcount, argtype_count;
Py_ssize_t i, n, argcount, argtype_count;
void *resbuf;
struct argument *args, *pa;
ffi_type **atypes;
@ -996,7 +997,10 @@ PyObject *_CallProc(PPROC pProc,
}
if (-1 == _call_function_pointer(flags, pProc, avalues, atypes,
rtype, resbuf, argcount))
rtype, resbuf,
Py_SAFE_DOWNCAST(argcount,
Py_ssize_t,
int)))
goto cleanup;
#ifdef WORDS_BIGENDIAN
@ -1036,6 +1040,15 @@ PyObject *_CallProc(PPROC pProc,
return retval;
}
static int
_parse_voidp(PyObject *obj, void **address)
{
*address = PyLong_AsVoidPtr(obj);
if (*address == NULL)
return 0;
return 1;
}
#ifdef MS_WIN32
#ifdef _UNICODE
@ -1123,7 +1136,7 @@ Free the handle of an executable previously loaded by LoadLibrary.\n";
static PyObject *free_library(PyObject *self, PyObject *args)
{
void *hMod;
if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":FreeLibrary", &hMod))
if (!PyArg_ParseTuple(args, "O&:FreeLibrary", &_parse_voidp, &hMod))
return NULL;
if (!FreeLibrary((HMODULE)hMod))
return PyErr_SetFromWindowsErr(GetLastError());
@ -1246,7 +1259,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args)
{
void *handle;
if (!PyArg_ParseTuple(args, PY_VOID_P_CODE ":dlclose", &handle))
if (!PyArg_ParseTuple(args, "O&:dlclose", &_parse_voidp, &handle))
return NULL;
if (dlclose(handle)) {
PyErr_SetString(PyExc_OSError,
@ -1263,7 +1276,8 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args)
void *handle;
void *ptr;
if (!PyArg_ParseTuple(args, PY_VOID_P_CODE "s:dlsym", &handle, &name))
if (!PyArg_ParseTuple(args, "O&s:dlsym",
&_parse_voidp, &handle, &name))
return NULL;
ptr = ctypes_dlsym((void*)handle, name);
if (!ptr) {
@ -1288,8 +1302,8 @@ call_function(PyObject *self, PyObject *args)
PyObject *result;
if (!PyArg_ParseTuple(args,
PY_VOID_P_CODE "O!",
&func,
"O&O!",
&_parse_voidp, &func,
&PyTuple_Type, &arguments))
return NULL;
@ -1319,8 +1333,8 @@ call_cdeclfunction(PyObject *self, PyObject *args)
PyObject *result;
if (!PyArg_ParseTuple(args,
PY_VOID_P_CODE "O!",
&func,
"O&O!",
&_parse_voidp, &func,
&PyTuple_Type, &arguments))
return NULL;
@ -1352,10 +1366,10 @@ sizeof_func(PyObject *self, PyObject *obj)
dict = PyType_stgdict(obj);
if (dict)
return PyInt_FromLong(dict->size);
return PyInt_FromSsize_t(dict->size);
if (CDataObject_Check(obj))
return PyInt_FromLong(((CDataObject *)obj)->b_size);
return PyInt_FromSsize_t(((CDataObject *)obj)->b_size);
PyErr_SetString(PyExc_TypeError,
"this type has no size");
return NULL;
@ -1373,11 +1387,11 @@ align_func(PyObject *self, PyObject *obj)
dict = PyType_stgdict(obj);
if (dict)
return PyInt_FromLong(dict->align);
return PyInt_FromSsize_t(dict->align);
dict = PyObject_stgdict(obj);
if (dict)
return PyInt_FromLong(dict->align);
return PyInt_FromSsize_t(dict->align);
PyErr_SetString(PyExc_TypeError,
"no alignment info");

View file

@ -35,14 +35,14 @@ CField_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
* prev_desc points to the type of the previous bitfield, if any.
*/
PyObject *
CField_FromDesc(PyObject *desc, int index,
int *pfield_size, int bitsize, int *pbitofs,
int *psize, int *poffset, int *palign,
CField_FromDesc(PyObject *desc, Py_ssize_t index,
Py_ssize_t *pfield_size, int bitsize, int *pbitofs,
Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign,
int pack, int big_endian)
{
CFieldObject *self;
PyObject *proto;
int size, align, length;
Py_ssize_t size, align, length;
SETFUNC setfunc = NULL;
GETFUNC getfunc = NULL;
StgDictObject *dict;
@ -147,7 +147,7 @@ CField_FromDesc(PyObject *desc, int index,
else
align = dict->align;
if (align && *poffset % align) {
int delta = align - (*poffset % align);
Py_ssize_t delta = align - (*poffset % align);
*psize += delta;
*poffset += delta;
}
@ -220,21 +220,13 @@ CField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
static PyObject *
CField_get_offset(PyObject *self, void *data)
{
#if (PY_VERSION_HEX < 0x02050000)
return PyInt_FromLong(((CFieldObject *)self)->offset);
#else
return PyInt_FromSsize_t(((CFieldObject *)self)->offset);
#endif
}
static PyObject *
CField_get_size(PyObject *self, void *data)
{
#if (PY_VERSION_HEX < 0x02050000)
return PyInt_FromLong(((CFieldObject *)self)->size);
#else
return PyInt_FromSsize_t(((CFieldObject *)self)->size);
#endif
}
static PyGetSetDef CField_getset[] = {
@ -268,8 +260,8 @@ static PyObject *
CField_repr(CFieldObject *self)
{
PyObject *result;
int bits = self->size >> 16;
int size = self->size & 0xFFFF;
Py_ssize_t bits = self->size >> 16;
Py_ssize_t size = self->size & 0xFFFF;
const char *name;
name = ((PyTypeObject *)self->proto)->tp_name;
@ -279,7 +271,7 @@ CField_repr(CFieldObject *self)
#if (PY_VERSION_HEX < 0x02050000)
"<Field type=%s, ofs=%d:%d, bits=%d>",
#else
"<Field type=%s, ofs=%zd:%d, bits=%d>",
"<Field type=%s, ofs=%zd:%zd, bits=%zd>",
#endif
name, self->offset, size, bits);
else
@ -287,7 +279,7 @@ CField_repr(CFieldObject *self)
#if (PY_VERSION_HEX < 0x02050000)
"<Field type=%s, ofs=%d, size=%d>",
#else
"<Field type=%s, ofs=%zd, size=%d>",
"<Field type=%s, ofs=%zd, size=%zd>",
#endif
name, self->offset, size);
return result;
@ -519,7 +511,7 @@ get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
*/
static PyObject *
b_set(void *ptr, PyObject *value, unsigned size)
b_set(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
if (get_long(value, &val) < 0)
@ -530,7 +522,7 @@ b_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
b_get(void *ptr, unsigned size)
b_get(void *ptr, Py_ssize_t size)
{
signed char val = *(signed char *)ptr;
GET_BITFIELD(val, size);
@ -538,7 +530,7 @@ b_get(void *ptr, unsigned size)
}
static PyObject *
B_set(void *ptr, PyObject *value, unsigned size)
B_set(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
if (get_ulong(value, &val) < 0)
@ -550,7 +542,7 @@ B_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
B_get(void *ptr, unsigned size)
B_get(void *ptr, Py_ssize_t size)
{
unsigned char val = *(unsigned char *)ptr;
GET_BITFIELD(val, size);
@ -558,7 +550,7 @@ B_get(void *ptr, unsigned size)
}
static PyObject *
h_set(void *ptr, PyObject *value, unsigned size)
h_set(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
short x;
@ -572,7 +564,7 @@ h_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
h_set_sw(void *ptr, PyObject *value, unsigned size)
h_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
short field;
@ -587,7 +579,7 @@ h_set_sw(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
h_get(void *ptr, unsigned size)
h_get(void *ptr, Py_ssize_t size)
{
short val;
memcpy(&val, ptr, sizeof(val));
@ -596,7 +588,7 @@ h_get(void *ptr, unsigned size)
}
static PyObject *
h_get_sw(void *ptr, unsigned size)
h_get_sw(void *ptr, Py_ssize_t size)
{
short val;
memcpy(&val, ptr, sizeof(val));
@ -606,7 +598,7 @@ h_get_sw(void *ptr, unsigned size)
}
static PyObject *
H_set(void *ptr, PyObject *value, unsigned size)
H_set(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned short x;
@ -619,7 +611,7 @@ H_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
H_set_sw(void *ptr, PyObject *value, unsigned size)
H_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned short field;
@ -635,7 +627,7 @@ H_set_sw(void *ptr, PyObject *value, unsigned size)
static PyObject *
H_get(void *ptr, unsigned size)
H_get(void *ptr, Py_ssize_t size)
{
unsigned short val;
memcpy(&val, ptr, sizeof(val));
@ -644,7 +636,7 @@ H_get(void *ptr, unsigned size)
}
static PyObject *
H_get_sw(void *ptr, unsigned size)
H_get_sw(void *ptr, Py_ssize_t size)
{
unsigned short val;
memcpy(&val, ptr, sizeof(val));
@ -654,7 +646,7 @@ H_get_sw(void *ptr, unsigned size)
}
static PyObject *
i_set(void *ptr, PyObject *value, unsigned size)
i_set(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
int x;
@ -667,7 +659,7 @@ i_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
i_set_sw(void *ptr, PyObject *value, unsigned size)
i_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
int field;
@ -683,7 +675,7 @@ i_set_sw(void *ptr, PyObject *value, unsigned size)
static PyObject *
i_get(void *ptr, unsigned size)
i_get(void *ptr, Py_ssize_t size)
{
int val;
memcpy(&val, ptr, sizeof(val));
@ -692,7 +684,7 @@ i_get(void *ptr, unsigned size)
}
static PyObject *
i_get_sw(void *ptr, unsigned size)
i_get_sw(void *ptr, Py_ssize_t size)
{
int val;
memcpy(&val, ptr, sizeof(val));
@ -704,7 +696,7 @@ i_get_sw(void *ptr, unsigned size)
#ifdef MS_WIN32
/* short BOOL - VARIANT_BOOL */
static PyObject *
vBOOL_set(void *ptr, PyObject *value, unsigned size)
vBOOL_set(void *ptr, PyObject *value, Py_ssize_t size)
{
switch (PyObject_IsTrue(value)) {
case -1:
@ -719,7 +711,7 @@ vBOOL_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
vBOOL_get(void *ptr, unsigned size)
vBOOL_get(void *ptr, Py_ssize_t size)
{
return PyBool_FromLong((long)*(short int *)ptr);
}
@ -734,7 +726,7 @@ vBOOL_get(void *ptr, unsigned size)
#endif
static PyObject *
t_set(void *ptr, PyObject *value, unsigned size)
t_set(void *ptr, PyObject *value, Py_ssize_t size)
{
switch (PyObject_IsTrue(value)) {
case -1:
@ -749,13 +741,13 @@ t_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
t_get(void *ptr, unsigned size)
t_get(void *ptr, Py_ssize_t size)
{
return PyBool_FromLong((long)*(BOOL_TYPE *)ptr);
}
static PyObject *
I_set(void *ptr, PyObject *value, unsigned size)
I_set(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned int x;
@ -768,7 +760,7 @@ I_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
I_set_sw(void *ptr, PyObject *value, unsigned size)
I_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned int field;
@ -783,7 +775,7 @@ I_set_sw(void *ptr, PyObject *value, unsigned size)
static PyObject *
I_get(void *ptr, unsigned size)
I_get(void *ptr, Py_ssize_t size)
{
unsigned int val;
memcpy(&val, ptr, sizeof(val));
@ -792,7 +784,7 @@ I_get(void *ptr, unsigned size)
}
static PyObject *
I_get_sw(void *ptr, unsigned size)
I_get_sw(void *ptr, Py_ssize_t size)
{
unsigned int val;
memcpy(&val, ptr, sizeof(val));
@ -802,7 +794,7 @@ I_get_sw(void *ptr, unsigned size)
}
static PyObject *
l_set(void *ptr, PyObject *value, unsigned size)
l_set(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
long x;
@ -815,7 +807,7 @@ l_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
l_set_sw(void *ptr, PyObject *value, unsigned size)
l_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
long val;
long field;
@ -831,7 +823,7 @@ l_set_sw(void *ptr, PyObject *value, unsigned size)
static PyObject *
l_get(void *ptr, unsigned size)
l_get(void *ptr, Py_ssize_t size)
{
long val;
memcpy(&val, ptr, sizeof(val));
@ -840,7 +832,7 @@ l_get(void *ptr, unsigned size)
}
static PyObject *
l_get_sw(void *ptr, unsigned size)
l_get_sw(void *ptr, Py_ssize_t size)
{
long val;
memcpy(&val, ptr, sizeof(val));
@ -850,7 +842,7 @@ l_get_sw(void *ptr, unsigned size)
}
static PyObject *
L_set(void *ptr, PyObject *value, unsigned size)
L_set(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned long x;
@ -863,7 +855,7 @@ L_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
L_set_sw(void *ptr, PyObject *value, unsigned size)
L_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned long val;
unsigned long field;
@ -879,7 +871,7 @@ L_set_sw(void *ptr, PyObject *value, unsigned size)
static PyObject *
L_get(void *ptr, unsigned size)
L_get(void *ptr, Py_ssize_t size)
{
unsigned long val;
memcpy(&val, ptr, sizeof(val));
@ -888,7 +880,7 @@ L_get(void *ptr, unsigned size)
}
static PyObject *
L_get_sw(void *ptr, unsigned size)
L_get_sw(void *ptr, Py_ssize_t size)
{
unsigned long val;
memcpy(&val, ptr, sizeof(val));
@ -899,7 +891,7 @@ L_get_sw(void *ptr, unsigned size)
#ifdef HAVE_LONG_LONG
static PyObject *
q_set(void *ptr, PyObject *value, unsigned size)
q_set(void *ptr, PyObject *value, Py_ssize_t size)
{
PY_LONG_LONG val;
PY_LONG_LONG x;
@ -912,7 +904,7 @@ q_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
q_set_sw(void *ptr, PyObject *value, unsigned size)
q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
PY_LONG_LONG val;
PY_LONG_LONG field;
@ -927,7 +919,7 @@ q_set_sw(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
q_get(void *ptr, unsigned size)
q_get(void *ptr, Py_ssize_t size)
{
PY_LONG_LONG val;
memcpy(&val, ptr, sizeof(val));
@ -936,7 +928,7 @@ q_get(void *ptr, unsigned size)
}
static PyObject *
q_get_sw(void *ptr, unsigned size)
q_get_sw(void *ptr, Py_ssize_t size)
{
PY_LONG_LONG val;
memcpy(&val, ptr, sizeof(val));
@ -946,7 +938,7 @@ q_get_sw(void *ptr, unsigned size)
}
static PyObject *
Q_set(void *ptr, PyObject *value, unsigned size)
Q_set(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned PY_LONG_LONG val;
unsigned PY_LONG_LONG x;
@ -959,7 +951,7 @@ Q_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
Q_set_sw(void *ptr, PyObject *value, unsigned size)
Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
unsigned PY_LONG_LONG val;
unsigned PY_LONG_LONG field;
@ -974,7 +966,7 @@ Q_set_sw(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
Q_get(void *ptr, unsigned size)
Q_get(void *ptr, Py_ssize_t size)
{
unsigned PY_LONG_LONG val;
memcpy(&val, ptr, sizeof(val));
@ -983,7 +975,7 @@ Q_get(void *ptr, unsigned size)
}
static PyObject *
Q_get_sw(void *ptr, unsigned size)
Q_get_sw(void *ptr, Py_ssize_t size)
{
unsigned PY_LONG_LONG val;
memcpy(&val, ptr, sizeof(val));
@ -1000,7 +992,7 @@ Q_get_sw(void *ptr, unsigned size)
static PyObject *
d_set(void *ptr, PyObject *value, unsigned size)
d_set(void *ptr, PyObject *value, Py_ssize_t size)
{
double x;
@ -1016,7 +1008,7 @@ d_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
d_get(void *ptr, unsigned size)
d_get(void *ptr, Py_ssize_t size)
{
double val;
memcpy(&val, ptr, sizeof(val));
@ -1024,7 +1016,7 @@ d_get(void *ptr, unsigned size)
}
static PyObject *
d_set_sw(void *ptr, PyObject *value, unsigned size)
d_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
double x;
@ -1046,7 +1038,7 @@ d_set_sw(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
d_get_sw(void *ptr, unsigned size)
d_get_sw(void *ptr, Py_ssize_t size)
{
#ifdef WORDS_BIGENDIAN
return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 1));
@ -1056,7 +1048,7 @@ d_get_sw(void *ptr, unsigned size)
}
static PyObject *
f_set(void *ptr, PyObject *value, unsigned size)
f_set(void *ptr, PyObject *value, Py_ssize_t size)
{
float x;
@ -1072,7 +1064,7 @@ f_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
f_get(void *ptr, unsigned size)
f_get(void *ptr, Py_ssize_t size)
{
float val;
memcpy(&val, ptr, sizeof(val));
@ -1080,7 +1072,7 @@ f_get(void *ptr, unsigned size)
}
static PyObject *
f_set_sw(void *ptr, PyObject *value, unsigned size)
f_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
float x;
@ -1102,7 +1094,7 @@ f_set_sw(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
f_get_sw(void *ptr, unsigned size)
f_get_sw(void *ptr, Py_ssize_t size)
{
#ifdef WORDS_BIGENDIAN
return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 1));
@ -1122,7 +1114,7 @@ f_get_sw(void *ptr, unsigned size)
Py_DECREF on destruction. Maybe only when b_needsfree is non-zero.
*/
static PyObject *
O_get(void *ptr, unsigned size)
O_get(void *ptr, Py_ssize_t size)
{
PyObject *ob = *(PyObject **)ptr;
if (ob == NULL) {
@ -1137,7 +1129,7 @@ O_get(void *ptr, unsigned size)
}
static PyObject *
O_set(void *ptr, PyObject *value, unsigned size)
O_set(void *ptr, PyObject *value, Py_ssize_t size)
{
/* Hm, does the memory block need it's own refcount or not? */
*(PyObject **)ptr = value;
@ -1147,7 +1139,7 @@ O_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
c_set(void *ptr, PyObject *value, unsigned size)
c_set(void *ptr, PyObject *value, Py_ssize_t size)
{
if (!PyString_Check(value) || (1 != PyString_Size(value))) {
PyErr_Format(PyExc_TypeError,
@ -1160,7 +1152,7 @@ c_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
c_get(void *ptr, unsigned size)
c_get(void *ptr, Py_ssize_t size)
{
return PyString_FromStringAndSize((char *)ptr, 1);
}
@ -1168,9 +1160,9 @@ c_get(void *ptr, unsigned size)
#ifdef CTYPES_UNICODE
/* u - a single wchar_t character */
static PyObject *
u_set(void *ptr, PyObject *value, unsigned size)
u_set(void *ptr, PyObject *value, Py_ssize_t size)
{
int len;
Py_ssize_t len;
if (PyString_Check(value)) {
value = PyUnicode_FromEncodedObject(value,
@ -1202,17 +1194,17 @@ u_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
u_get(void *ptr, unsigned size)
u_get(void *ptr, Py_ssize_t size)
{
return PyUnicode_FromWideChar((wchar_t *)ptr, 1);
}
/* U - a unicode string */
static PyObject *
U_get(void *ptr, unsigned size)
U_get(void *ptr, Py_ssize_t size)
{
PyObject *result;
unsigned int len;
Py_ssize_t len;
Py_UNICODE *p;
size /= sizeof(wchar_t); /* we count character units here, not bytes */
@ -1240,9 +1232,9 @@ U_get(void *ptr, unsigned size)
}
static PyObject *
U_set(void *ptr, PyObject *value, unsigned length)
U_set(void *ptr, PyObject *value, Py_ssize_t length)
{
unsigned int size;
Py_ssize_t size;
/* It's easier to calculate in characters than in bytes */
length /= sizeof(wchar_t);
@ -1263,7 +1255,11 @@ U_set(void *ptr, PyObject *value, unsigned length)
size = PyUnicode_GET_SIZE(value);
if (size > length) {
PyErr_Format(PyExc_ValueError,
#if (PY_VERSION_HEX < 0x02050000)
"string too long (%d, maximum length %d)",
#else
"string too long (%zd, maximum length %zd)",
#endif
size, length);
Py_DECREF(value);
return NULL;
@ -1277,9 +1273,10 @@ U_set(void *ptr, PyObject *value, unsigned length)
#endif
static PyObject *
s_get(void *ptr, unsigned size)
s_get(void *ptr, Py_ssize_t size)
{
PyObject *result;
size_t slen;
result = PyString_FromString((char *)ptr);
if (!result)
@ -1287,7 +1284,8 @@ s_get(void *ptr, unsigned size)
/* chop off at the first NUL character, if any.
* On error, result will be deallocated and set to NULL.
*/
size = min(size, strlen(PyString_AS_STRING(result)));
slen = strlen(PyString_AS_STRING(result));
size = min(size, (Py_ssize_t)slen);
if (result->ob_refcnt == 1) {
/* shorten the result */
_PyString_Resize(&result, size);
@ -1298,10 +1296,10 @@ s_get(void *ptr, unsigned size)
}
static PyObject *
s_set(void *ptr, PyObject *value, unsigned length)
s_set(void *ptr, PyObject *value, Py_ssize_t length)
{
char *data;
unsigned size;
Py_ssize_t size;
data = PyString_AsString(value);
if (!data)
@ -1314,7 +1312,11 @@ s_set(void *ptr, PyObject *value, unsigned length)
++size;
} else if (size > length) {
PyErr_Format(PyExc_ValueError,
#if (PY_VERSION_HEX < 0x02050000)
"string too long (%d, maximum length %d)",
#else
"string too long (%zd, maximum length %zd)",
#endif
size, length);
return NULL;
}
@ -1324,7 +1326,7 @@ s_set(void *ptr, PyObject *value, unsigned length)
}
static PyObject *
z_set(void *ptr, PyObject *value, unsigned size)
z_set(void *ptr, PyObject *value, Py_ssize_t size)
{
if (value == Py_None) {
*(char **)ptr = NULL;
@ -1358,7 +1360,7 @@ z_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
z_get(void *ptr, unsigned size)
z_get(void *ptr, Py_ssize_t size)
{
/* XXX What about invalid pointers ??? */
if (*(void **)ptr) {
@ -1379,7 +1381,7 @@ z_get(void *ptr, unsigned size)
#ifdef CTYPES_UNICODE
static PyObject *
Z_set(void *ptr, PyObject *value, unsigned size)
Z_set(void *ptr, PyObject *value, Py_ssize_t size)
{
if (value == Py_None) {
*(wchar_t **)ptr = NULL;
@ -1447,7 +1449,7 @@ Z_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
Z_get(void *ptr, unsigned size)
Z_get(void *ptr, Py_ssize_t size)
{
wchar_t *p;
p = *(wchar_t **)ptr;
@ -1470,7 +1472,7 @@ Z_get(void *ptr, unsigned size)
#ifdef MS_WIN32
static PyObject *
BSTR_set(void *ptr, PyObject *value, unsigned size)
BSTR_set(void *ptr, PyObject *value, Py_ssize_t size)
{
BSTR bstr;
@ -1494,8 +1496,13 @@ BSTR_set(void *ptr, PyObject *value, unsigned size)
/* create a BSTR from value */
if (value) {
Py_ssize_t size = PyUnicode_GET_SIZE(value);
if ((unsigned) size != size) {
PyErr_SetString(PyExc_ValueError, "String too long for BSTR");
return NULL;
}
bstr = SysAllocStringLen(PyUnicode_AS_UNICODE(value),
PyUnicode_GET_SIZE(value));
(unsigned)size);
Py_DECREF(value);
} else
bstr = NULL;
@ -1513,7 +1520,7 @@ BSTR_set(void *ptr, PyObject *value, unsigned size)
static PyObject *
BSTR_get(void *ptr, unsigned size)
BSTR_get(void *ptr, Py_ssize_t size)
{
BSTR p;
p = *(BSTR *)ptr;
@ -1530,7 +1537,7 @@ BSTR_get(void *ptr, unsigned size)
#endif
static PyObject *
P_set(void *ptr, PyObject *value, unsigned size)
P_set(void *ptr, PyObject *value, Py_ssize_t size)
{
void *v;
if (value == Py_None) {
@ -1563,7 +1570,7 @@ P_set(void *ptr, PyObject *value, unsigned size)
}
static PyObject *
P_get(void *ptr, unsigned size)
P_get(void *ptr, Py_ssize_t size)
{
if (*(void **)ptr == NULL) {
Py_INCREF(Py_None);

View file

@ -4,6 +4,7 @@
#if (PY_VERSION_HEX < 0x02050000)
typedef int Py_ssize_t;
#define PyInt_FromSsize_t PyInt_FromLong
#endif
#ifndef MS_WIN32
@ -23,16 +24,10 @@ typedef int Py_ssize_t;
#define PY_LONG_LONG LONG_LONG
#endif
#if SIZEOF_VOID_P == SIZEOF_LONG
#define PY_VOID_P_CODE "k"
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P == SIZEOF_LONG_LONG)
#define PY_VOID_P_CODE "K"
#endif
typedef struct tagPyCArgObject PyCArgObject;
typedef struct tagCDataObject CDataObject;
typedef PyObject *(* GETFUNC)(void *, unsigned size);
typedef PyObject *(* SETFUNC)(void *, PyObject *value, unsigned size);
typedef PyObject *(* GETFUNC)(void *, Py_ssize_t size);
typedef PyObject *(* SETFUNC)(void *, PyObject *value, Py_ssize_t size);
typedef PyCArgObject *(* PARAMFUNC)(CDataObject *obj);
/* A default buffer in CDataObject, which can be used for small C types. If
@ -137,9 +132,9 @@ extern struct fielddesc *getentry(char *fmt);
extern PyObject *
CField_FromDesc(PyObject *desc, int index,
int *pfield_size, int bitsize, int *pbitofs,
int *psize, int *poffset, int *palign,
CField_FromDesc(PyObject *desc, Py_ssize_t index,
Py_ssize_t *pfield_size, int bitsize, int *pbitofs,
Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign,
int pack, int is_big_endian);
extern PyObject *CData_AtAddress(PyObject *type, void *buf);
@ -310,7 +305,7 @@ struct tagPyCArgObject {
void *p;
} value;
PyObject *obj;
int size; /* for the 'V' tag */
Py_ssize_t size; /* for the 'V' tag */
};
extern PyTypeObject PyCArg_Type;
@ -387,7 +382,7 @@ extern char *conversion_mode_errors;
# define PyUnicode_AsWideChar My_PyUnicode_AsWideChar
extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, Py_ssize_t);
extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t);
extern Py_ssize_t My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t);
#endif

View file

@ -174,7 +174,7 @@ extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
void (*fn)(void));
/*@=declundef@*/
/*@=exportheader@*/
@ -185,13 +185,13 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
void (*fn)(void));
/*@=declundef@*/
/*@=exportheader@*/
#endif /* X86_WIN32 */
void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{
@ -405,7 +405,7 @@ ffi_call_SYSV(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
void (*fn)(void));
#ifdef X86_WIN32
extern void
@ -413,12 +413,12 @@ ffi_call_STDCALL(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
void (*fn)(void));
#endif /* X86_WIN32 */
void
ffi_raw_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *fake_avalue)
{

View file

@ -42,7 +42,7 @@ struct register_args
};
extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
void *raddr, void (*fnaddr)(), unsigned ssecount);
void *raddr, void (*fnaddr)(void), unsigned ssecount);
/* All reference to register classes here is identical to the code in
gcc/config/i386/i386.c. Do *not* change one without the other. */
@ -339,7 +339,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
}
void
ffi_call (ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
enum x86_64_reg_class classes[MAX_CLASSES];
char *stack, *argp;

View file

@ -50,7 +50,7 @@ int
StgDict_clone(StgDictObject *dst, StgDictObject *src)
{
char *d, *s;
int size;
Py_ssize_t size;
StgDict_clear(dst);
PyMem_Free(dst->ffi_type_pointer.elements);
@ -285,13 +285,13 @@ int
StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
{
StgDictObject *stgdict, *basedict;
int len, offset, size, align, i;
int union_size, total_align;
int field_size = 0;
Py_ssize_t len, offset, size, align, i;
Py_ssize_t union_size, total_align;
Py_ssize_t field_size = 0;
int bitofs;
PyObject *isPacked;
int pack = 0;
int ffi_ofs;
Py_ssize_t ffi_ofs;
int big_endian;
/* HACK Alert: I cannot be bothered to fix ctypes.com, so there has to
@ -402,7 +402,11 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
if (dict == NULL) {
Py_DECREF(pair);
PyErr_Format(PyExc_TypeError,
#if (PY_VERSION_HEX < 0x02050000)
"second item in _fields_ tuple (index %d) must be a C type",
#else
"second item in _fields_ tuple (index %zd) must be a C type",
#endif
i);
return -1;
}
@ -480,7 +484,9 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
/* Adjust the size according to the alignment requirements */
size = ((size + total_align - 1) / total_align) * total_align;
stgdict->ffi_type_pointer.alignment = total_align;
stgdict->ffi_type_pointer.alignment = Py_SAFE_DOWNCAST(total_align,
Py_ssize_t,
unsigned short);
stgdict->ffi_type_pointer.size = size;
stgdict->size = size;

View file

@ -243,6 +243,7 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
}
template = PyString_FromString("%s <- %s ->%s\n");
if (!template) {
Py_DECREF(fmt_args);
return NULL;
}
display_str = PyString_Format(template, fmt_args);

View file

@ -287,12 +287,12 @@ PyMODINIT_FUNC init_sqlite3(void)
/*** Create DB-API Exception hierarchy */
if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_StandardError, NULL))) {
if (!(pysqlite_Error = PyErr_NewException(MODULE_NAME ".Error", PyExc_Exception, NULL))) {
goto error;
}
PyDict_SetItemString(dict, "Error", pysqlite_Error);
if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_StandardError, NULL))) {
if (!(pysqlite_Warning = PyErr_NewException(MODULE_NAME ".Warning", PyExc_Exception, NULL))) {
goto error;
}
PyDict_SetItemString(dict, "Warning", pysqlite_Warning);

View file

@ -726,7 +726,7 @@ void print_delta(int test, struct timeval *s, struct timeval *e)
e->tv_sec -=1;
e->tv_usec += 1000000;
}
printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, e->tv_usec);
printf("Test %d: %d.%06ds\n", test, (int)e->tv_sec, (int)e->tv_usec);
}
static PyObject *
@ -884,6 +884,10 @@ typedef struct {
unsigned long ulong_member;
float float_member;
double double_member;
#ifdef HAVE_LONG_LONG
PY_LONG_LONG longlong_member;
unsigned PY_LONG_LONG ulonglong_member;
#endif
} all_structmembers;
typedef struct {
@ -902,23 +906,40 @@ static struct PyMemberDef test_members[] = {
{"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL},
{"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL},
{"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL},
#ifdef HAVE_LONG_LONG
{"T_LONGLONG", T_LONGLONG, offsetof(test_structmembers, structmembers.longlong_member), 0, NULL},
{"T_ULONGLONG", T_ULONGLONG, offsetof(test_structmembers, structmembers.ulonglong_member), 0, NULL},
#endif
{NULL}
};
static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){
static char *keywords[]={"T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT",
"T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", NULL};
"T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE",
#ifdef HAVE_LONG_LONG
"T_LONGLONG", "T_ULONGLONG",
#endif
NULL};
static char *fmt="|bBhHiIlkfd"
#ifdef HAVE_LONG_LONG
"LK"
#endif
;
test_structmembers *ob=PyObject_New(test_structmembers, type);
if (ob==NULL)
return NULL;
memset(&ob->structmembers, 0, sizeof(all_structmembers));
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|bBhHiIlkfd", keywords,
if (!PyArg_ParseTupleAndKeywords(args, kwargs, fmt, keywords,
&ob->structmembers.byte_member, &ob->structmembers.ubyte_member,
&ob->structmembers.short_member, &ob->structmembers.ushort_member,
&ob->structmembers.int_member, &ob->structmembers.uint_member,
&ob->structmembers.long_member, &ob->structmembers.ulong_member,
&ob->structmembers.float_member, &ob->structmembers.double_member)){
&ob->structmembers.float_member, &ob->structmembers.double_member
#ifdef HAVE_LONG_LONG
,&ob->structmembers.longlong_member, &ob->structmembers.ulonglong_member
#endif
)){
Py_DECREF(ob);
return NULL;
}
@ -1001,6 +1022,9 @@ init_testcapi(void)
PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN));
PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX));
PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN));
PyModule_AddObject(m, "LLONG_MAX", PyLong_FromLongLong(PY_LLONG_MAX));
PyModule_AddObject(m, "LLONG_MIN", PyLong_FromLongLong(PY_LLONG_MIN));
PyModule_AddObject(m, "ULLONG_MAX", PyLong_FromUnsignedLongLong(PY_ULLONG_MAX));
PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyInt_FromSsize_t(PY_SSIZE_T_MAX));
PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN));

View file

@ -1220,6 +1220,8 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
cres = NULL;
for (;;) {
int endoffile;
if (sizehint < 0)
cres = PyObject_CallMethod(self->stream,
(char *)method, NULL);
@ -1245,6 +1247,8 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
goto errorexit;
}
endoffile = (PyString_GET_SIZE(cres) == 0);
if (self->pendingsize > 0) {
PyObject *ctr;
char *ctrdata;
@ -1272,7 +1276,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
(MultibyteStatefulDecoderContext *)self, &buf))
goto errorexit;
if (rsize == 0 || sizehint < 0) { /* end of file */
if (endoffile || sizehint < 0) {
if (buf.inbuf < buf.inbuf_end &&
multibytecodec_decerror(self->codec, &self->state,
&buf, self->errors, MBERR_TOOFEW))

View file

@ -20,7 +20,14 @@
#endif
#endif
/* on unix, SVNVERSION is passed on the command line.
* on Windows, the string is interpolated using
* subwcrev.exe
*/
#ifndef SVNVERSION
#define SVNVERSION "$WCRANGE$$WCMODS?M:$"
#endif
const char *
Py_GetBuildInfo(void)
{
@ -39,7 +46,7 @@ _Py_svnversion(void)
{
/* the following string can be modified by subwcrev.exe */
static const char svnversion[] = SVNVERSION;
if (!strstr(svnversion, "$"))
return svnversion; /* it was interpolated */
if (svnversion[0] != '$')
return svnversion; /* it was interpolated, or passed on command line */
return "exported";
}

View file

@ -361,8 +361,11 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
#define BTPROTO_L2CAP BLUETOOTH_PROTO_L2CAP
#define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
#define BTPROTO_HCI BLUETOOTH_PROTO_HCI
#define SOL_HCI SOL_HCI_RAW
#define HCI_FILTER SO_HCI_RAW_FILTER
#define sockaddr_l2 sockaddr_l2cap
#define sockaddr_rc sockaddr_rfcomm
#define hci_dev hci_node
#define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb)
#define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb)
#define _BT_HCI_MEMB(sa, memb) ((sa)->hci_##memb)
@ -4335,10 +4338,10 @@ init_socket(void)
PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
PyModule_AddIntConstant(m, "BTPROTO_HCI", BTPROTO_HCI);
PyModule_AddIntConstant(m, "SOL_HCI", SOL_HCI);
PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP);
PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR);
PyModule_AddIntConstant(m, "HCI_FILTER", HCI_FILTER);
#if !defined(__FreeBSD__)
PyModule_AddIntConstant(m, "HCI_TIME_STAMP", HCI_TIME_STAMP);
PyModule_AddIntConstant(m, "HCI_DATA_DIR", HCI_DATA_DIR);
PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
#endif
PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM);