From 3ebd087f18ad397dab46c0c71ea92587e0ba242b Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 20 Jun 2018 21:14:51 +0000 Subject: [PATCH 62/64] Python 3 preparation: avoid string.translate() and string.maketrans(). --- roundup/dist/command/build_scripts.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roundup/dist/command/build_scripts.py b/roundup/dist/command/build_scripts.py index 8dfab52..a9cb8b3 100644 --- a/roundup/dist/command/build_scripts.py +++ b/roundup/dist/command/build_scripts.py @@ -96,7 +96,13 @@ sys.path.insert(1, "%s/lib/python%s/site-packages") """ Create each script listed in 'self.scripts' """ - to_module = string.maketrans('-/', '_.') + try: + # Python 3. + maketrans = str.maketrans + except AttributeError: + # Python 2. + maketrans = string.maketrans + to_module = maketrans('-/', '_.') self.mkpath(self.build_dir) for script in self.scripts: @@ -111,7 +117,7 @@ sys.path.insert(1, "%s/lib/python%s/site-packages") continue module = os.path.splitext(os.path.basename(script))[0] - module = string.translate(module, to_module) + module = module.translate(to_module) script_vars = { 'python': self.python_executable, 'package': self.package_name, -- 2.7.4