Skip to content

Commit 2390d34

Browse files
fffrogpytorchmergebot
authored andcommitted
[Code Clean] Remove deadcodes about Python3.9 [7/N] (pytorch#163646)
As the title stated. Pull Request resolved: pytorch#163646 Approved by: https://github.com/jansel ghstack dependencies: pytorch#163626, pytorch#163627, pytorch#163629, pytorch#163643, pytorch#163644, pytorch#163645
1 parent a635505 commit 2390d34

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

test/jit/test_hash.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ def fn(f1: float, f2: float):
7373
self.checkScript(fn, (1.2345, float("inf")))
7474
self.checkScript(fn, (float("inf"), float("inf")))
7575
self.checkScript(fn, (1.2345, float("nan")))
76-
if sys.version_info < (3, 10):
77-
# Hash of two nans are not guaranteed to be equal. From https://docs.python.org/3/whatsnew/3.10.html :
78-
# Hashes of NaN values of both float type and decimal.Decimal type now depend on object identity.
79-
self.checkScript(fn, (float("nan"), float("nan")))
8076
self.checkScript(fn, (float("nan"), float("inf")))
8177

8278
def test_hash_int(self):

test/jit/test_union_pep604.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from torch.testing._internal.jit_utils import JitTestCase, make_global
2121

2222

23-
@unittest.skipIf(sys.version_info < (3, 10), "Requires Python 3.10")
2423
class TestUnion(JitTestCase):
2524
"""
2625
This class tests the functionality of `Union`.

torch/_dynamo/bytecode_transformation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def create_print_value(value: Any) -> list[Instruction]:
529529
]
530530

531531

532-
def linetable_310_writer(
532+
def linetable_writer(
533533
first_lineno: int,
534534
) -> tuple[list[int], Callable[[int, int], None], Callable[[int], None]]:
535535
"""
@@ -759,7 +759,7 @@ def assemble(instructions: list[Instruction], firstlineno: int) -> tuple[bytes,
759759
for _ in range(instruction_size(inst) // 2 - 1):
760760
code.extend((0, 0))
761761
else:
762-
lnotab, update_lineno, end = linetable_310_writer(firstlineno)
762+
lnotab, update_lineno, end = linetable_writer(firstlineno)
763763

764764
for inst in instructions:
765765
if inst.starts_line is not None:
@@ -871,7 +871,6 @@ def devirtualize_jumps(instructions: list[Instruction]) -> None:
871871
inst.arg = abs(
872872
int(target.offset - inst.offset - instruction_size(inst))
873873
)
874-
# see bytecode size comment in the absolute jump case above
875874
inst.arg //= 2
876875
inst.argval = target.offset
877876
inst.argrepr = f"to {target.offset}"

torch/_jit_internal.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
_P = ParamSpec("_P")
5353
_R = TypeVar("_R")
5454

55-
BuiltinUnionType: Union[type, tuple[type, ...]]
56-
BuiltinUnionType = types.UnionType
55+
BuiltinUnionType: Union[type, tuple[type, ...]] = types.UnionType
5756

5857
LockType: type
5958
try:
@@ -1248,8 +1247,7 @@ def _get_named_tuple_properties(
12481247
]
12491248
else:
12501249
defaults = []
1251-
# In 3.10 recommended way to get annotations is to call `inspect.get_annotations` function
1252-
# Also, annotations from base class are not inherited so they need to be queried explicitly
1250+
12531251
obj_annotations = inspect.get_annotations(obj)
12541252
if len(obj_annotations) == 0 and hasattr(obj, "__base__"):
12551253
obj_annotations = inspect.get_annotations(obj.__base__)

0 commit comments

Comments
 (0)