Skip to content

Commit 39e20e3

Browse files
committed
Merge branch 'master' into soft-shutdown
2 parents 4f00165 + ec424bb commit 39e20e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+203
-1008
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:

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@
7474
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
7575
- ([@stonebig](https://github.com/stonebig))
7676
- ([@testrunner123](https://github.com/testrunner123))
77+
- ([@DanBarzilian](https://github.com/DanBarzilian))
7778

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ 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

17+
- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
18+
- Fix incorrect dereference in params array handling
19+
1620
## [2.5.0][] - 2020-06-14
1721

1822
This version improves performance on benchmarks significantly compared to 2.3.

appveyor.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ environment:
2424
BUILD_OPTS: --xplat
2525
- PYTHON_VERSION: 3.5
2626
BUILD_OPTS: --xplat
27-
- PYTHON_VERSION: 2.7
28-
BUILD_OPTS: --xplat
2927
- PYTHON_VERSION: 3.8
3028
- PYTHON_VERSION: 3.7
3129
- PYTHON_VERSION: 3.6
3230
- PYTHON_VERSION: 3.5
33-
- PYTHON_VERSION: 2.7
3431

3532
matrix:
3633
- PYTHON_VERSION: 3.7

setup.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@
150150
def _check_output(*args, **kwargs):
151151
"""Check output wrapper for py2/py3 compatibility"""
152152
output = subprocess.check_output(*args, **kwargs)
153-
if PY_MAJOR == 2:
154-
return output
155153
return output.decode("ascii")
156154

157155

@@ -255,17 +253,11 @@ def build_extension(self, ext):
255253

256254
# Up to Python 3.2 sys.maxunicode is used to determine the size of
257255
# 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-
if sys.version_info[:2] <= (3, 2):
260-
unicode_width = 2 if sys.maxunicode < 0x10FFFF else 4
261-
else:
262-
import ctypes
263-
264-
unicode_width = ctypes.sizeof(ctypes.c_wchar)
256+
import ctypes
257+
unicode_width = ctypes.sizeof(ctypes.c_wchar)
265258

266259
defines = [
267260
"PYTHON{0}{1}".format(PY_MAJOR, PY_MINOR),
268-
"PYTHON{0}".format(PY_MAJOR), # Python Major Version
269261
"UCS{0}".format(unicode_width),
270262
]
271263

@@ -274,7 +266,6 @@ def build_extension(self, ext):
274266

275267
if sys.platform != "win32" and (DEVTOOLS == "Mono" or DEVTOOLS == "dotnet"):
276268
on_darwin = sys.platform == "darwin"
277-
defines.append("MONO_OSX" if on_darwin else "MONO_LINUX")
278269

279270
# Check if --enable-shared was set when Python was built
280271
enable_shared = sysconfig.get_config_var("Py_ENABLE_SHARED")
@@ -288,6 +279,9 @@ def build_extension(self, ext):
288279
if not enable_shared:
289280
defines.append("PYTHON_WITHOUT_ENABLE_SHARED")
290281

282+
if sys.platform == "win32":
283+
defines.append("WINDOWS")
284+
291285
if hasattr(sys, "abiflags"):
292286
if "d" in sys.abiflags:
293287
defines.append("PYTHON_WITH_PYDEBUG")
@@ -479,10 +473,7 @@ def _find_msbuild_tool(self, tool="msbuild.exe", use_windows_sdk=False):
479473
return path
480474

481475
# Search within registry to find build tools
482-
try: # PY2
483-
import _winreg as winreg
484-
except ImportError: # PY3
485-
import winreg
476+
import winreg
486477

487478
_collect_installed_windows_kits_v10(winreg)
488479

@@ -645,8 +636,6 @@ def run(self):
645636
"Intended Audience :: Developers",
646637
"License :: OSI Approved :: MIT License",
647638
"Programming Language :: C#",
648-
"Programming Language :: Python :: 2",
649-
"Programming Language :: Python :: 2.7",
650639
"Programming Language :: Python :: 3",
651640
"Programming Language :: Python :: 3.5",
652641
"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
public class clrModule
3232
{
33-
#if PYTHON3
3433
[DllExport("PyInit_clr", CallingConvention.StdCall)]
3534
public static IntPtr PyInit_clr()
36-
#elif PYTHON2
37-
[DllExport("initclr", CallingConvention.StdCall)]
38-
public static void initclr()
39-
#endif
4035
{
4136
DebugPrint("Attempting to load 'Python.Runtime' using standard binding rules.");
4237
#if USE_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-
#if PYTHON3
9993
return IntPtr.Zero;
100-
#elif PYTHON2
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
Type pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");
109100

110-
#if PYTHON3
111101
return (IntPtr)pythonEngineType.InvokeMember("InitExt", BindingFlags.InvokeMethod, null, null, null);
112-
#elif PYTHON2
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
dynamic callWith42 = PythonEngine.Eval("lambda f: f([42])");
2626
var error = Assert.Throws<PythonException>(() => callWith42(aFunctionThatCallsIntoPython.ToPython()));
2727
Assert.AreEqual("TypeError", error.PythonTypeName);
28-
string expectedArgTypes = Runtime.IsPython2
29-
? "(<type 'list'>)"
30-
: "(<class 'list'>)";
28+
string expectedArgTypes = "(<class 'list'>)";
3129
StringAssert.EndsWith(expectedArgTypes, error.Message);
3230
}
3331
}

src/embed_tests/TestPythonEngineProperties.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,6 @@ public void SetProgramName()
180180
[Test]
181181
public void SetPythonPath()
182182
{
183-
if (Runtime.Runtime.pyversion == "2.7")
184-
{
185-
// Assert.Skip outputs as a warning (ie. pending to fix)
186-
Assert.Pass();
187-
}
188-
189183
PythonEngine.Initialize();
190184
string path = PythonEngine.PythonPath;
191185
PythonEngine.Shutdown();
@@ -196,25 +190,5 @@ public void SetPythonPath()
196190
Assert.AreEqual(path, PythonEngine.PythonPath);
197191
PythonEngine.Shutdown();
198192
}
199-
200-
[Test]
201-
public void SetPythonPathExceptionOn27()
202-
{
203-
if (Runtime.Runtime.pyversion != "2.7")
204-
{
205-
Assert.Pass();
206-
}
207-
208-
PythonEngine.Initialize();
209-
string path = PythonEngine.PythonPath;
210-
PythonEngine.Shutdown();
211-
212-
var ex = Assert.Throws<NotSupportedException>(() => PythonEngine.PythonPath = "foo");
213-
Assert.AreEqual("Set PythonPath not supported on Python 2", ex.Message);
214-
215-
PythonEngine.Initialize();
216-
Assert.AreEqual(path, PythonEngine.PythonPath);
217-
PythonEngine.Shutdown();
218-
}
219193
}
220194
}

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
public static IntPtr Py3UnicodePy2StringtoPtr(string s)
122122
{
123-
return Runtime.IsPython3
124-
? Instance.MarshalManagedToNative(s)
125-
: Marshal.StringToHGlobalAnsi(s);
123+
return Instance.MarshalManagedToNative(s);
126124
}
127125

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

src/runtime/Python.Runtime.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
<Compile Include="$(PythonInteropFile)" />
163163
</ItemGroup>
164164
<ItemGroup Condition=" '$(PythonInteropFile)' == '' ">
165-
<Compile Include="interop27.cs" />
166165
<Compile Include="interop34.cs" />
167166
<Compile Include="interop35.cs" />
168167
<Compile Include="interop36.cs" />
@@ -186,4 +185,4 @@
186185
<Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
187186
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
188187
</Target>
189-
</Project>
188+
</Project>

0 commit comments

Comments
 (0)