Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit76b0d7e

Browse files
committed
Drop Python 2 support
1 parent9fb545a commit76b0d7e

17 files changed

+222
-730
lines changed

‎.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ python:
66
-3.7
77
-3.6
88
-3.5
9-
-2.7
109

1110
env:
1211
matrix:

‎CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1010
###Added
1111

1212
###Changed
13+
- Drop support for Python 2
1314

1415
###Fixed
1516

‎appveyor.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build: off
33

44
image:
55
-Visual Studio 2017
6-
6+
77
platform:
88
-x86
99
-x64
@@ -23,13 +23,10 @@ environment:
2323
BUILD_OPTS:--xplat
2424
-PYTHON_VERSION:3.5
2525
BUILD_OPTS:--xplat
26-
-PYTHON_VERSION:2.7
27-
BUILD_OPTS:--xplat
2826
-PYTHON_VERSION:3.8
2927
-PYTHON_VERSION:3.7
3028
-PYTHON_VERSION:3.6
3129
-PYTHON_VERSION:3.5
32-
-PYTHON_VERSION:2.7
3330

3431
init:
3532
# Update Environment Variables based on matrix/platform

‎setup.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,11 @@ def build_extension(self, ext):
255255

256256
# Up to Python 3.2 sys.maxunicode is used to determine the size of
257257
# Py_UNICODE, but from 3.3 onwards Py_UNICODE is a typedef of wchar_t.
258-
# TODO: Is this doing the right check for Py27?
259-
ifsys.version_info[:2]<= (3,2):
260-
unicode_width=2ifsys.maxunicode<0x10FFFFelse4
261-
else:
262-
importctypes
263-
264-
unicode_width=ctypes.sizeof(ctypes.c_wchar)
258+
importctypes
259+
unicode_width=ctypes.sizeof(ctypes.c_wchar)
265260

266261
defines= [
267262
"PYTHON{0}{1}".format(PY_MAJOR,PY_MINOR),
268-
"PYTHON{0}".format(PY_MAJOR),# Python Major Version
269263
"UCS{0}".format(unicode_width),
270264
]
271265

@@ -274,7 +268,6 @@ def build_extension(self, ext):
274268

275269
ifsys.platform!="win32"and (DEVTOOLS=="Mono"orDEVTOOLS=="dotnet"):
276270
on_darwin=sys.platform=="darwin"
277-
defines.append("MONO_OSX"ifon_darwinelse"MONO_LINUX")
278271

279272
# Check if --enable-shared was set when Python was built
280273
enable_shared=sysconfig.get_config_var("Py_ENABLE_SHARED")
@@ -645,8 +638,6 @@ def run(self):
645638
"Intended Audience :: Developers",
646639
"License :: OSI Approved :: MIT License",
647640
"Programming Language :: C#",
648-
"Programming Language :: Python :: 2",
649-
"Programming Language :: Python :: 2.7",
650641
"Programming Language :: Python :: 3",
651642
"Programming Language :: Python :: 3.5",
652643
"Programming Language :: Python :: 3.6",

‎src/clrmodule/ClrModule.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@
3030

3131
publicclassclrModule
3232
{
33-
#ifPYTHON3
3433
[DllExport("PyInit_clr",CallingConvention.StdCall)]
3534
publicstaticIntPtrPyInit_clr()
36-
#elifPYTHON2
37-
[DllExport("initclr",CallingConvention.StdCall)]
38-
publicstaticvoidinitclr()
39-
#endif
4035
{
4136
DebugPrint("Attempting to load 'Python.Runtime' using standard binding rules.");
4237
#ifUSE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
@@ -95,23 +90,15 @@ public static void initclr()
9590
catch(InvalidOperationException)
9691
{
9792
DebugPrint("Could not load 'Python.Runtime'.");
98-
#ifPYTHON3
9993
returnIntPtr.Zero;
100-
#elifPYTHON2
101-
return;
102-
#endif
10394
}
10495
}
10596

10697
// Once here, we've successfully loaded SOME version of Python.Runtime
10798
// So now we get the PythonEngine and execute the InitExt method on it.
10899
TypepythonEngineType=pythonRuntime.GetType("Python.Runtime.PythonEngine");
109100

110-
#ifPYTHON3
111101
return(IntPtr)pythonEngineType.InvokeMember("InitExt",BindingFlags.InvokeMethod,null,null,null);
112-
#elifPYTHON2
113-
pythonEngineType.InvokeMember("InitExt",BindingFlags.InvokeMethod,null,null,null);
114-
#endif
115102
}
116103

117104
/// <summary>

‎src/embed_tests/TestCallbacks.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public void TestNoOverloadException() {
2525
dynamiccallWith42=PythonEngine.Eval("lambda f: f([42])");
2626
varerror=Assert.Throws<PythonException>(()=>callWith42(aFunctionThatCallsIntoPython.ToPython()));
2727
Assert.AreEqual("TypeError",error.PythonTypeName);
28-
stringexpectedArgTypes=Runtime.IsPython2
29-
?"(<type 'list'>)"
30-
:"(<class 'list'>)";
28+
stringexpectedArgTypes="(<class 'list'>)";
3129
StringAssert.EndsWith(expectedArgTypes,error.Message);
3230
}
3331
}

‎src/runtime/CustomMarshaler.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ public static int GetUnicodeByteLength(IntPtr p)
120120
/// </remarks>
121121
publicstaticIntPtrPy3UnicodePy2StringtoPtr(strings)
122122
{
123-
returnRuntime.IsPython3
124-
?Instance.MarshalManagedToNative(s)
125-
:Marshal.StringToHGlobalAnsi(s);
123+
returnInstance.MarshalManagedToNative(s);
126124
}
127125

128126
/// <summary>
@@ -137,9 +135,7 @@ public static IntPtr Py3UnicodePy2StringtoPtr(string s)
137135
/// </returns>
138136
publicstaticstringPtrToPy3UnicodePy2String(IntPtrp)
139137
{
140-
returnRuntime.IsPython3
141-
?PtrToStringUni(p)
142-
:Marshal.PtrToStringAnsi(p);
138+
returnPtrToStringUni(p);
143139
}
144140
}
145141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp