From 881f80e0618d5d4aa26890a4ca70045b84928cf9 Mon Sep 17 00:00:00 2001 From: Siting Ren Date: Fri, 27 Oct 2023 11:51:33 +0800 Subject: [PATCH] Add support for Python 3.12 (#534) --- .github/workflows/ci.yaml | 2 +- README.md | 2 +- setup.py | 1 + tox.ini | 4 ++-- vertica_python/datatypes.py | 8 ++++---- vertica_python/vertica/connection.py | 5 ++++- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ad83c00..2e7381f0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9'] steps: - name: Check out repository diff --git a/README.md b/README.md index 43ac0452..7713b94d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Please check out [release notes](https://github.com/vertica/vertica-python/releases) to learn about the latest improvements. -vertica-python has been tested with Vertica 23.4.0 and Python 3.7/3.8/3.9/3.10/3.11. Feel free to submit issues and/or pull requests (Read up on our [contributing guidelines](#contributing-guidelines)). +vertica-python has been tested with Vertica 23.4.0 and Python 3.7/3.8/3.9/3.10/3.11/3.12. Feel free to submit issues and/or pull requests (Read up on our [contributing guidelines](#contributing-guidelines)). ## Installation diff --git a/setup.py b/setup.py index d9fb4306..f3559548 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,7 @@ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Database", "Topic :: Database :: Database Engines/Servers", "Topic :: Database :: Front-Ends", diff --git a/tox.ini b/tox.ini index 2883cd4e..f3f18cd6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37,py38,py39,py310,py311 +envlist = py37,py38,py39,py310,py311,py312 [testenv] passenv = * @@ -7,7 +7,7 @@ commands = pytest {posargs} deps = pytest - pytest-timeout==1.4.2 + pytest-timeout parameterized python-dateutil mock diff --git a/vertica_python/datatypes.py b/vertica_python/datatypes.py index 22582d4d..e7ddfc61 100644 --- a/vertica_python/datatypes.py +++ b/vertica_python/datatypes.py @@ -36,7 +36,7 @@ from __future__ import print_function, division, absolute_import -from datetime import date, datetime, time +from datetime import date, datetime, time, timezone # noinspection PyPep8Naming @@ -56,19 +56,19 @@ def Timestamp(year, month, day, hour, minute, second): # noinspection PyPep8Naming def DateFromTicks(ticks): - d = datetime.utcfromtimestamp(ticks) + d = datetime.fromtimestamp(ticks, timezone.utc) return d.date() # noinspection PyPep8Naming def TimeFromTicks(ticks): - d = datetime.utcfromtimestamp(ticks) + d = datetime.fromtimestamp(ticks, timezone.utc) return d.time() # noinspection PyPep8Naming def TimestampFromTicks(ticks): - d = datetime.utcfromtimestamp(ticks) + d = datetime.fromtimestamp(ticks, timezone.utc) return d.time() diff --git a/vertica_python/vertica/connection.py b/vertica_python/vertica/connection.py index cfd864ea..704090f5 100644 --- a/vertica_python/vertica/connection.py +++ b/vertica_python/vertica/connection.py @@ -548,7 +548,10 @@ def enable_ssl(self, raw_socket, ssl_options): raise errors.ConnectionError(msg) raw_socket = ssl_options.wrap_socket(raw_socket, server_hostname=server_host) else: - raw_socket = ssl.wrap_socket(raw_socket) + ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + raw_socket = ssl_context.wrap_socket(raw_socket) except ssl.CertificateError as e: raise errors.ConnectionError(str(e)) except ssl.SSLError as e: