Skip to content

Commit 1294dd5

Browse files
authored
Remove more dead python code found using deadcode module. NFC (#25359)
The remaining dead code being reported is false positives I believe.
1 parent d801296 commit 1294dd5

File tree

12 files changed

+9
-110
lines changed

12 files changed

+9
-110
lines changed

emcc.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,6 @@ def make_relative(filename):
165165
reproduce_file.add(rsp_name, os.path.join(root, 'response.txt'))
166166

167167

168-
def get_library_basename(filename):
169-
"""Similar to get_file_suffix this strips off all numeric suffixes and then
170-
then final non-numeric one. For example for 'libz.so.1.2.8' returns 'libz'"""
171-
filename = os.path.basename(filename)
172-
while filename:
173-
filename, suffix = os.path.splitext(filename)
174-
# Keep stipping suffixes until we strip a non-numeric one.
175-
if not suffix[1:].isdigit():
176-
return filename
177-
178-
179168
#
180169
# Main run() function
181170
#

emrun.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,9 @@ def shutdown(self):
577577

578578
# Processes HTTP request back to the browser.
579579
class HTTPHandler(SimpleHTTPRequestHandler):
580+
protocol_version = 'HTTP/1.1'
581+
580582
def send_head(self):
581-
self.protocol_version = 'HTTP/1.1'
582583
global page_last_served_time
583584
path = self.translate_path(self.path)
584585
f = None
@@ -669,7 +670,6 @@ def log_message(self, format, *args):
669670
sys.stderr.write(msg)
670671

671672
def do_POST(self):
672-
self.protocol_version = 'HTTP/1.1'
673673
global page_exit_code, have_received_messages
674674

675675
(_, _, path, query, _) = urlsplit(self.path)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ module = ["psutil", "win32con", "win32gui", "win32process"]
110110
ignore_missing_imports = true
111111

112112
[tool.deadcode]
113-
exclude = ["out", "third_party", "test/third_party"]
113+
exclude = ["out", "third_party", "test/third_party", "node_modules", "site/source/_themes", "site/source/conf.py"]

test/common.py

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,6 @@ def decorated(self, *args, **kwargs):
414414
return decorated
415415

416416

417-
def requires_wasm_legacy_eh(func):
418-
assert callable(func)
419-
420-
@wraps(func)
421-
def decorated(self, *args, **kwargs):
422-
self.require_wasm_legacy_eh()
423-
return func(self, *args, **kwargs)
424-
425-
return decorated
426-
427-
428417
def requires_wasm_eh(func):
429418
assert callable(func)
430419

@@ -632,31 +621,6 @@ def metafunc(self, rawfs, *args, **kwargs):
632621
return metafunc
633622

634623

635-
# Decorator version of env_modify
636-
def also_with_env_modify(name_updates_mapping):
637-
638-
def decorated(f):
639-
@wraps(f)
640-
def metafunc(self, updates, *args, **kwargs):
641-
if DEBUG:
642-
print('parameterize:env_modify=%s' % (updates))
643-
if updates:
644-
with env_modify(updates):
645-
return f(self, *args, **kwargs)
646-
else:
647-
return f(self, *args, **kwargs)
648-
649-
params = {'': (None,)}
650-
for name, updates in name_updates_mapping.items():
651-
params[name] = (updates,)
652-
653-
parameterize(metafunc, params)
654-
655-
return metafunc
656-
657-
return decorated
658-
659-
660624
def also_with_minimal_runtime(f):
661625
assert callable(f)
662626

@@ -1638,32 +1602,6 @@ def get_func(self, src, name):
16381602
t += 1
16391603
assert t < len(src)
16401604

1641-
def count_funcs(self, javascript_file):
1642-
num_funcs = 0
1643-
start_tok = "// EMSCRIPTEN_START_FUNCS"
1644-
end_tok = "// EMSCRIPTEN_END_FUNCS"
1645-
start_off = 0
1646-
end_off = 0
1647-
1648-
js = read_file(javascript_file)
1649-
blob = "".join(js.splitlines())
1650-
1651-
start_off = blob.find(start_tok) + len(start_tok)
1652-
end_off = blob.find(end_tok)
1653-
asm_chunk = blob[start_off:end_off]
1654-
num_funcs = asm_chunk.count('function ')
1655-
return num_funcs
1656-
1657-
def count_wasm_contents(self, wasm_binary, what):
1658-
out = self.run_process([os.path.join(building.get_binaryen_bin(), 'wasm-opt'), wasm_binary, '--metrics'], stdout=PIPE).stdout
1659-
# output is something like
1660-
# [?] : 125
1661-
for line in out.splitlines():
1662-
if '[' + what + ']' in line:
1663-
ret = line.split(':')[1].strip()
1664-
return int(ret)
1665-
self.fail('Failed to find [%s] in wasm-opt output' % what)
1666-
16671605
def get_wasm_text(self, wasm_binary):
16681606
return self.run_process([WASM_DIS, wasm_binary], stdout=PIPE).stdout
16691607

test/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def check_js_engines():
119119
def get_and_import_modules():
120120
modules = []
121121
for filename in glob.glob(os.path.join(common.TEST_ROOT, 'test*.py')):
122-
module_dir, module_file = os.path.split(filename)
123-
module_name, module_ext = os.path.splitext(module_file)
122+
module_file = os.path.basename(filename)
123+
module_name = os.path.splitext(module_file)[0]
124124
__import__(module_name)
125125
modules.append(sys.modules[module_name])
126126
return modules

test/test_core.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,11 +3775,6 @@ def zzztest_dlfcn_exceptions(self):
37753775
@no_js_math('JS_MATH is not compatible with MAIN_MODULE')
37763776
def test_dlfcn_handle_alloc(self):
37773777
# verify that dlopen does not allocate already used handles
3778-
dirname = self.get_dir()
3779-
3780-
def indir(name):
3781-
return os.path.join(dirname, name)
3782-
37833778
create_file('a.cpp', r'''
37843779
#include <stdio.h>
37853780

test/test_other.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@
5151
from tools.settings import settings
5252
from tools.system_libs import DETERMINISTIC_PREFIX
5353

54-
scons_path = shutil.which('scons')
5554
emmake = shared.bat_suffix(path_from_root('emmake'))
5655
emconfig = shared.bat_suffix(path_from_root('em-config'))
5756
emsize = shared.bat_suffix(path_from_root('emsize'))
5857
empath_split = shared.bat_suffix(path_from_root('empath-split'))
5958
emprofile = shared.bat_suffix(path_from_root('emprofile'))
6059
emstrip = shared.bat_suffix(path_from_root('emstrip'))
6160
emsymbolizer = shared.bat_suffix(path_from_root('emsymbolizer'))
62-
wasm_opt = Path(building.get_binaryen_bin(), 'wasm-opt')
6361

6462

6563
def is_bitcode(filename):
@@ -3056,9 +3054,6 @@ def verify_dwarf(self, wasm_file, verify_func):
30563054
def verify_dwarf_exists(self, wasm_file):
30573055
self.verify_dwarf(wasm_file, self.assertIn)
30583056

3059-
def verify_dwarf_does_not_exist(self, wasm_file):
3060-
self.verify_dwarf(wasm_file, self.assertNotIn)
3061-
30623057
# Verify if the given file name contains a source map
30633058
def verify_source_map_exists(self, map_file):
30643059
self.assertExists(map_file)

tools/cmdline.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def __init__(self):
6161
self.post_link = False
6262
self.save_temps = False
6363
self.executable = False
64-
self.compiler_wrapper = None
6564
self.oformat = None
6665
self.requested_debug = None
6766
self.emit_symbol_map = False
@@ -78,7 +77,6 @@ def __init__(self):
7877
self.shell_path = None
7978
self.source_map_base = ''
8079
self.emit_tsd = ''
81-
self.embind_emit_tsd = ''
8280
self.emrun = False
8381
self.cpu_profiler = False
8482
self.memory_profiler = False

tools/diagnostics.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# diagnostic levels
2323
WARN = 1
2424
ERROR = 2
25-
FATAL = 3
2625

2726
# available colors
2827
RED = 1
@@ -249,16 +248,6 @@ def add_warning(name, enabled=True, part_of_all=True, shared=False, error=False)
249248
manager.add_warning(name, enabled, part_of_all, shared, error)
250249

251250

252-
def enable_warning(name, as_error=False):
253-
manager.warnings[name]['enabled'] = True
254-
if as_error:
255-
manager.warnings[name]['error'] = True
256-
257-
258-
def disable_warning(name):
259-
manager.warnings[name]['enabled'] = False
260-
261-
262251
def is_enabled(name):
263252
return manager.warnings[name]['enabled']
264253

tools/feature_matrix.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Feature(IntEnum):
4242
MEMORY64 = auto()
4343

4444

45-
default_features = {Feature.SIGN_EXT, Feature.MUTABLE_GLOBALS}
4645
disable_override_features = set()
4746
enable_override_features = set()
4847

0 commit comments

Comments
 (0)