Skip to content

Commit

Permalink
fix a comatible problem for cup.shell
Browse files Browse the repository at this point in the history
  • Loading branch information
mythmgn committed May 20, 2020
1 parent b654b30 commit 24aa6e7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
23 changes: 22 additions & 1 deletion cup/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
cross-platform functions related module
"""

import sys
import select
import platform

__all__ = [
'is_linux',
'is_windows',
'is_mac'
'is_mac',
'is_py2',
'is_py3'
]


Expand Down Expand Up @@ -54,4 +57,22 @@ def is_mac():
return False


def is_py2():
"""
is python 2.x
"""
if sys.version_info >= (3, 0):
return False
if sys.version_info < (3, 0):
return True
raise ValueError('cannot determine if it\'s python2')


def is_py3():
"""is python 3.x"""
if (3, 0) <= sys.version_info <= (4, 0):
return True
else:
return False

# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent
6 changes: 5 additions & 1 deletion cup/shell/oper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import subprocess

import cup
from cup import decorators
from cup import err
from cup import log
from cup import platforms
from cup import decorators


# linux only import
Expand Down Expand Up @@ -518,6 +519,9 @@ def _signal_handle():
signal.signal(signal.SIGPIPE, signal.SIG_DFL)

def _trans_bytes(data):
"""trans bytes into unicode for python3"""
if platforms.is_py2():
return data
if isinstance(data, bytes):
try:
data = bytes.decode(data)
Expand Down
2 changes: 1 addition & 1 deletion cup/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
]


VERSION = '3.2.12'
VERSION = '3.2.13'
AUTHOR = 'CUP-DEV Team'

# vi:set tw=0 ts=4 sw=4 nowrap fdm=indent

0 comments on commit 24aa6e7

Please sign in to comment.