Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Build/debugpy-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.14
1.8.16
13 changes: 10 additions & 3 deletions Python/Product/PythonTools/ptvsd/repl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,19 @@
import select
import time
import struct
import imp
import types
# Add compatibility code:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be a function?

try:
# Python < 3.12
import imp
new_module = imp.new_module
except ImportError:
# Python >= 3.12 - imp module was removed
new_module = types.ModuleType
import traceback
import random
import os
import inspect
import types
from collections import deque
import ptvsd.util as _vspu

Expand Down Expand Up @@ -557,7 +564,7 @@ def __init__(self, mod_name='__main__'):
self.exec_mod = Scope()
self.exec_mod.__name__ = '__main__'
else:
self.exec_mod = imp.new_module(mod_name)
self.exec_mod = new_module(mod_name)
# On 2.6, the below messes up the globals of the calling script
# if it is in sys.modules of the same name.
if sys.version_info >= (2, 7):
Expand Down
12 changes: 9 additions & 3 deletions Python/Product/PythonTools/ptvsd/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
# attach scenario, it is loaded on the injected debugger attach thread, and if threading module
# hasn't been loaded already, it will assume that the thread on which it is being loaded is the
# main thread. This will cause issues when the thread goes away after attach completes.

import imp
import types
try:
# Python < 3.12
import imp
new_module = imp.new_module
except ImportError:
# Python >= 3.12 - imp module was removed
new_module = types.ModuleType
import os
import sys
import struct
Expand Down Expand Up @@ -72,7 +78,7 @@ def exec_code(code, file, global_variables):

global_variables = dict(global_variables)
mod_name = global_variables.setdefault('__name__', '<run_path>')
mod = sys.modules[mod_name] = imp.new_module(mod_name)
mod = sys.modules[mod_name] = new_module(mod_name)
mod.__dict__.update(global_variables)
global_variables = mod.__dict__
global_variables.setdefault('__file__', file)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "ptvs",
"private": true,
"devDependencies": {
"@pylance/pylance": "2025.6.2"
"@pylance/pylance": "2025.7.1"
}
}