Author: Maciej Fijalkowski <[email protected]>
Branch: release-2.0-beta2
Changeset: r63004:b330a6e08a7e
Date: 2013-04-04 10:46 +0200
http://bitbucket.org/pypy/pypy/changeset/b330a6e08a7e/
Log: merge default
diff --git a/lib-python/2.7/distutils/command/install.py
b/lib-python/2.7/distutils/command/install.py
--- a/lib-python/2.7/distutils/command/install.py
+++ b/lib-python/2.7/distutils/command/install.py
@@ -474,7 +474,8 @@
def select_scheme (self, name):
# it's the caller's problem if they supply a bad name!
- if hasattr(sys, 'pypy_version_info'):
+ if hasattr(sys, 'pypy_version_info') and not (
+ name.endswith('_user') or name.endswith('_home')):
name = 'pypy'
scheme = INSTALL_SCHEMES[name]
for key in SCHEME_KEYS:
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -96,6 +96,9 @@
else:
_config_vars = {}
+ _config_vars['prefix'] = PREFIX
+ _config_vars['exec_prefix'] = EXEC_PREFIX
+
if args:
vals = []
for name in args:
diff --git a/lib-python/2.7/distutils/tests/test_install.py
b/lib-python/2.7/distutils/tests/test_install.py
--- a/lib-python/2.7/distutils/tests/test_install.py
+++ b/lib-python/2.7/distutils/tests/test_install.py
@@ -4,7 +4,6 @@
import sys
import unittest
import site
-from test import test_support
from test.test_support import captured_stdout, run_unittest
@@ -57,15 +56,14 @@
expected = os.path.normpath(expected)
self.assertEqual(got, expected)
- if test_support.check_impl_detail():
- libdir = os.path.join(destination, "lib", "python")
- check_path(cmd.install_lib, libdir)
- check_path(cmd.install_platlib, libdir)
- check_path(cmd.install_purelib, libdir)
- check_path(cmd.install_headers,
- os.path.join(destination, "include", "python",
"foopkg"))
- check_path(cmd.install_scripts, os.path.join(destination, "bin"))
- check_path(cmd.install_data, destination)
+ libdir = os.path.join(destination, "lib", "python")
+ check_path(cmd.install_lib, libdir)
+ check_path(cmd.install_platlib, libdir)
+ check_path(cmd.install_purelib, libdir)
+ check_path(cmd.install_headers,
+ os.path.join(destination, "include", "python", "foopkg"))
+ check_path(cmd.install_scripts, os.path.join(destination, "bin"))
+ check_path(cmd.install_data, destination)
def test_user_site(self):
# site.USER_SITE was introduced in 2.6
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -1328,7 +1328,7 @@
def tigetstr(capname):
_ensure_initialised_setupterm()
val = lib.tigetstr(capname)
- if val in (0, -1, ffi.NULL):
+ if int(ffi.cast("intptr_t", val)) in (0, -1):
return None
return ffi.string(val)
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -145,6 +145,7 @@
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
int sqlite3_finalize(sqlite3_stmt *pStmt);
+int sqlite3_data_count(sqlite3_stmt *pStmt);
int sqlite3_column_count(sqlite3_stmt *pStmt);
const char *sqlite3_column_name(sqlite3_stmt*, int N);
int sqlite3_get_autocommit(sqlite3*);
@@ -308,7 +309,7 @@
PARSE_DECLTYPES = 2
# SQLite version information
-sqlite_version = _ffi.string(_lib.sqlite3_libversion())
+sqlite_version = str(_ffi.string(_lib.sqlite3_libversion()).decode('ascii'))
class Error(StandardError):
@@ -580,9 +581,8 @@
def _begin(self):
statement_star = _ffi.new('sqlite3_stmt **')
- next_char = _ffi.new('char **')
ret = _lib.sqlite3_prepare_v2(self._db, self.__begin_statement, -1,
- statement_star, next_char)
+ statement_star, _ffi.NULL)
try:
if ret != _lib.SQLITE_OK:
raise self._get_exception(ret)
@@ -602,9 +602,8 @@
self.__do_all_statements(Statement._reset, False)
statement_star = _ffi.new('sqlite3_stmt **')
- next_char = _ffi.new('char **')
ret = _lib.sqlite3_prepare_v2(self._db, b"COMMIT", -1,
- statement_star, next_char)
+ statement_star, _ffi.NULL)
try:
if ret != _lib.SQLITE_OK:
raise self._get_exception(ret)
@@ -624,9 +623,8 @@
self.__do_all_statements(Statement._reset, True)
statement_star = _ffi.new('sqlite3_stmt **')
- next_char = _ffi.new('char **')
ret = _lib.sqlite3_prepare_v2(self._db, b"ROLLBACK", -1,
- statement_star, next_char)
+ statement_star, _ffi.NULL)
try:
if ret != _lib.SQLITE_OK:
raise self._get_exception(ret)
@@ -915,8 +913,6 @@
ret = _lib.sqlite3_step(self.__statement._statement)
if ret not in (_lib.SQLITE_DONE, _lib.SQLITE_ROW):
self.__statement._reset()
- self.__connection._in_transaction = \
- not _lib.sqlite3_get_autocommit(self.__connection._db)
raise self.__connection._get_exception(ret)
if self.__statement._kind == Statement._DML:
@@ -931,6 +927,8 @@
self.__rowcount = 0
self.__rowcount +=
_lib.sqlite3_changes(self.__connection._db)
finally:
+ self.__connection._in_transaction = \
+ not _lib.sqlite3_get_autocommit(self.__connection._db)
self.__locked = False
return self
@@ -950,13 +948,13 @@
elif not isinstance(sql, str):
raise ValueError("script argument must be unicode or string.")
statement_star = _ffi.new('sqlite3_stmt **')
- tail = _ffi.new('char **')
+ next_char = _ffi.new('char **')
self.__connection.commit()
while True:
- rc = _lib.sqlite3_prepare(self.__connection._db, sql, -1,
- statement_star, tail)
- sql = _ffi.string(tail[0])
+ c_sql = _ffi.new("char[]", sql)
+ rc = _lib.sqlite3_prepare(self.__connection._db, c_sql, -1,
+ statement_star, next_char)
if rc != _lib.SQLITE_OK:
raise self.__connection._get_exception(rc)
@@ -978,6 +976,7 @@
if rc != _lib.SQLITE_OK:
raise self.__connection._get_exception(rc)
+ sql = _ffi.string(next_char[0])
if not sql:
break
return self
@@ -1052,6 +1051,9 @@
self.__con = connection
self.__con._remember_statement(self)
+ self._in_use = False
+ self._row_factory = None
+
if not isinstance(sql, basestring):
raise Warning("SQL is of wrong type. Must be string or unicode.")
first_word = self._statement_kind = sql.lstrip().split(" ")[0].upper()
@@ -1062,27 +1064,27 @@
else:
self._kind = Statement._DDL
- self._in_use = False
- self._row_factory = None
-
if isinstance(sql, unicode):
sql = sql.encode('utf-8')
statement_star = _ffi.new('sqlite3_stmt **')
next_char = _ffi.new('char **')
- ret = _lib.sqlite3_prepare_v2(self.__con._db, sql, -1,
+ c_sql = _ffi.new("char[]", sql)
+ ret = _lib.sqlite3_prepare_v2(self.__con._db, c_sql, -1,
statement_star, next_char)
self._statement = statement_star[0]
if ret == _lib.SQLITE_OK and not self._statement:
# an empty statement, work around that, as it's the least trouble
- ret = _lib.sqlite3_prepare_v2(self.__con._db, "select 42", -1,
+ c_sql = _ffi.new("char[]", "select 42")
+ ret = _lib.sqlite3_prepare_v2(self.__con._db, c_sql, -1,
statement_star, next_char)
self._statement = statement_star[0]
self._kind = Statement._DQL
if ret != _lib.SQLITE_OK:
raise self.__con._get_exception(ret)
- if _check_remaining_sql(_ffi.string(next_char[0])):
+ tail = _ffi.string(next_char[0]).decode('utf-8')
+ if _check_remaining_sql(tail):
raise Warning("You can only execute one statement at a time.")
def __del__(self):
@@ -1173,7 +1175,7 @@
raise ProgrammingError("Binding %d has no name, but you "
"supplied a dictionary (which has "
"only names)." % i)
- param_name = _ffi.string(param_name)[1:]
+ param_name = _ffi.string(param_name).decode('utf-8')[1:]
try:
param = params[param_name]
except KeyError:
@@ -1196,8 +1198,8 @@
if self.__con._detect_types & PARSE_COLNAMES:
colname = _lib.sqlite3_column_name(self._statement, i)
- if colname is not None:
- colname = _ffi.string(colname)
+ if colname:
+ colname = _ffi.string(colname).decode('utf-8')
type_start = -1
key = None
for pos in range(len(colname)):
@@ -1209,8 +1211,8 @@
if converter is None and self.__con._detect_types &
PARSE_DECLTYPES:
decltype = _lib.sqlite3_column_decltype(self._statement, i)
- if decltype is not None:
- decltype = _ffi.string(decltype)
+ if decltype:
+ decltype = _ffi.string(decltype).decode('utf-8')
# if multiple words, use first, eg.
# "INTEGER NOT NULL" => "INTEGER"
decltype = decltype.split()[0]
@@ -1222,7 +1224,7 @@
def _readahead(self, cursor):
row = []
- num_cols = _lib.sqlite3_column_count(self._statement)
+ num_cols = _lib.sqlite3_data_count(self._statement)
for i in xrange(num_cols):
if self.__con._detect_types:
converter = self.__row_cast_map[i]
@@ -1266,6 +1268,7 @@
try:
item = self._item
except AttributeError:
+ self._reset()
raise StopIteration
del self._item
@@ -1284,7 +1287,8 @@
desc = []
for i in xrange(_lib.sqlite3_column_count(self._statement)):
name = _lib.sqlite3_column_name(self._statement, i)
- name = _ffi.string(name).split("[")[0].strip()
+ if name:
+ name = _ffi.string(name).decode('utf-8').split("[")[0].strip()
desc.append((name, None, None, None, None, None, None))
return desc
@@ -1379,7 +1383,7 @@
val = _lib.sqlite3_value_double(params[i])
elif typ == _lib.SQLITE_TEXT:
val = _lib.sqlite3_value_text(params[i])
- val = unicode(_ffi.string(val), 'utf-8')
+ val = _ffi.string(val).decode('utf-8')
elif typ == _lib.SQLITE_BLOB:
blob = _lib.sqlite3_value_blob(params[i])
blob_len = _lib.sqlite3_value_bytes(params[i])
diff --git a/pypy/module/test_lib_pypy/test_sqlite3.py
b/pypy/module/test_lib_pypy/test_sqlite3.py
--- a/pypy/module/test_lib_pypy/test_sqlite3.py
+++ b/pypy/module/test_lib_pypy/test_sqlite3.py
@@ -196,3 +196,12 @@
con.execute('insert into foo(x) values (?)', 2)
assert str(e.value) == 'parameters are of unsupported type'
con.close()
+
+def test_explicit_begin():
+ con = _sqlite3.connect(':memory:')
+ con.execute('BEGIN')
+ con.execute('BEGIN ')
+ con.execute('BEGIN')
+ con.commit()
+ con.execute('BEGIN')
+ con.commit()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit