aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulano <nulano@nulano.eu>2020-10-14 00:41:37 +0100
committernulano <nulano@nulano.eu>2020-10-14 00:41:37 +0100
commit5c0f9959cb9a202659ec9b0dfa851ef0c6e2e3b2 (patch)
treede5507c452b7c5b648badab9a244455f8c8cc0b9 /lib_pypy
parentadd some missing includes to _cffi_backend/copy_includes.py (diff)
parentsort the tuple of wanted names (diff)
downloadpypy-5c0f9959cb9a202659ec9b0dfa851ef0c6e2e3b2.tar.gz
pypy-5c0f9959cb9a202659ec9b0dfa851ef0c6e2e3b2.tar.bz2
pypy-5c0f9959cb9a202659ec9b0dfa851ef0c6e2e3b2.zip
Merge
Diffstat (limited to 'lib_pypy')
-rw-r--r--lib_pypy/_audioop_build.py23
-rw-r--r--lib_pypy/_sqlite3.py2
-rw-r--r--lib_pypy/_tkinter/tclobj.py1
3 files changed, 16 insertions, 10 deletions
diff --git a/lib_pypy/_audioop_build.py b/lib_pypy/_audioop_build.py
index 88d67d9c4b..043ea849c3 100644
--- a/lib_pypy/_audioop_build.py
+++ b/lib_pypy/_audioop_build.py
@@ -313,11 +313,18 @@ static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x7FFFFFFF-1};
static int
fbound(double val, double minval, double maxval)
{
- if (val > maxval)
+ if (val > maxval) {
val = maxval;
- else if (val < minval + 1)
+ }
+ else if (val < minval + 1.0) {
val = minval;
- return val;
+ }
+
+ /* Round towards minus infinity (-inf) */
+ val = floor(val);
+
+ /* Cast double to integer: round towards zero */
+ return (int)val;
}
static int
@@ -409,11 +416,11 @@ void tostereo(char* rv, char* cp, size_t len, int size,
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
else if ( size == 4 ) val = (int)*LONGP(cp, i);
- fval = (double)val*fac1;
- val1 = (int)floor(fbound(fval, minval, maxval));
+ fval = (double)val * fac1;
+ val1 = fbound(fval, minval, maxval);
- fval = (double)val*fac2;
- val2 = (int)floor(fbound(fval, minval, maxval));
+ fval = (double)val * fac2;
+ val2 = fbound(fval, minval, maxval);
if ( size == 1 ) *CHARP(ncp, i*2) = (signed char)val1;
else if ( size == 2 ) *SHORTP(ncp, i*2) = (short)val1;
@@ -454,7 +461,7 @@ void add(char* rv, char* cp1, char* cp2, size_t len1, int size)
else {
double fval = (double)val1 + (double)val2;
/* truncate in case of overflow */
- newval = (int)floor(fbound(fval, minval, maxval));
+ newval = fbound(fval, minval, maxval);
}
if ( size == 1 ) *CHARP(ncp, i) = (signed char)newval;
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
index a0e6d8e1b8..16c7f38197 100644
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -291,7 +291,7 @@ class Connection(object):
raise ProgrammingError(
"SQLite objects created in a thread can only be used in that "
"same thread. The object was created in thread id %d and this "
- "is thread id %d" % (self.__thread_ident, _thread_get_ident()))
+ "is thread id %d." % (self.__thread_ident, _thread_get_ident()))
def _check_thread_wrap(func):
@wraps(func)
diff --git a/lib_pypy/_tkinter/tclobj.py b/lib_pypy/_tkinter/tclobj.py
index 483d1a1023..3a5c599111 100644
--- a/lib_pypy/_tkinter/tclobj.py
+++ b/lib_pypy/_tkinter/tclobj.py
@@ -182,7 +182,6 @@ def AsObj(value):
inbuf = tkffi.cast("Tcl_UniChar*", buf)
return tklib.Tcl_NewUnicodeObj(inbuf, len(encoded)/2)
if isinstance(value, TclObject):
- tklib.Tcl_IncrRefCount(value._value)
return value._value
return AsObj(str(value))