Changeset 27713 for lang

Show
Ignore:
Timestamp:
01/01/09 05:14:32 (4 years ago)
Author:
tasuku
Message:

* version 0.7
* Added Python 2.4 compatibility. Thanks to Vernon Tang.
* Allow negitive values on optimize and tune methods of pytc.BDB and pytc.HDB. Thanks to Vernon Tang.
* removed unnecessarily links(libz and libm). Thanks to Vernon Tang.

Location:
lang/python/pytc/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/python/pytc/trunk/ChangeLog

    r24694 r27713  
     12008-12-31  Tasuku SUENAGA <gunyarakun@sourceforge.net> 
     2 
     3        * version 0.7 
     4        * Added Python 2.4 compatibility. Thanks to Vernon Tang. 
     5        * Allow negitive values on optimize and tune methods of pytc.BDB and pytc.HDB. Thanks to Vernon Tang. 
     6        * removed unnecessarily links(libz and libm). Thanks to Vernon Tang. 
     7 
    182008-11-22  Tasuku SUENAGA <gunyarakun@sourceforge.net> 
    29 
  • lang/python/pytc/trunk/pytc.c

    r24694 r27713  
    1717#include <tchdb.h> 
    1818#include <tcutil.h> 
     19#include <limits.h> 
     20 
     21#if PY_VERSION_HEX < 0x02050000 
     22typedef inquiry lenfunc; 
     23#endif 
    1924 
    2025/* FIXME: handle error */ 
     
    2732  iter_item 
    2833} itertype; 
     34 
     35static bool 
     36char_bounds(short x) { 
     37  if (x < SCHAR_MIN) { 
     38    PyErr_SetString(PyExc_OverflowError, 
     39    "signed byte integer is less than minimum"); 
     40    return false; 
     41  } else if (x > SCHAR_MAX) { 
     42    PyErr_SetString(PyExc_OverflowError, 
     43    "signed byte integer is greater than maximum"); 
     44    return false; 
     45  } else { 
     46    return true; 
     47  } 
     48} 
    2949 
    3050/* Error Objects */ 
     
    511531  a(PyTCHDB *self, PyObject *args, PyObject *keywds) { \ 
    512532    bool result; \ 
    513     char apow, fpow; \ 
     533    short apow, fpow; \ 
    514534    PY_LONG_LONG bnum; \ 
    515535    unsigned char opts; \ 
    516536    static char *kwlist[] = {"bnum", "apow", "fpow", "opts", NULL}; \ 
    517537  \ 
    518     if (!PyArg_ParseTupleAndKeywords(args, keywds, "LbbB:" #b, kwlist, \ 
     538    if (!PyArg_ParseTupleAndKeywords(args, keywds, "LhhB:" #b, kwlist, \ 
    519539                                     &bnum, &apow, &fpow, &opts)) { \ 
     540      return NULL; \ 
     541    } \ 
     542    if (!(char_bounds(apow) && char_bounds(fpow))) { \ 
    520543      return NULL; \ 
    521544    } \ 
     
    12391262  a(PyTCBDB *self, PyObject *args, PyObject *keywds) { \ 
    12401263    bool result; \ 
    1241     char apow, fpow; \ 
     1264    short apow, fpow; \ 
    12421265    int lmemb, nmemb; \ 
    12431266    PY_LONG_LONG bnum; \ 
     
    12451268    static char *kwlist[] = {"lmemb", "nmemb", "bnum", "apow", "fpow", "opts", NULL}; \ 
    12461269  \ 
    1247     if (!PyArg_ParseTupleAndKeywords(args, keywds, "iiLbbB:" #b, kwlist, \ 
     1270    if (!PyArg_ParseTupleAndKeywords(args, keywds, "iiLhhB:" #b, kwlist, \ 
    12481271                                     &lmemb, &nmemb, &bnum, \ 
    12491272                                     &apow, &fpow, &opts)) { \ 
     1273      return NULL; \ 
     1274    } \ 
     1275    if (!(char_bounds(apow) && char_bounds(fpow))) { \ 
    12501276      return NULL; \ 
    12511277    } \ 
  • lang/python/pytc/trunk/setup.py

    r24694 r27713  
    1818 
    1919ext = Extension('pytc', 
    20                 libraries = ['tokyocabinet', 'z', 'pthread', 'm', 'c'], 
     20                libraries = ['tokyocabinet'], 
    2121                sources = ['pytc.c'], 
    2222                include_dirs = include_dirs, 
     
    2525 
    2626setup(name = 'pytc', 
    27       version = '0.6', 
     27      version = '0.7', 
    2828      description = 'Tokyo Cabinet Python bindings', 
    2929      long_description = '''