mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Make PL/Python tests more compatible with Python 3
This changes a bunch of incidentially used constructs in the PL/Python regression tests to equivalent constructs in cases where Python 3 no longer supports the old syntax. Support for older Python versions is unchanged.
This commit is contained in:
@@ -20,11 +20,9 @@ CREATE FUNCTION import_succeed() returns text
|
||||
import cmath
|
||||
import errno
|
||||
import math
|
||||
import md5
|
||||
import operator
|
||||
import random
|
||||
import re
|
||||
import sha
|
||||
import string
|
||||
import time
|
||||
except Exception, ex:
|
||||
@@ -35,16 +33,24 @@ return "succeeded, as expected"'
|
||||
|
||||
CREATE FUNCTION import_test_one(p text) RETURNS text
|
||||
AS
|
||||
'import sha
|
||||
digest = sha.new(p)
|
||||
'try:
|
||||
import hashlib
|
||||
digest = hashlib.sha1(p.encode("ascii"))
|
||||
except ImportError:
|
||||
import sha
|
||||
digest = sha.new(p)
|
||||
return digest.hexdigest()'
|
||||
LANGUAGE plpythonu;
|
||||
|
||||
CREATE FUNCTION import_test_two(u users) RETURNS text
|
||||
AS
|
||||
'import sha
|
||||
plain = u["fname"] + u["lname"]
|
||||
digest = sha.new(plain);
|
||||
'plain = u["fname"] + u["lname"]
|
||||
try:
|
||||
import hashlib
|
||||
digest = hashlib.sha1(plain.encode("ascii"))
|
||||
except ImportError:
|
||||
import sha
|
||||
digest = sha.new(plain);
|
||||
return "sha hash of " + plain + " is " + digest.hexdigest()'
|
||||
LANGUAGE plpythonu;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user