Skip to content

Commit b94a52a

Browse files
author
James William Pye
committed
Fix Startup() for Python3.2's no non-str() keywords.
1 parent 1f8fb8e commit b94a52a

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

postgresql/documentation/changes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Changes
88
* Release savepoints after rolling them back.
99
* Add support for DOMAINs in registered composites. (Elvis Pranskevichus)
1010
* Properly raise StopIteration in Cursor.__next__ (Elvis Pranskevichus)
11+
* Fix Startup() usage for Python 3.2.
1112

1213
1.0.1 released on 2010-04-24
1314
----------------------------

postgresql/driver/pq3.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,15 +2799,17 @@ def __init__(self,
27992799
##
28002800
# Attempt to accommodate for literal treatment of startup data.
28012801
##
2802-
self._startup_parameters = {
2802+
self._startup_parameters = tuple([
28032803
# All keys go in utf-8. However, ascii would probably be good enough.
2804-
k.encode('utf-8') : \
2804+
(
2805+
k.encode('utf-8'),
28052806
# If it's a str(), encode in the hinted server_encoding.
28062807
# Otherwise, convert the object(int, float, bool, etc) into a string
28072808
# and treat it as utf-8.
2808-
v.encode(se) if type(v) is str else str(v).encode('utf-8')
2809+
v.encode(se) if type(v) is str else str(v).encode('utf-8')
2810+
)
28092811
for k, v in tnkw.items()
2810-
}
2812+
])
28112813
self._password = (self.password or '').encode(se)
28122814
self._socket_secure = {
28132815
'keyfile' : self.sslkeyfile,

postgresql/protocol/client3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def __init__(self,
511511

512512
self.socket_factory = socket_factory
513513
self.xact = xact.Negotiation(
514-
element.Startup(**startup), password
514+
element.Startup(startup), password
515515
)
516516

517517
self.garbage_statements = []

postgresql/test/test_protocol.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ def test_getvalue(self):
132132

133133
message_samples = [
134134
e3.VoidMessage,
135-
e3.Startup(**{
136-
b'user' : b'jwp',
137-
b'database' : b'template1',
138-
b'options' : b'-f',
139-
}),
135+
e3.Startup([
136+
(b'user', b'jwp'),
137+
(b'database', b'template1'),
138+
(b'options', b'-f'),
139+
]),
140140
e3.Notice((
141141
(b'S', b'FATAL'),
142142
(b'M', b'a descriptive message'),

0 commit comments

Comments
 (0)