Skip to content

Commit c8b1065

Browse files
committed
Merge branch 'dev' into repl-improvements
2 parents 07f3eb3 + 7980f08 commit c8b1065

File tree

7 files changed

+39
-6
lines changed

7 files changed

+39
-6
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Version 2.0.1
2+
-----------------------------------------------------------
3+
* Fix unicode decoder error with BinaryPayloadDecoder in some platforms
4+
* Avoid unnecessary import of deprecated modules with dependencies on twisted
5+
16
Version 2.0.0
27
-----------------------------------------------------------
38
**Note This is a Major release and might affect your existing Async client implementation. Refer examples on how to use the latest async clients.**

pymodbus/client/async/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@
3131
# For asyncio the actual client is returned and event loop is asyncio loop
3232
3333
"""
34-
from pymodbus.client.async.deprecated.async import *
34+
from pymodbus.compat import is_installed
35+
36+
installed = is_installed('twisted')
37+
if installed:
38+
# Import deprecated async client only if twisted is installed #338
39+
from pymodbus.client.async.deprecated.async import *
40+
else:
41+
import logging
42+
logger = logging.getLogger(__name__)
43+
logger.warning("Not Importing deprecated clients. "
44+
"Dependency Twisted is not Installed")

pymodbus/client/async/deprecated/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@
4343
"""
4444

4545

46-
def deprecated(name): # pragma: no cover
46+
def deprecated(name): # pragma: no cover
4747
warnings.warn(WARNING.format(name), DeprecationWarning)

pymodbus/compat.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@
5858
implements_to_string = lambda x: x
5959

6060
byte2int = lambda b: b
61+
if PYTHON_VERSION >= (3, 4):
62+
def is_installed(module):
63+
import importlib.util
64+
found = importlib.util.find_spec(module)
65+
return found
66+
else:
67+
def is_installed(module):
68+
import importlib
69+
found = importlib.find_loader(module)
70+
return found
6171
# --------------------------------------------------------------------------- #
6272
# python > 2.5 compatability layer
6373
# --------------------------------------------------------------------------- #
@@ -76,3 +86,11 @@ def implements_to_string(klass):
7686
klass.__unicode__ = klass.__str__
7787
klass.__str__ = lambda x: x.__unicode__().encode('utf-8')
7888
return klass
89+
90+
def is_installed(module):
91+
import imp
92+
try:
93+
imp.find_module(module)
94+
return True
95+
except ImportError:
96+
return False

pymodbus/payload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def _unpack_words(self, fstring, handle):
331331
:return:
332332
"""
333333
handle = make_byte_string(handle)
334-
wc = WC.get(fstring.lower())//2
334+
wc = WC.get(fstring.lower()) // 2
335335
up = "!{}H".format(wc)
336336
handle = unpack(up, handle)
337337
if self._wordorder == Endian.Little:
@@ -340,8 +340,8 @@ def _unpack_words(self, fstring, handle):
340340
# Repack as unsigned Integer
341341
pk = self._byteorder + 'H'
342342
handle = [pack(pk, p) for p in handle]
343+
_logger.debug(handle)
343344
handle = b''.join(handle)
344-
_logger.debug(unicode_string(handle))
345345
return handle
346346

347347
def reset(self):

pymodbus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __str__(self):
4141
return '[%s, version %s]' % (self.package, self.short())
4242

4343

44-
version = Version('pymodbus', 2, 0, 0)
44+
version = Version('pymodbus', 2, 0, 1)
4545

4646

4747
version.__name__ = 'pymodbus' # fix epydoc error

requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Python packages required to run `make docs'.
2-
cryptography==2.1.4 # Required to parse some files
2+
cryptography>= 2.3 # Required to parse some files
33
humanfriendly==4.4.1
44
pyasn1==0.4.2 # Required to parse some files
55
pyserial-asyncio==0.4.0;python_version>="3.4"

0 commit comments

Comments
 (0)