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

Add support for python 3.10 #6891

Merged
merged 5 commits into from
Feb 28, 2022
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/17.0/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<package id="Microsoft.DotNet.PlatformAbstractions" version="2.1.0" />
<package id="Microsoft.Extensions.FileSystemGlobbing" version="3.1.8" />
<!-- keep in sync with Python\Product\Core\Properties\AssemblyInfo.cs -->
<package id="Microsoft.Python.Parsing" version="0.646.0" />
<package id="Microsoft.Python.Parsing" version="0.655.0" />
<package id="Microsoft.VisualStudio.ComponentModelHost" version = "17.0.56-gb3c64827ce" />
<package id="Microsoft.VisualStudio.Composition" version = "16.9.20" />
<package id="Microsoft.VisualStudio.CoreUtility" version = "17.0.56-gb3c64827ce" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public enum PythonLanguageVersion {
V36 = 0x0306,
V37 = 0x0307,
V38 = 0x0308,
V39 = 0x0309
V39 = 0x0309,
V310 = 0x0310
}

public static class PythonLanguageVersionExtensions {
Expand Down Expand Up @@ -85,6 +86,7 @@ public static PythonLanguageVersion ToLanguageVersion(this Version version) {
case 7: return PythonLanguageVersion.V37;
case 8: return PythonLanguageVersion.V38;
case 9: return PythonLanguageVersion.V39;
case 10: return PythonLanguageVersion.V310;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Python/Product/Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

internal static class ParserNuGetPackageInfo {
// important: keep in sync with Build\17.0\package.config
public const string Version = "0.646.0";
public const string Version = "0.655.0";
public const string Culture = "neutral";
public const string PublicKeyToken = "b03f5f7f11d50a3a";
}
1 change: 1 addition & 0 deletions Python/Product/Debugger.Concord/PythonRuntimeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public static PythonLanguageVersion GetPythonLanguageVersion(DkmNativeModuleInst
case "37": return PythonLanguageVersion.V37;
case "38": return PythonLanguageVersion.V38;
case "39": return PythonLanguageVersion.V39;
case "310": return PythonLanguageVersion.V310;
default: return PythonLanguageVersion.None;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ sealed class ConfigurationEnvironmentView : INotifyPropertyChanged {
"3.6",
"3.7",
"3.8",
"3.9",
"3.10"
};

private readonly EnvironmentView _view;
Expand Down
44 changes: 34 additions & 10 deletions Python/Product/PyDebugAttach/PyDebugAttach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,10 @@ DWORD GetPythonThreadId(PythonVersion version, PyThreadState* curThread) {
threadId = (DWORD)((PyThreadState_30_33*)curThread)->thread_id;
} else if (PyThreadState_34_36::IsFor(version)) {
threadId = (DWORD)((PyThreadState_34_36*)curThread)->thread_id;
} else if (PyThreadState_37::IsFor(version)) {
threadId = (DWORD)((PyThreadState_37*)curThread)->thread_id;
} else if (PyThreadState_37_39::IsFor(version)) {
threadId = (DWORD)((PyThreadState_37_39*)curThread)->thread_id;
} else if (PyThreadState_310::IsFor(version)) {
threadId = (DWORD)((PyThreadState_310*)curThread)->thread_id;
}
return threadId;
}
Expand Down Expand Up @@ -1101,8 +1103,10 @@ bool DoAttach(HMODULE module, ConnectionInfo& connInfo, bool isDebug) {
frame = ((PyThreadState_30_33*)curThread)->frame;
} else if (PyThreadState_34_36::IsFor(version)) {
frame = ((PyThreadState_34_36*)curThread)->frame;
} else if (PyThreadState_37::IsFor(version)) {
frame = ((PyThreadState_37*)curThread)->frame;
} else if (PyThreadState_37_39::IsFor(version)) {
frame = ((PyThreadState_37_39*)curThread)->frame;
} else if (PyThreadState_310::IsFor(version)) {
frame = ((PyThreadState_310*)curThread)->frame;
} else {
_ASSERTE(false);
frame = nullptr; // prevent compiler warning
Expand Down Expand Up @@ -1151,13 +1155,29 @@ bool DoAttach(HMODULE module, ConnectionInfo& connInfo, bool isDebug) {
// update all of the frames so they have our trace func
auto curFrame = (PyFrameObject*)GetPyObjectPointerNoDebugInfo(isDebug, frame);
while (curFrame != nullptr) {

PyObject **f_trace = nullptr;

if (PyFrameObject25_33::IsFor(version)) {
f_trace = &((PyFrameObject25_33*)curFrame)->f_trace;
} else if (PyFrameObject34_36::IsFor(version)) {
f_trace = &((PyFrameObject34_36*)curFrame)->f_trace;
} else if (PyFrameObject37_39::IsFor(version)) {
f_trace = &((PyFrameObject37_39*)curFrame)->f_trace;
} else if (PyFrameObject310::IsFor(version)) {
f_trace = &((PyFrameObject310*)curFrame)->f_trace;
} else {
_ASSERTE(false);
break;
}

// Special case for CFrame objects
// Stackless CFrame does not have a trace function
// This will just prevent a crash on attach.
if (((PyObject*)curFrame)->ob_type != PyCFrame_Type) {
DecRef(curFrame->f_trace, isDebug);
DecRef(*f_trace, isDebug);
IncRef(*traceFunc);
curFrame->f_trace = traceFunc.ToPython();
*f_trace = traceFunc.ToPython();
}
curFrame = (PyFrameObject*)GetPyObjectPointerNoDebugInfo(isDebug, curFrame->f_back);
}
Expand Down Expand Up @@ -1310,8 +1330,10 @@ int TraceGeneral(int interpreterId, PyObject *obj, PyFrameObject *frame, int wha
((PyThreadState_30_33*)curThread)->c_tracefunc(((PyThreadState_30_33*)curThread)->c_traceobj, frame, what, arg);
} else if (PyThreadState_34_36::IsFor(version)) {
((PyThreadState_34_36*)curThread)->c_tracefunc(((PyThreadState_34_36*)curThread)->c_traceobj, frame, what, arg);
} else if (PyThreadState_37::IsFor(version)) {
((PyThreadState_37*)curThread)->c_tracefunc(((PyThreadState_37*)curThread)->c_traceobj, frame, what, arg);
} else if (PyThreadState_37_39::IsFor(version)) {
((PyThreadState_37_39*)curThread)->c_tracefunc(((PyThreadState_37_39*)curThread)->c_traceobj, frame, what, arg);
} else if (PyThreadState_310::IsFor(version)) {
((PyThreadState_310*)curThread)->c_tracefunc(((PyThreadState_310*)curThread)->c_traceobj, frame, what, arg);
}
}
return 0;
Expand Down Expand Up @@ -1357,8 +1379,10 @@ void SetInitialTraceFunc(DWORD interpreterId, PyThreadState *thread) {
gilstate_counter = ((PyThreadState_30_33*)thread)->gilstate_counter;
} else if (PyThreadState_34_36::IsFor(version)) {
gilstate_counter = ((PyThreadState_34_36*)thread)->gilstate_counter;
} else if (PyThreadState_37::IsFor(version)) {
gilstate_counter = ((PyThreadState_37*)thread)->gilstate_counter;
} else if (PyThreadState_37_39::IsFor(version)) {
gilstate_counter = ((PyThreadState_37_39*)thread)->gilstate_counter;
} else if (PyThreadState_310::IsFor(version)) {
gilstate_counter = ((PyThreadState_310*)thread)->gilstate_counter;
}

if (gilstate_counter == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.5" CommandParameter="python=3.5"/>
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.6" CommandParameter="python=3.6"/>
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.7" CommandParameter="python=3.7"/>
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.8" CommandParameter="python=3.8"/>
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.9" CommandParameter="python=3.9"/>
<MenuItem Style="{StaticResource PackageItem}" Header="Python 3.10" CommandParameter="python=3.10"/>
</MenuItem>
<MenuItem Style="{StaticResource PackageFolder}" Header="{x:Static common:Strings.CondaPackageDataScienceCoreLibs}">
<MenuItem Style="{StaticResource PackageItem}" Header="NumPy" CommandParameter="numpy"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ ProjectView selectedProject
"3.6",
"3.7",
"3.8",
"3.9",
"3.10"
};

public static readonly DependencyProperty InterpretersProperty =
Expand Down
26 changes: 10 additions & 16 deletions Python/Product/VsPyProf/PythonApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,14 @@ VsPyProf* VsPyProf::Create(HMODULE pythonModule) {
pyFuncType != NULL && pyModuleType != NULL) {
auto version = getVersion();
if (version != NULL) {
// parse version like "2.7"
int major = atoi(version);
int minor = 0;
while (*version && *version >= '0' && *version <= '9') {
version++;
}
if (*version == '.') {
version++;
minor = atoi(version);
}

if ((major == 2 && (minor >= 4 && minor <= 7)) ||
(major == 3 && (minor >= 0 && minor <= 9))) {
PythonVersionMajMin pythonVer = GetPythonVersionFromVersionString(version);

if ((pythonVer.major == 2 && (pythonVer.minor >= 4 && pythonVer.minor <= 7)) ||
(pythonVer.major == 3 && (pythonVer.minor >= 0 && pythonVer.minor <= 10))) {
return new VsPyProf(pythonModule,
major,
minor,
pythonVer.major,
pythonVer.minor,
enterFunction,
exitFunction,
nameToken,
Expand Down Expand Up @@ -282,8 +274,10 @@ wstring VsPyProf::GetClassNameFromFrame(PyFrameObject* frameObj, PyObject *codeO
self = ((PyFrameObject25_33*)frameObj)->f_localsplus[0];
} else if (PyFrameObject34_36::IsFor(MajorVersion, MinorVersion)) {
self = ((PyFrameObject34_36*)frameObj)->f_localsplus[0];
} else if (PyFrameObject37::IsFor(MajorVersion, MinorVersion)) {
self = ((PyFrameObject37*)frameObj)->f_localsplus[0];
} else if (PyFrameObject37_39::IsFor(MajorVersion, MinorVersion)) {
self = ((PyFrameObject37_39*)frameObj)->f_localsplus[0];
} else if (PyFrameObject310::IsFor(MajorVersion, MinorVersion)) {
self = ((PyFrameObject310*)frameObj)->f_localsplus[0];
}
return GetClassNameFromSelf(self, codeObj);
}
Expand Down
Loading