1
0
mirror of https://github.com/gryf/weechat-replacer.git synced 2025-12-18 12:00:18 +01:00

Change a way for detecting python3 vs python2.

This commit is contained in:
2019-07-20 11:56:54 +02:00
parent 5a5ecd8ce0
commit 943aec432f

View File

@@ -21,7 +21,6 @@ Examples:
import os
import json
import sys
import weechat
@@ -40,15 +39,20 @@ COLOR_RESET = weechat.color('reset')
def _decode(string):
if sys.version_info.major == 2:
try:
return string.decode('utf-8')
return string
except AttributeError:
return string
def _encode(string):
if sys.version_info.major == 2:
try:
# Encode only, if we have decode attribute, which is available for
# string only on python2
string.decode
return string.encode('utf-8')
return string
except AttributeError:
return string
class Replacer(object):