Commit 9aad620e authored by Tres Seaver's avatar Tres Seaver

Merge pull request #36 from zopefoundation/fix-appveyor-build

(Try to) fix appveyor build
parents 96e88e11 1879a2af
...@@ -77,6 +77,7 @@ static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;} ...@@ -77,6 +77,7 @@ static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;}
#error "PY_LONG_LONG required but not defined" #error "PY_LONG_LONG required but not defined"
#endif #endif
#ifdef NEED_LONG_LONG_KEYS
static int static int
longlong_check(PyObject *ob) longlong_check(PyObject *ob)
{ {
...@@ -84,15 +85,19 @@ longlong_check(PyObject *ob) ...@@ -84,15 +85,19 @@ longlong_check(PyObject *ob)
return 1; return 1;
if (PyLong_Check(ob)) { if (PyLong_Check(ob)) {
/* check magnitude */ int overflow;
PY_LONG_LONG val = PyLong_AsLongLong(ob); (void)PyLong_AsLongLongAndOverflow(ob, &overflow);
if (overflow)
if (val == -1 && PyErr_Occurred()) goto overflow;
return 0;
return 1; return 1;
} }
return 0; return 0;
overflow:
PyErr_SetString(PyExc_ValueError,
"longlong_check: long integer out of range");
return 0;
} }
#endif
static PyObject * static PyObject *
longlong_as_object(PY_LONG_LONG val) longlong_as_object(PY_LONG_LONG val)
...@@ -101,10 +106,8 @@ longlong_as_object(PY_LONG_LONG val) ...@@ -101,10 +106,8 @@ longlong_as_object(PY_LONG_LONG val)
return PyLong_FromLongLong(val); return PyLong_FromLongLong(val);
return INT_FROM_LONG((long)val); return INT_FROM_LONG((long)val);
} }
#endif
#ifdef NEED_LONG_LONG_KEYS
static int static int
longlong_convert(PyObject *ob, PY_LONG_LONG *value) longlong_convert(PyObject *ob, PY_LONG_LONG *value)
{ {
...@@ -124,18 +127,10 @@ longlong_convert(PyObject *ob, PY_LONG_LONG *value) ...@@ -124,18 +127,10 @@ longlong_convert(PyObject *ob, PY_LONG_LONG *value)
else else
{ {
PY_LONG_LONG val; PY_LONG_LONG val;
#if PY_VERSION_HEX < 0x02070000
/* check magnitude */
val = PyLong_AsLongLong(ob);
if (val == -1 && PyErr_Occurred())
goto overflow;
#else
int overflow; int overflow;
val = PyLong_AsLongLongAndOverflow(ob, &overflow); val = PyLong_AsLongLongAndOverflow(ob, &overflow);
if (overflow) if (overflow)
goto overflow; goto overflow;
#endif
(*value) = val; (*value) = val;
return 1; return 1;
} }
...@@ -143,7 +138,7 @@ overflow: ...@@ -143,7 +138,7 @@ overflow:
PyErr_SetString(PyExc_ValueError, "long integer out of range"); PyErr_SetString(PyExc_ValueError, "long integer out of range");
return 0; return 0;
} }
#endif #endif /* NEED_LONG_LONG_SUPPORT */
/* Various kinds of BTree and Bucket structs are instances of /* Various kinds of BTree and Bucket structs are instances of
......
...@@ -7,14 +7,10 @@ ...@@ -7,14 +7,10 @@
#define VALUE_PARSE "L" #define VALUE_PARSE "L"
#define COPY_VALUE_TO_OBJECT(O, K) O=longlong_as_object(K) #define COPY_VALUE_TO_OBJECT(O, K) O=longlong_as_object(K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \ #define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
if (INT_CHECK(ARG)) TARGET=INT_AS_LONG(ARG); else \ if (!longlong_convert((ARG), &TARGET)) \
if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \ { \
if (PyLong_Check(ARG)) { \ (STATUS)=0; (TARGET)=0; \
PyErr_SetString(PyExc_ValueError, "long integer out of range"); \ }
(STATUS)=0; (TARGET)=0; } \
else { \
PyErr_SetString(PyExc_TypeError, "expected integer value"); \
(STATUS)=0; (TARGET)=0; }
#else #else
#define VALUE_TYPE int #define VALUE_TYPE int
#define VALUE_PARSE "i" #define VALUE_PARSE "i"
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
4.3.0 (TBD) 4.3.0 (TBD)
----------- -----------
- Fix unexpected ``OverflowError`` when passing 64bit values to long
keys / values on Win64. See:
https://github.com/zopefoundation/BTrees/issues/32
- When testing ``PURE_PYTHON`` environments under ``tox``, avoid poisoning - When testing ``PURE_PYTHON`` environments under ``tox``, avoid poisoning
the user's global wheel cache. the user's global wheel cache.
......
environment:
password:
secure: RtpeKCle25vCixaUcJBu6Q==
matrix:
- python : 27
- python : 27-x64
- python : 33
- python : 33-x64
- python : 34
- python : 34-x64
- python : 35
- python : 35-x64
install:
- "SET PATH=C:\\Python%PYTHON%;c:\\Python%PYTHON%\\scripts;%PATH%"
- echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
- pip install -e .
build: false
test_script:
- python setup.py -q test -q
on_success:
- echo Build succesful!
deploy_script:
- echo [distutils] > %USERPROFILE%\\.pypirc
- echo index-servers = >> %USERPROFILE%\\.pypirc
- echo pypi >> %USERPROFILE%\\.pypirc
- echo [pypi] >> %USERPROFILE%\\.pypirc
- echo repository=https://pypi.python.org/pypi >> %USERPROFILE%\\.pypirc
- echo username=zope.wheelbuilder >> %USERPROFILE%\\.pypirc
- echo password=%password% >> %USERPROFILE%\\.pypirc
- set HOME=%USERPROFILE%
- pip install wheel twine
- ps: if($env:APPVEYOR_REPO_TAG -eq $TRUE) { python -W ignore setup.py bdist_wheel bdist_egg; twine upload dist/* }
deploy : on
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment