Skip to content

Commit c3a307f

Browse files
authored
Merge pull request #279 from python/master
Sync Fork from Upstream Repo
2 parents 1dd654f + 0267335 commit c3a307f

25 files changed

+94
-29
lines changed

.azure-pipelines/windows-release/stage-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
displayName: Docs build
44
pool:
55
name: 'Windows Release'
6-
#vmName: win2016-vs2017
6+
#vmImage: windows-2019
77

88
workspace:
99
clean: all
@@ -45,7 +45,7 @@ jobs:
4545
displayName: Python build
4646

4747
pool:
48-
vmName: win2016-vs2017
48+
vmImage: windows-2019
4949

5050
workspace:
5151
clean: all
@@ -91,7 +91,7 @@ jobs:
9191
condition: and(succeeded(), ne(variables['DoPGO'], 'true'))
9292

9393
pool:
94-
vmName: win2016-vs2017
94+
vmImage: windows-2019
9595

9696
workspace:
9797
clean: all
@@ -141,7 +141,7 @@ jobs:
141141
displayName: Publish Tcl/Tk Library
142142

143143
pool:
144-
vmName: windows-latest
144+
vmImage: windows-2019
145145

146146
workspace:
147147
clean: all

.azure-pipelines/windows-release/stage-layout-embed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoEmbed'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-layout-full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoLayout'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-layout-msix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
displayName: Make MSIX layout
44

55
pool:
6-
vmName: win2016-vs2017
6+
vmImage: windows-2019
77

88
workspace:
99
clean: all

.azure-pipelines/windows-release/stage-layout-nuget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoNuget'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), not(variables['SigningCertificate']))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
variables:
1010
ReleaseUri: http://www.python.org/{arch}

.azure-pipelines/windows-release/stage-pack-msix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
displayName: Pack MSIX bundles
44

55
pool:
6-
vmName: win2016-vs2017
6+
vmImage: windows-2019
77

88
workspace:
99
clean: all

.azure-pipelines/windows-release/stage-pack-nuget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoNuget'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-publish-nugetorg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoNuget'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-publish-pythonorg.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), and(eq(variables['DoMSI'], 'true'), eq(variables['DoEmbed'], 'true')))
55

66
pool:
7-
#vmName: win2016-vs2017
7+
#vmImage: windows-2019
88
name: 'Windows Release'
99

1010
workspace:

.azure-pipelines/windows-release/stage-publish-store.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoMSIX'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-sign.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
condition: and(succeeded(), not(variables['SigningCertificate']))
115115

116116
pool:
117-
vmName: win2016-vs2017
117+
vmImage: windows-2019
118118

119119
steps:
120120
- checkout: none

.azure-pipelines/windows-release/stage-test-embed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoEmbed'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

.azure-pipelines/windows-release/stage-test-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
displayName: Test MSI
44

55
pool:
6-
vmName: win2016-vs2017
6+
vmImage: windows-2019
77

88
workspace:
99
clean: all

.azure-pipelines/windows-release/stage-test-nuget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
condition: and(succeeded(), eq(variables['DoNuget'], 'true'))
55

66
pool:
7-
vmName: win2016-vs2017
7+
vmImage: windows-2019
88

99
workspace:
1010
clean: all

Doc/library/compileall.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ runtime.
143143
Public functions
144144
----------------
145145

146-
.. function:: compile_dir(dir, maxlevels=sys.getrecursionlimit(), ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, stripdir=None, prependdir=None, limit_sl_dest=None)
146+
.. function:: compile_dir(dir, maxlevels=sys.getrecursionlimit(), ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, invalidation_mode=None, \*, stripdir=None, prependdir=None, limit_sl_dest=None)
147147

148148
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
149149
files along the way. Return a true value if all the files compiled successfully,
@@ -221,7 +221,7 @@ Public functions
221221
.. versionchanged:: 3.9
222222
Added *stripdir*, *prependdir* and *limit_sl_dest* arguments.
223223

224-
.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None)
224+
.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, invalidation_mode=None, \*, stripdir=None, prependdir=None, limit_sl_dest=None)
225225

226226
Compile the file with path *fullname*. Return a true value if the file
227227
compiled successfully, and a false value otherwise.

Doc/library/token.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ the :mod:`tokenize` module.
8787
now tokenized as :data:`NAME` tokens.
8888

8989
.. versionchanged:: 3.8
90-
Added :data:`TYPE_COMMENT`.
90+
Added :data:`TYPE_COMMENT`, :data:`TYPE_IGNORE`, :data:`COLONEQUAL`.
9191
Added :data:`AWAIT` and :data:`ASYNC` tokens back (they're needed
9292
to support parsing older Python versions for :func:`ast.parse` with
9393
``feature_version`` set to 6 or lower).

Lib/compileall.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _walk_dir(dir, maxlevels, quiet=0):
4646

4747
def compile_dir(dir, maxlevels=None, ddir=None, force=False,
4848
rx=None, quiet=0, legacy=False, optimize=-1, workers=1,
49-
invalidation_mode=None, stripdir=None,
49+
invalidation_mode=None, *, stripdir=None,
5050
prependdir=None, limit_sl_dest=None):
5151
"""Byte-compile all modules in the given directory tree.
5252
@@ -72,6 +72,13 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
7272
the defined path
7373
"""
7474
ProcessPoolExecutor = None
75+
if ddir is not None and (stripdir is not None or prependdir is not None):
76+
raise ValueError(("Destination dir (ddir) cannot be used "
77+
"in combination with stripdir or prependdir"))
78+
if ddir is not None:
79+
stripdir = dir
80+
prependdir = ddir
81+
ddir = None
7582
if workers < 0:
7683
raise ValueError('workers must be greater or equal to 0')
7784
if workers != 1:
@@ -111,7 +118,7 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False,
111118

112119
def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
113120
legacy=False, optimize=-1,
114-
invalidation_mode=None, stripdir=None, prependdir=None,
121+
invalidation_mode=None, *, stripdir=None, prependdir=None,
115122
limit_sl_dest=None):
116123
"""Byte-compile one file.
117124

Lib/test/test_compileall.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,47 @@ def test_compile_dir_maxlevels(self):
212212
compileall.compile_dir(self.directory, quiet=True, maxlevels=depth)
213213
self.assertTrue(os.path.isfile(pyc_filename))
214214

215+
def _test_ddir_only(self, *, ddir, parallel=True):
216+
"""Recursive compile_dir ddir must contain package paths; bpo39769."""
217+
fullpath = ["test", "foo"]
218+
path = self.directory
219+
mods = []
220+
for subdir in fullpath:
221+
path = os.path.join(path, subdir)
222+
os.mkdir(path)
223+
script_helper.make_script(path, "__init__", "")
224+
mods.append(script_helper.make_script(path, "mod",
225+
"def fn(): 1/0\nfn()\n"))
226+
compileall.compile_dir(
227+
self.directory, quiet=True, ddir=ddir,
228+
workers=2 if parallel else 1)
229+
self.assertTrue(mods)
230+
for mod in mods:
231+
self.assertTrue(mod.startswith(self.directory), mod)
232+
modcode = importlib.util.cache_from_source(mod)
233+
modpath = mod[len(self.directory+os.sep):]
234+
_, _, err = script_helper.assert_python_failure(modcode)
235+
expected_in = os.path.join(ddir, modpath)
236+
mod_code_obj = test.test_importlib.util.get_code_from_pyc(modcode)
237+
self.assertEqual(mod_code_obj.co_filename, expected_in)
238+
self.assertIn(f'"{expected_in}"', os.fsdecode(err))
239+
240+
def test_ddir_only_one_worker(self):
241+
"""Recursive compile_dir ddir= contains package paths; bpo39769."""
242+
return self._test_ddir_only(ddir="<a prefix>", parallel=False)
243+
244+
def test_ddir_multiple_workers(self):
245+
"""Recursive compile_dir ddir= contains package paths; bpo39769."""
246+
return self._test_ddir_only(ddir="<a prefix>", parallel=True)
247+
248+
def test_ddir_empty_only_one_worker(self):
249+
"""Recursive compile_dir ddir='' contains package paths; bpo39769."""
250+
return self._test_ddir_only(ddir="", parallel=False)
251+
252+
def test_ddir_empty_multiple_workers(self):
253+
"""Recursive compile_dir ddir='' contains package paths; bpo39769."""
254+
return self._test_ddir_only(ddir="", parallel=True)
255+
215256
def test_strip_only(self):
216257
fullpath = ["test", "build", "real", "path"]
217258
path = os.path.join(self.directory, *fullpath)

Lib/test/test_importlib/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from importlib import machinery, util, invalidate_caches
88
from importlib.abc import ResourceReader
99
import io
10+
import marshal
1011
import os
1112
import os.path
1213
from pathlib import Path, PurePath
@@ -118,6 +119,16 @@ def submodule(parent, name, pkg_dir, content=''):
118119
return '{}.{}'.format(parent, name), path
119120

120121

122+
def get_code_from_pyc(pyc_path):
123+
"""Reads a pyc file and returns the unmarshalled code object within.
124+
125+
No header validation is performed.
126+
"""
127+
with open(pyc_path, 'rb') as pyc_f:
128+
pyc_f.seek(16)
129+
return marshal.load(pyc_f)
130+
131+
121132
@contextlib.contextmanager
122133
def uncache(*names):
123134
"""Uncache a module from sys.modules.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update :mod:`token` documentation to reflect additions in Python 3.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The :func:`compileall.compile_dir` function's *ddir* parameter and the
2+
compileall command line flag `-d` no longer write the wrong pathname to the
3+
generated pyc file for submodules beneath the root of the directory tree
4+
being compiled. This fixes a regression introduced with Python 3.5.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update Windows release build machines to Visual Studio 2019 (MSVC 14.2).

