Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Python <=3.6 support #1061

Merged
merged 2 commits into from May 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions jpype/_core.py
Expand Up @@ -44,14 +44,6 @@ class JVMNotRunning(RuntimeError):
pass


def versionTest():
if sys.version_info < (3,):
raise ImportError("Python 2 is not supported")


versionTest()


# Activate jedi tab completion
try:
import jedi as _jedi
Expand Down
3 changes: 2 additions & 1 deletion jpype/_pykeywords.py
Expand Up @@ -16,8 +16,9 @@
#
# *****************************************************************************

# This is a super set of the keywords in Python2 and Python3.
# This is a superset of the keywords in Python.
# We use this so that jpype is a bit more version independent.
# Removing keywords from this list impacts the exposed interfaces, and therefore is a breaking change.
_KEYWORDS = set((
'False', 'None', 'True', 'and', 'as', 'assert', 'async',
'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else',
Expand Down
5 changes: 0 additions & 5 deletions jpype/imports.py
Expand Up @@ -24,8 +24,6 @@
``net`` and ``edu``. Java symbols from these domains can be imported using the
standard Python syntax.

Import customizers are supported in Python 3.6 or greater.

Forms supported:
- **import <java_pkg> [ as <name> ]**
- **import <java_pkg>.<java_class> [ as <name> ]**
Expand All @@ -36,9 +34,6 @@

For further information please read the :doc:`imports` guide.

Requires:
Python 3.6 or later

Example:

.. code-block:: python
Expand Down
7 changes: 1 addition & 6 deletions jpype/pickle.py
Expand Up @@ -49,9 +49,6 @@

Proxies and other JPype specific module resources cannot be pickled currently.

Requires:
Python 3.6 or later

"""
from __future__ import absolute_import
import _jpype
Expand Down Expand Up @@ -89,8 +86,7 @@ def __init__(self, dispatch):
# Extension dispatch table holds reduce method
self._call = self.reduce

# Python2 and Python3 _Pickler use get()

# Pure Python _Pickler uses get()
def get(self, cls):
if not issubclass(cls, (_jpype.JClass, _jpype.JObject)):
return self._dispatch.get(cls)
Expand All @@ -102,7 +98,6 @@ def __getitem__(self, cls):
return self._dispatch[cls]
return self._call

# For Python3
def reduce(self, obj):
byte = bytes(self._encoder.pack(obj))
return (self._builder, (byte, ))
Expand Down
12 changes: 0 additions & 12 deletions jpype/protocol.py
Expand Up @@ -105,18 +105,6 @@ def _JInstantConversion(jcls, obj):
return jcls.ofEpochSecond(sec, nsec)


if sys.version_info < (3, 6): # pragma: no cover
import pathlib

@_jcustomizer.JConversion("java.nio.file.Path", instanceof=pathlib.PurePath)
def _JPathConvert(jcls, obj):
Paths = _jpype.JClass("java.nio.file.Paths")
return Paths.get(str(obj))

@_jcustomizer.JConversion("java.io.File", instanceof=pathlib.PurePath)
def _JFileConvert(jcls, obj):
return jcls(str(obj))

# Types needed for SQL


Expand Down
8 changes: 0 additions & 8 deletions native/python/pyjp_module.cpp
Expand Up @@ -714,14 +714,6 @@ PyMODINIT_FUNC PyInit__jpype()
JP_PY_TRY("PyInit__jpype");
JPContext_global = new JPContext();

#if PY_VERSION_HEX<0x03070000
// This is required for python versions prior to 3.7.
// It is called by the python initialization starting from 3.7,
// but is safe to call afterwards. Starting 3.9 this issues a
// deprecation warning.
PyEval_InitThreads();
#endif

// Initialize the module (depends on python version)
PyObject* module = PyModule_Create(&moduledef);
// PyJPModule = module;
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Expand Up @@ -58,7 +58,7 @@
author_email='devilwolf@users.sourceforge.net',
maintainer='Luis Nell',
maintainer_email='cooperate@originell.org',
python_requires=">=3.5",
python_requires=">=3.7",
url='https://github.com/jpype-project/jpype',
platforms=[
'Operating System :: Microsoft :: Windows',
Expand All @@ -68,10 +68,10 @@
],
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development',
'Topic :: Scientific/Engineering',
],
Expand Down
8 changes: 0 additions & 8 deletions test/jpypetest/test_closeable.py
Expand Up @@ -17,11 +17,6 @@
# *****************************************************************************
import jpype
import common
import sys


def pythonNewerThan(major, minor):
return sys.version_info[0] > major or (sys.version_info[0] == major and sys.version_info[1] > minor)


class CloseableTestCase(common.JPypeTestCase):
Expand All @@ -38,7 +33,6 @@ def testCloseable(self):
self.assertEqual(CloseableTest.printed, "hello 1")
self.assertTrue(CloseableTest.closed)

@common.unittest.skipUnless(pythonNewerThan(3, 0), "requires python 3")
def testCloseableFail(self):
CloseableTest = jpype.JClass("jpype.closeable.CloseableTest")
CloseableTest.reset()
Expand Down Expand Up @@ -72,7 +66,6 @@ def testCloseablePyExcept(self):
self.assertEqual(CloseableTest.printed, "hello 2")
self.assertTrue(CloseableTest.closed)

@common.unittest.skipUnless(pythonNewerThan(2, 6), "Earlier python does not support stacked exceptions.")
def testCloseablePyExceptFail(self):
CloseableTest = jpype.JClass("jpype.closeable.CloseableTest")
CloseableTest.reset()
Expand Down Expand Up @@ -105,7 +98,6 @@ def testCloseableJExcept(self):
self.assertEqual(CloseableTest.printed, "hello 4")
self.assertTrue(CloseableTest.closed)

@common.unittest.skipUnless(pythonNewerThan(2, 6), "Earlier python does not support stacked exceptions.")
def testCloseableJExceptFail(self):
CloseableTest = jpype.JClass("jpype.closeable.CloseableTest")
CloseableTest.reset()
Expand Down
8 changes: 0 additions & 8 deletions test/jpypetest/test_core.py
Expand Up @@ -25,14 +25,6 @@ class JCharTestCase(common.JPypeTestCase):
def setUp(self):
common.JPypeTestCase.setUp(self)

@mock.patch('jpype._core.sys')
def testVersion(self, mock_sys):
mock_sys.version_info = (2, 7)
with self.assertRaises(ImportError):
jpype._core.versionTest()
mock_sys.version_info = (3, 8)
jpype._core.versionTest()

def testShutdownHook(self):
Thread = JClass("java.lang.Thread")
Runnable = JClass("java.lang.Runnable")
Expand Down
2 changes: 1 addition & 1 deletion test/jpypetest/test_overloads.py
Expand Up @@ -128,7 +128,7 @@ def testVarArgsCall(self):

def testPrimitive(self):
test1 = self.__jp.Test1()
intexpectation = 'int' if not sys.version_info[0] > 2 and sys.maxint == 2**31 - 1 else 'long'
intexpectation = 'long'
# FIXME it is not possible to determine if this is bool/char/byte currently
#self.assertEqual(intexpectation, test1.testPrimitive(5))
#self.assertEqual('long', test1.testPrimitive(2**31))
Expand Down