Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove py2 compatibility code #40375

Merged
merged 1 commit into from Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/dump_syms.py
@@ -1,4 +1,4 @@
from __future__ import print_function
#!/usr/bin/env python3

import collections
import os
Expand Down
2 changes: 1 addition & 1 deletion build/npm-run.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import os
import subprocess
import sys
Expand Down
2 changes: 1 addition & 1 deletion build/profile_toolchain.py
@@ -1,4 +1,4 @@
from __future__ import unicode_literals
#!/usr/bin/env python3

import contextlib
import sys
Expand Down
2 changes: 1 addition & 1 deletion build/zip.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import os
import subprocess
import sys
Expand Down
2 changes: 1 addition & 1 deletion build/zip_libcxx.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import os
import subprocess
import sys
Expand Down
2 changes: 1 addition & 1 deletion script/add-debug-link.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 1 addition & 1 deletion script/copy-debug-symbols.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import argparse
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion script/generate-config-gypi.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function
import ast
import os
import pprint
Expand Down
1 change: 0 additions & 1 deletion script/lib/config.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function
import os
import sys

Expand Down
12 changes: 1 addition & 11 deletions script/lib/git.py
Expand Up @@ -6,8 +6,6 @@
structure, or make assumptions about the passed arguments or calls' outcomes.
"""

from __future__ import unicode_literals

import io
import os
import posixpath
Expand Down Expand Up @@ -229,14 +227,6 @@ def remove_patch_filename(patch):
force_keep_next_line = l.startswith('Subject: ')


def to_utf8(patch):
"""Python 2/3 compatibility: unicode has been renamed to str in Python3"""
if sys.version_info[0] >= 3:
return str(patch, "utf-8")

return unicode(patch, "utf-8")


def export_patches(repo, out_dir, patch_range=None, dry_run=False):
if not os.path.exists(repo):
sys.stderr.write(
Expand All @@ -263,7 +253,7 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
for patch in patches:
filename = get_file_name(patch)
filepath = posixpath.join(out_dir, filename)
existing_patch = to_utf8(io.open(filepath, 'rb').read())
existing_patch = str(io.open(filepath, 'rb').read(), 'utf-8')
formatted_patch = join_patch(patch)
if formatted_patch != existing_patch:
bad_patches.append(filename)
Expand Down
9 changes: 2 additions & 7 deletions script/lib/native_tests.py
@@ -1,4 +1,4 @@
from __future__ import print_function
#!/usr/bin/env python3

import os
import subprocess
Expand All @@ -10,11 +10,6 @@
sys.path.append(PYYAML_LIB_DIR)
import yaml #pylint: disable=wrong-import-position,wrong-import-order

try:
basestring # Python 2
except NameError: # Python 3
basestring = str # pylint: disable=redefined-builtin


class Verbosity:
CHATTY = 'chatty' # stdout and stderr
Expand Down Expand Up @@ -148,7 +143,7 @@ def __expand_shorthand(value):
if isinstance(value, dict):
return value

if isinstance(value, basestring):
if isinstance(value, str):
return {value: None}

raise AssertionError("unexpected shorthand type: {}".format(type(value)))
Expand Down
7 changes: 1 addition & 6 deletions script/lib/util.py
@@ -1,18 +1,13 @@
#!/usr/bin/env python3

from __future__ import print_function
import contextlib
import errno
import json
import os
import shutil
import subprocess
import sys
# Python 3 / 2 compat import
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
from urllib.request import urlopen
import zipfile

# from lib.config import is_verbose_mode
Expand Down
2 changes: 0 additions & 2 deletions script/native-tests.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function

import argparse
import os
import sys
Expand Down
10 changes: 1 addition & 9 deletions script/patches-mtime-cache.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function

import argparse
import hashlib
import json
Expand Down Expand Up @@ -168,13 +166,7 @@ def main():
traceback.print_exc(file=sys.stderr)
return 0
elif args.operation == "set":
# Python 2/3 compatibility
try:
user_input = raw_input
except NameError:
user_input = input

answer = user_input(
answer = input(
"WARNING: Manually setting mtimes could mess up your build. "
"If you're sure, type yes: "
)
Expand Down
1 change: 0 additions & 1 deletion script/release/uploaders/upload-index-json.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function
import json
import os
import sys
Expand Down
1 change: 0 additions & 1 deletion script/release/uploaders/upload.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function
import argparse
import datetime
import hashlib
Expand Down
2 changes: 0 additions & 2 deletions script/run-clang-format.py
Expand Up @@ -7,8 +7,6 @@
A diff output is produced and a sensible exit code is returned.
"""

from __future__ import print_function, unicode_literals

import argparse
import codecs
import difflib
Expand Down
2 changes: 1 addition & 1 deletion script/strip-binaries.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import argparse
import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions script/verify-chromedriver.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function

import argparse
import os
import re
Expand Down
2 changes: 1 addition & 1 deletion script/verify-ffmpeg.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import argparse
import os
import platform
Expand Down
2 changes: 1 addition & 1 deletion script/verify-mksnapshot.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function

import argparse
import glob
import os
Expand Down
1 change: 0 additions & 1 deletion script/zip-symbols.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

from __future__ import print_function
import argparse
import glob
import os
Expand Down