Parcourir la source

Fix issue #44 - Python2 and Python3 compat

Oz N Tiram il y a 8 ans
Parent
commit
8275eb0acd
2 fichiers modifiés avec 10 ajouts et 6 suppressions
  1. 6 5
      pwman/data/nodes.py
  2. 4 1
      setup.py

+ 6 - 5
pwman/data/nodes.py

@@ -18,6 +18,7 @@
 # ============================================================================
 # ============================================================================
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 # Copyright (C) 2006 Ivan Kelly <ivan@ivankelly.net>
 # ============================================================================
 # ============================================================================
+from builtins import bytes
 from colorama import Fore
 from colorama import Fore
 from pwman.util.crypto_engine import CryptoEngine
 from pwman.util.crypto_engine import CryptoEngine
 import pwman.ui.tools
 import pwman.ui.tools
@@ -72,11 +73,11 @@ class Node(object):
         the encrypted entities from the database
         the encrypted entities from the database
         """
         """
         node = Node(clear_text=False)
         node = Node(clear_text=False)
-        node._username = bytes(username).strip()
-        node._password = bytes(password).strip()
-        node._url = bytes(url).strip()
-        node._notes = bytes(notes).strip()
-        node._tags = [bytes(t).strip() for t in tags]
+        node._username = bytes(username, 'utf8').strip()
+        node._password = bytes(password, 'utf8').strip()
+        node._url = bytes(url, 'utf8').strip()
+        node._notes = bytes(notes, 'utf8').strip()
+        node._tags = [bytes(t, 'utf8').strip() for t in tags]
         return node
         return node
 
 
     def __iter__(self):
     def __iter__(self):

+ 4 - 1
setup.py

@@ -318,7 +318,10 @@ class PyCryptoInstallCommand(install):
                    'to install pycrypto ...'))
                    'to install pycrypto ...'))
 
 
 
 
-install_requires=['colorama>=0.2.4']
+install_requires = ['colorama>=0.2.4']
+
+if sys.version_info.major < 3:
+    install_requires.append("future")
 
 
 if sys.platform.startswith('win'):
 if sys.platform.startswith('win'):
     install_requires.append('pyreadline')
     install_requires.append('pyreadline')