PC/layout/support/nuspec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
NUSPEC_DATA = {
1515
"PYTHON_TAG": VER_DOT,
1616
"PYTHON_VERSION": os.getenv("PYTHON_NUSPEC_VERSION"),
17-
"FILELIST": r' <file src="**\*" target="tools" />',
17+
"FILELIST": r' <file src="**\*" exclude="python.png" target="tools" />',
1818
"GIT": sys._git,
1919
}
2020

@@ -31,7 +31,7 @@
3131
VER_DOT, VER_MICRO, "-" if VER_SUFFIX else "", VER_SUFFIX
3232
)
3333

34-
FILELIST_WITH_PROPS = r""" <file src="**\*" exclude="python.props" target="tools" />
34+
FILELIST_WITH_PROPS = r""" <file src="**\*" exclude="python.png;python.props" target="tools" />
3535
<file src="python.props" target="build\native" />"""
3636

3737
NUSPEC_TEMPLATE = r"""<?xml version="1.0"?>
@@ -44,13 +44,13 @@
4444
<license type="file">tools\LICENSE.txt</license>
4545
<projectUrl>https://www.python.org/</projectUrl>
4646
<description>Installs {PYTHON_BITNESS} Python for use in build scenarios.</description>
47-
<icon>images\logox128.png</icon>
47+
<icon>images\python.png</icon>
4848
<iconUrl>https://www.python.org/static/favicon.ico</iconUrl>
4949
<tags>python</tags>
5050
<repository type="git" url="https://github.com/Python/CPython.git" commit="{GIT[2]}" />
5151
</metadata>
5252
<files>
53-
<file src="{LOGO}" target="images" />
53+
<file src="python.png" target="images" />
5454
{FILELIST}
5555
</files>
5656
</package>
@@ -73,6 +73,6 @@ def get_nuspec_layout(ns):
7373
data[k] = v
7474
if ns.include_all or ns.include_props:
7575
data["FILELIST"] = FILELIST_WITH_PROPS
76-
data["LOGO"] = ns.source / "PC" / "icons" / "logox128.png"
7776
nuspec = NUSPEC_TEMPLATE.format_map(data)
7877
yield "python.nuspec", ("python.nuspec", nuspec.encode("utf-8"))
78+
yield "python.png", ns.source / "PC" / "icons" / "logox128.png"

Tools/nuget/make_pkg.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<PackageArguments Condition="$(Packages) != ''">"$(IntermediateOutputPath)pkg\pip.exe" -B -m pip install -U $(Packages)</PackageArguments>
3535

36-
<NugetPackCommand>"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).nuspec" -BasePath "$(IntermediateOutputPath)pkg"</NugetPackCommand>
36+
<NugetPackCommand>"$(Nuget)" pack "$(IntermediateOutputPath)pkg\python.nuspec" -BasePath "$(IntermediateOutputPath)pkg"</NugetPackCommand>
3737
<NugetPackSymbolsCommand Condition="Exists('$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec')">"$(Nuget)" pack "$(MSBuildThisFileDirectory)\$(OutputName).symbols.nuspec" -BasePath "$(BuildPath.TrimEnd(`\`))"</NugetPackSymbolsCommand>
3838
<NugetArguments>$(NugetArguments) -OutputDirectory "$(OutputPath.Trim(`\`))"</NugetArguments>
3939
<NugetArguments>$(NugetArguments) -Version "$(NuspecVersion)"</NugetArguments>

0 commit comments

Comments
 (0)