summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--psycopg/typecast.c9
-rw-r--r--psycopg/typecast_datetime.c10
-rw-r--r--setup.cfg4
-rw-r--r--setup.py2
5 files changed, 25 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index f99137f..d34d261 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,14 @@
-2005-11-03 Federico Di Gregorio <fog@initd.org>
+2005-11-04 Federico Di Gregorio <fog@initd.org>
- * Applied patch from Daniele Varazzo to enablÃeDecimal on Python
+ * psycopg/typecast_datetime.c: now typecast_PYINTERVAL_cast limit the
+ scan to 'len' characters in the string (should fix #65.)
+
+2005-11-03 Federico Di Gregorio <fog@initd.org>
+
+ * Applied patch from Daniele Varazzo to enable Decimal on Python
2.3 when the module is available (run-time check, nice.)
-2005-10-26 Federico Di Gregorio <fog@initd.org>
+2005-10-26 Federico Di Gregorio <fog@initd.org>
* setup.cfg: added include_dirs line for SUSE 9.3.
diff --git a/psycopg/typecast.c b/psycopg/typecast.c
index 7ab8bc5..e627e97 100644
--- a/psycopg/typecast.c
+++ b/psycopg/typecast.c
@@ -38,6 +38,15 @@ skip_until_space(char *s)
return s;
}
+static char *
+skip_until_space2(char *s, int *len)
+{
+ while (*len > 0 && *s && *s != ' ') {
+ s++; (*len)--;
+ }
+ return s;
+}
+
/** include casting objects **/
#include "psycopg/typecast_basic.c"
diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c
index 40c80f3..7f963d9 100644
--- a/psycopg/typecast_datetime.c
+++ b/psycopg/typecast_datetime.c
@@ -89,7 +89,7 @@ typecast_PYDATETIME_cast(char *str, int len, PyObject *curs)
}
else {
- Dprintf("typecast_PYDATETIME_cast: s = %s", str);
+ Dprintf("typecast_PYDATETIME_cast: s = %s", str);
n = sscanf(str, "%d-%d-%d %d:%d:%lf%c%d:%d",
&y, &m, &d, &hh, &mm, &ss, &tzs, &tzh, &tzm);
Dprintf("typecast_PYDATETIME_cast: date parsed, %d components", n);
@@ -172,7 +172,7 @@ typecast_PYINTERVAL_cast(char *str, int len, PyObject *curs)
Dprintf("typecast_PYINTERVAL_cast: s = %s", str);
- while (*str) {
+ while (len-- > 0 && *str) {
switch (*str) {
case '-':
@@ -190,7 +190,7 @@ typecast_PYINTERVAL_cast(char *str, int len, PyObject *curs)
case 'y':
if (part == 0) {
years = (long)(v*sign);
- str = skip_until_space(str);
+ str = skip_until_space2(str, &len);
v = 0.0; sign = 1.0; part = 1;
}
break;
@@ -198,7 +198,7 @@ typecast_PYINTERVAL_cast(char *str, int len, PyObject *curs)
case 'm':
if (part <= 1) {
months = (long)(v*sign);
- str = skip_until_space(str);
+ str = skip_until_space2(str, &len);
v = 0.0; sign = 1.0; part = 2;
}
break;
@@ -206,7 +206,7 @@ typecast_PYINTERVAL_cast(char *str, int len, PyObject *curs)
case 'd':
if (part <= 2) {
days = (long)(v*sign);
- str = skip_until_space(str);
+ str = skip_until_space2(str, &len);
v = 0.0; sign = 1.0; part = 3;
}
break;
diff --git a/setup.cfg b/setup.cfg
index 0bb03d1..4759da1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,8 +7,8 @@ define=PSYCOPG_EXTENSIONS,PSYCOPG_DISPLAY_SIZE,HAVE_PQFREEMEM,HAVE_PQPROTOCOL3
use_pydatetime=1
# Set to 1 if you want to enable "Decimal" type on python 2.3.
-# If the "decimal" module is found in the PYTHONPATH it will be used,
-# else fall back on the float type.
+# If the "decimal" module is found in the PYTHONPATH it will be used, else
+# fall back on the float type.
use_decimal=0
# "include_dirs" is the preferred method for locating postgresql headers,
diff --git a/setup.py b/setup.py
index 3ded6e4..95b489c 100644
--- a/setup.py
+++ b/setup.py
@@ -55,7 +55,7 @@ from distutils.command.build_ext import build_ext
from distutils.sysconfig import get_python_inc
from distutils.ccompiler import get_default_compiler
-PSYCOPG_VERSION = '2.0b5'
+PSYCOPG_VERSION = '2.0b6'
version_flags = []
# to work around older distutil limitations