mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
IDEA-CR-60026: PY-40721 PY-40723 Fix troublesome cases in bytecode parsing and make sure internal errors are printed only in debug mode
(cherry picked from commit 9444416aa25d4188bcafa47253f9c9bd7e40932e) GitOrigin-RevId: 6d5f0a70cb34378a11341bfd68f05abe338c37d9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e851f55a4c
commit
8897eed94f
@@ -0,0 +1,43 @@
|
||||
from __future__ import print_function
|
||||
import pytest
|
||||
from _pydevd_bundle import pydevd_bytecode_utils
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inner_decorator_code():
|
||||
def power(exponent):
|
||||
def outer(f):
|
||||
def inner(*args):
|
||||
result = f(*args)
|
||||
return exponent ** result
|
||||
return inner
|
||||
return outer
|
||||
return power.__code__.co_consts[1].co_consts[1]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def function_with_try_except_code():
|
||||
def f():
|
||||
try:
|
||||
1 / 0
|
||||
except ZeroDivisionError:
|
||||
print("Can't divide by zero!")
|
||||
else:
|
||||
print("Everything is fine.")
|
||||
return f.__code__
|
||||
|
||||
|
||||
def test_candidates_for_inner_decorator(inner_decorator_code):
|
||||
variants = pydevd_bytecode_utils.get_smart_step_into_candidates(inner_decorator_code)
|
||||
assert len(variants) == 2
|
||||
assert variants[0].argval == 'f'
|
||||
assert variants[1].argval == '__pow__'
|
||||
|
||||
|
||||
def test_candidates_for_function_with_try_except(function_with_try_except_code):
|
||||
variants = pydevd_bytecode_utils.get_smart_step_into_candidates(function_with_try_except_code)
|
||||
assert len(variants) == 3
|
||||
assert variants[0].argval == '__div__'
|
||||
assert variants[1].argval == 'print'
|
||||
assert variants[2].argval == 'print'
|
||||
|
||||
Reference in New Issue
Block a user