Commit Graph

2322 Commits

Author SHA1 Message Date
Daniele Varrazzo
45c6dfb69d Merge branch 'adapt-type' into python2 2011-01-02 00:35:59 +01:00
Daniele Varrazzo
7ac0bdd661 Added PostgreSQL composite types typecaster to Python tuples. 2011-01-02 00:34:13 +01:00
Daniele Varrazzo
159cda3688 Added cursor.cast() method
The method exposes the typecasters lookup algorithm. Useful to create
recursive typecasters.
2011-01-01 22:55:10 +01:00
Daniele Varrazzo
3e94375cf7 Merge branch 'python2' into python3
Conflicts:
	ChangeLog
	NEWS-2.3
	lib/extensions.py
	psycopg/microprotocols.c
	setup.py
2011-01-01 17:14:54 +01:00
Daniele Varrazzo
f9be48d89e Merge branch 'none-in-composite' into python2 2011-01-01 17:09:37 +01:00
Daniele Varrazzo
fdfa2de1a1 Fixed adaptation of None in composite types (ticket #26).
Added an adapter for None: it is usually not invoked as adaptation to
NULL is a fast path in mogrify, but can be invoked by composite types.
Notice that composite types still have the option to fast-path None
(e.g. list adapter does).
2011-01-01 17:07:54 +01:00
Daniele Varrazzo
506ce93a5b Bump to the next dev version. 2011-01-01 12:55:41 +01:00
Daniele Varrazzo
30921b58a8 Dropped conversion from None to NULL in adapter.
It was an error as the string is not conform to the protocol. The error
is masked by the None fast path in _mogrify, but surfaces when adapting
a tuple contains a None.
2010-12-31 18:55:33 +01:00
Daniele Varrazzo
b5a8facb9c Added test to show failed adaptation of None in records. 2010-12-31 18:54:50 +01:00
Daniele Varrazzo
ac25816962 Use the same Bytes_Format function for both Python 2 and 3.
This makes the behaviour between the two versions similar. It also have
the effect of a more specific error message in case an user specifies a
placeholder different from 's'.
2010-12-31 03:22:19 +01:00
Daniele Varrazzo
2930ed3d59 Dropped support for all format specifiers except s in PyBytes_Format. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
6882ac31d4 Dropped warnings in PyBytes_Format function. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
96a950d3eb Fixed 2-phase commit support in Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
89fb60de4b Column names in copy methods can be unicode. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
73917c15e1 Fixed COPY FROM to deal with decoded files. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
bc28cc8b00 Use unicode keys as strings in Py3.
This fixes pyformat style argument passing. Unicode and bytes don't
compare equal (even if they hash the same).
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
0a4eeb4e13 Fixed notification tests to run on Py3.
Call 2to3 on the dynamically generated scripts.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
b78ff4a273 Several tests ported to Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
2fa9117835 Inet adapter compatible with Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
c176de4bf8 Hstore adapter compatible with Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
89c492d3a4 Added b() function to return bytes in both Py2 and Py3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
061079c918 In Py3, decode the tuple values before passing to the typecaster.
Not sure this is the best way to go: it is now impossible to write a
binary typecaster in Python; furthermore it is the opposite approach of
the codecs, which should return bytes.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
ab5934dc35 Use ascii_letters instead of letters.
The latter is locale-dependent and not available on Py3.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
01565fa6c5 Added tests to verify a couple of incomplete encodings. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
f6fefbea64 Function psycopg_ensure_bytes converted in a "filter" stealing a ref. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
3214c23f51 Fixed adaptation in several adapters.
The getquoted methods always return bytes. The str() convert this
representation to string on the fly.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
2e22eef727 Added utility function to convert bytes to string in Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
d3f3f1caf0 Added utility method to return a string in the connection encoding.
In Py2 the result is plain string, in Py3 an unicode decoded in the
connection encoding.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
60841c6567 Added regression test on bool adaptation. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
beba064983 Test on basic adapters pass on Python 3. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
56e4c2bd55 Redefining the microprotocol on Py3 as returning bytes. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
014b6a6d5b Use psycopg_ensure_bytes() to unify Py2/3 code paths. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
89e4d4c7bb Empty lists correctly roundtrip. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
b5ef5ef21d Added typecasters repr(). 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
b4685bba4a Added utility function to get bytes from a str/unicode. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
03dde732f6 Datetime adaptation in bytes. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
87a7ebac10 Query mogrification in bytes. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
c3196ebd9d Added PyBytes_Format function. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
e18f1c63ea Deal with slices passed to __*item__ in Python 3. 2010-12-23 03:28:19 +01:00
Daniele Varrazzo
ade1b2cc7b Test suite converted into a proper package.
Dropped cyclic import from modules to tests: they were only working
because a second copy of the package was found in the project dir.
Use relative import so that 2to3 can do a good conversion.
2010-12-21 05:02:19 +00:00
Daniele Varrazzo
f697410ab4 The tests are run from the external of the package.
If __init__ is treated as a script, relative import fail.
2010-12-21 04:49:16 +00:00
Daniele Varrazzo
cb6b52945b The library can be compiled with Python 3.
Just compiled! No test run yet and many points to review, marked in the
code.

The patch is largely Martin von Löwis work, simplified after refactoring
in the previous commits and adapted to the new code (as the patch was
originally for Psycopg 2.0.9)
2010-12-21 04:24:36 +00:00
Daniele Varrazzo
e182201e6e Added Python codec name to the connection.
This allows dropping repeated dictionary lookups with unicode
query/parameters.
2010-12-21 04:02:14 +00:00
Daniele Varrazzo
ae06fb03e7 Added psycopg_strdup utility function. 2010-12-21 04:02:14 +00:00
Daniele Varrazzo
a50a91fc7b No need to put connection fields to zero: tp_alloc already did. 2010-12-21 04:02:14 +00:00
Daniele Varrazzo
7b5d80d36d Added a few missing encodings.
EUC_CN, EUC_JIS_2004, ISO885910, ISO885916, LATIN10, SHIFT_JIS_2004.
2010-12-21 04:02:14 +00:00
Daniele Varrazzo
657bcb4828 Encodings mapping reordered in a more maintainable order. 2010-12-21 04:02:14 +00:00
Daniele Varrazzo
b96dcef8a2 Fixed PG -> Py encodings mapping with non-alnum chars.
We mangle the encoding names a little bit before asking it to the
backend: be sure to be able to find the equivalent Python code back or
decoding (unicode cast or Py3) will barf.
2010-12-21 04:02:14 +00:00
Daniele Varrazzo
4635c2aa4f Import structmember/stringobject headers from python.h.
stringobject is not to be imported with Python 3.
2010-12-21 04:02:13 +00:00
Daniele Varrazzo
9b30147341 Using PyVarObject_HEAD_INIT macro. 2010-12-21 04:02:13 +00:00