View | Details | Raw Unified | Return to bug 249597
Collapse All | Expand All

(-)databases/mongodb36/Makefile (-2 / +2 lines)
Lines 23-29 Link Here
23
ONLY_FOR_ARCHS=	aarch64 amd64
23
ONLY_FOR_ARCHS=	aarch64 amd64
24
ONLY_FOR_ARCHS_REASON=	"Only supported on amd64 and aarch64 (i386 deprecated in v3)"
24
ONLY_FOR_ARCHS_REASON=	"Only supported on amd64 and aarch64 (i386 deprecated in v3)"
25
25
26
BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}cheetah>=2.4.4:devel/py-cheetah@${PY_FLAVOR} \
26
BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}cheetah3>0:devel/py-cheetah3@${PY_FLAVOR} \
27
		${PY_TYPING} \
27
		${PY_TYPING} \
28
		${PYTHON_PKGNAMEPREFIX}yaml>=3.11:devel/py-yaml@${PY_FLAVOR}
28
		${PYTHON_PKGNAMEPREFIX}yaml>=3.11:devel/py-yaml@${PY_FLAVOR}
29
LIB_DEPENDS=	libboost_system.so:devel/boost-libs \
29
LIB_DEPENDS=	libboost_system.so:devel/boost-libs \
Lines 30-36 Link Here
30
		libpcre.so:devel/pcre \
30
		libpcre.so:devel/pcre \
31
		libsnappy.so:archivers/snappy
31
		libsnappy.so:archivers/snappy
32
32
33
USES=		compiler:c++14-lang cpe python:2.7,build scons:python2 shebangfix
33
USES=		compiler:c++14-lang cpe python:3.5+,build scons shebangfix
34
USE_RC_SUBR=	mongod
34
USE_RC_SUBR=	mongod
35
35
36
CONFLICTS_BUILD=	mongo-cxx-driver
36
CONFLICTS_BUILD=	mongo-cxx-driver
(-)databases/mongodb36/files/patch-python3 (+1977 lines)
Line 0 Link Here
1
From cbfdc41e1d05aa1bfc298b8bd1a2fae9b3477e87 Mon Sep 17 00:00:00 2001
2
From: MikaelUrankar <mikael.urankar@gmail.com>
3
Date: Sat, 3 Oct 2020 17:26:21 +0200
4
Subject: [PATCH 01/24] Backport SConstruct patch
5
6
---
7
 SConstruct | 61 ++++++++++++++++++++++++++++--------------------------
8
 1 file changed, 32 insertions(+), 29 deletions(-)
9
10
diff --git a/SConstruct b/SConstruct
11
index cd4100e9..63f22862 100644
12
--- SConstruct
13
+++ SConstruct
14
@@ -28,8 +28,8 @@ import mongo.platform as mongo_platform
15
 import mongo.toolchain as mongo_toolchain
16
 import mongo.generators as mongo_generators
17
 
18
-EnsurePythonVersion(2, 7)
19
-EnsureSConsVersion(2, 5)
20
+EnsurePythonVersion(3, 5)
21
+EnsureSConsVersion(3, 0, 4)
22
 
23
 from buildscripts import utils
24
 from buildscripts import moduleconfig
25
@@ -389,7 +389,7 @@ win_version_min_choices = {
26
 }
27
 
28
 add_option('win-version-min',
29
-    choices=win_version_min_choices.keys(),
30
+    choices=list(win_version_min_choices.keys()),
31
     default=None,
32
     help='minimum Windows version to support',
33
     type='choice',
34
@@ -482,7 +482,7 @@ try:
35
 except IOError as e:
36
     # If the file error wasn't because the file is missing, error out
37
     if e.errno != errno.ENOENT:
38
-        print("Error opening version.json: {0}".format(e.strerror))
39
+        print(("Error opening version.json: {0}".format(e.strerror)))
40
         Exit(1)
41
 
42
     version_data = {
43
@@ -491,14 +491,14 @@ except IOError as e:
44
     }
45
 
46
 except ValueError as e:
47
-    print("Error decoding version.json: {0}".format(e))
48
+    print(("Error decoding version.json: {0}".format(e)))
49
     Exit(1)
50
 
51
 # Setup the command-line variables
52
 def variable_shlex_converter(val):
53
     # If the argument is something other than a string, propogate
54
     # it literally.
55
-    if not isinstance(val, basestring):
56
+    if not isinstance(val, str):
57
         return val
58
     parse_mode = get_option('variable-parse-mode')
59
     if parse_mode == 'auto':
60
@@ -563,7 +563,7 @@ def variable_distsrc_converter(val):
61
 
62
 variables_files = variable_shlex_converter(get_option('variables-files'))
63
 for file in variables_files:
64
-    print("Using variable customization file %s" % file)
65
+    print(("Using variable customization file %s" % file))
66
 
67
 env_vars = Variables(
68
     files=variables_files,
69
@@ -572,7 +572,7 @@ env_vars = Variables(
70
 
71
 sconsflags = os.environ.get('SCONSFLAGS', None)
72
 if sconsflags:
73
-    print("Using SCONSFLAGS environment variable arguments: %s" % sconsflags)
74
+    print(("Using SCONSFLAGS environment variable arguments: %s" % sconsflags))
75
 
76
 env_vars.Add('ABIDW',
77
     help="Configures the path to the 'abidw' (a libabigail) utility")
78
@@ -691,7 +691,7 @@ env_vars.Add('MONGO_DISTNAME',
79
 def validate_mongo_version(key, val, env):
80
     regex = r'^(\d+)\.(\d+)\.(\d+)-?((?:(rc)(\d+))?.*)?'
81
     if not re.match(regex, val):
82
-        print("Invalid MONGO_VERSION '{}', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons".format(val))
83
+        print(("Invalid MONGO_VERSION '{}', or could not derive from version.json or git metadata. Please add a conforming MONGO_VERSION=x.y.z[-extra] as an argument to SCons".format(val)))
84
         Exit(1)
85
 
86
 env_vars.Add('MONGO_VERSION',
87
@@ -822,12 +822,12 @@ if installDir[0] not in ['$', '#']:
88
         Exit(1)
89
 
90
 sconsDataDir = Dir(buildDir).Dir('scons')
91
-SConsignFile(str(sconsDataDir.File('sconsign')))
92
+SConsignFile(str(sconsDataDir.File('sconsign.py3')))
93
 
94
 def printLocalInfo():
95
     import sys, SCons
96
-    print( "scons version: " + SCons.__version__ )
97
-    print( "python version: " + " ".join( [ `i` for i in sys.version_info ] ) )
98
+    print(( "scons version: " + SCons.__version__ ))
99
+    print(( "python version: " + " ".join( [ repr(i) for i in sys.version_info ] ) ))
100
 
101
 printLocalInfo()
102
 
103
@@ -904,12 +904,12 @@ env.AddMethod(mongo_platform.env_os_is_wrapper, 'TargetOSIs')
104
 env.AddMethod(mongo_platform.env_get_os_name_wrapper, 'GetTargetOSName')
105
 
106
 def fatal_error(env, msg, *args):
107
-    print(msg.format(*args))
108
+    print((msg.format(*args)))
109
     Exit(1)
110
 
111
 def conf_error(env, msg, *args):
112
-    print(msg.format(*args))
113
-    print("See {0} for details".format(env.File('$CONFIGURELOG').abspath))
114
+    print((msg.format(*args)))
115
+    print(("See {0} for details".format(env.File('$CONFIGURELOG').abspath)))
116
     Exit(1)
117
 
118
 env.AddMethod(fatal_error, 'FatalError')
119
@@ -928,12 +928,12 @@ else:
120
 env.AddMethod(lambda env: env['VERBOSE'], 'Verbose')
121
 
122
 if has_option('variables-help'):
123
-    print(env_vars.GenerateHelpText(env))
124
+    print((env_vars.GenerateHelpText(env)))
125
     Exit(0)
126
 
127
 #unknown_vars = env_vars.UnknownVariables()
128
 #if unknown_vars:
129
-#    env.FatalError("Unknown variables specified: {0}", ", ".join(unknown_vars.keys()))
130
+#    env.FatalError("Unknown variables specified: {0}", ", ".join(list(unknown_vars.keys())))
131
 
132
 def set_config_header_define(env, varname, varval = 1):
133
     env['CONFIG_HEADER_DEFINES'][varname] = varval
134
@@ -1018,7 +1018,7 @@ def CheckForProcessor(context, which_arch):
135
         context.Result(ret)
136
         return ret;
137
 
138
-    for k in processor_macros.keys():
139
+    for k in list(processor_macros.keys()):
140
         ret = run_compile_check(k)
141
         if ret:
142
             context.Result('Detected a %s processor' % k)
143
@@ -1136,7 +1136,7 @@ else:
144
     env['TARGET_ARCH'] = detected_processor
145
 
146
 if env['TARGET_OS'] not in os_macros:
147
-    print("No special config for [{0}] which probably means it won't work".format(env['TARGET_OS']))
148
+    print(("No special config for [{0}] which probably means it won't work".format(env['TARGET_OS'])))
149
 elif not detectConf.CheckForOS(env['TARGET_OS']):
150
     env.ConfError("TARGET_OS ({0}) is not supported by compiler", env['TARGET_OS'])
151
 
152
@@ -1922,7 +1922,7 @@ def doConfigure(myenv):
153
             # form -Wno-xxx (but not -Wno-error=xxx), we also add -Wxxx to the flags. GCC does
154
             # warn on unknown -Wxxx style flags, so this lets us probe for availablity of
155
             # -Wno-xxx.
156
-            for kw in test_mutation.keys():
157
+            for kw in list(test_mutation.keys()):
158
                 test_flags = test_mutation[kw]
159
                 for test_flag in test_flags:
160
                     if test_flag.startswith("-Wno-") and not test_flag.startswith("-Wno-error="):
161
@@ -1936,7 +1936,7 @@ def doConfigure(myenv):
162
         # to make them real errors.
163
         cloned.Append(CCFLAGS=['-Werror'])
164
         conf = Configure(cloned, help=False, custom_tests = {
165
-                'CheckFlag' : lambda(ctx) : CheckFlagTest(ctx, tool, extension, flag)
166
+                'CheckFlag' : lambda ctx : CheckFlagTest(ctx, tool, extension, flag)
167
         })
168
         available = conf.CheckFlag()
169
         conf.Finish()
170
@@ -2408,7 +2408,7 @@ def doConfigure(myenv):
171
             "undefined" : myenv.File("#etc/ubsan.blacklist"),
172
         }
173
 
174
-        blackfiles = set([v for (k, v) in blackfiles_map.iteritems() if k in sanitizer_list])
175
+        blackfiles = {v for (k, v) in blackfiles_map.items() if k in sanitizer_list}
176
         blacklist_options=["-fsanitize-blacklist=%s" % blackfile
177
                            for blackfile in blackfiles
178
                            if os.stat(blackfile.path).st_size != 0]
179
@@ -2420,7 +2420,7 @@ def doConfigure(myenv):
180
         llvm_symbolizer = get_option('llvm-symbolizer')
181
         if os.path.isabs(llvm_symbolizer):
182
             if not myenv.File(llvm_symbolizer).exists():
183
-                print("WARNING: Specified symbolizer '%s' not found" % llvm_symbolizer)
184
+                print(("WARNING: Specified symbolizer '%s' not found" % llvm_symbolizer))
185
                 llvm_symbolizer = None
186
         else:
187
             llvm_symbolizer = myenv.WhereIs(llvm_symbolizer)
188
@@ -2710,7 +2710,7 @@ def doConfigure(myenv):
189
             files = ['ssleay32.dll', 'libeay32.dll']
190
             for extra_file in files:
191
                 if not addOpenSslLibraryToDistArchive(extra_file):
192
-                    print("WARNING: Cannot find SSL library '%s'" % extra_file)
193
+                    print(("WARNING: Cannot find SSL library '%s'" % extra_file))
194
 
195
         # Used to import system certificate keychains
196
         if conf.env.TargetOSIs('darwin'):
197
@@ -2738,7 +2738,7 @@ def doConfigure(myenv):
198
                         # TODO: If we could programmatically extract the paths from the info output
199
                         # we could give a better message here, but brew info's machine readable output
200
                         # doesn't seem to include the whole 'caveats' section.
201
-                        message = subprocess.check_output([brew, "info", "openssl"])
202
+                        message = subprocess.check_output([brew, "info", "openssl"]).decode('utf-8')
203
                         advice = textwrap.dedent(
204
                             """\
205
                             NOTE: HomeBrew installed to {0} appears to have OpenSSL installed.
206
@@ -3114,7 +3114,7 @@ def doConfigure(myenv):
207
 
208
         outputIndex = next((idx for idx in [0,1] if conf.CheckAltivecVbpermqOutput(idx)), None)
209
         if outputIndex is not None:
210
-	    conf.env.SetConfigHeaderDefine("MONGO_CONFIG_ALTIVEC_VEC_VBPERMQ_OUTPUT_INDEX", outputIndex)
211
+            conf.env.SetConfigHeaderDefine("MONGO_CONFIG_ALTIVEC_VEC_VBPERMQ_OUTPUT_INDEX", outputIndex)
212
         else:
213
             myenv.ConfError("Running on ppc64le, but can't find a correct vec_vbpermq output index.  Compiler or platform not supported")
214
 
215
@@ -3176,9 +3176,12 @@ def doLint( env , target , source ):
216
     import buildscripts.pylinters
217
     buildscripts.pylinters.lint_all(None, {}, [])
218
 
219
-    import buildscripts.lint
220
-    if not buildscripts.lint.run_lint( [ "src/mongo/" ] ):
221
-        raise Exception( "lint errors" )
222
+    env.Command(
223
+        target="#run_lint",
224
+        source=["buildscripts/lint.py", "src/mongo"],
225
+        action="$PYTHON $SOURCES[0] $SOURCES[1]",
226
+    )
227
+
228
 
229
 env.Alias( "lint" , [] , [ doLint ] )
230
 env.AlwaysBuild( "lint" )
231
-- 
232
2.28.0
233
234
235
From 81abd3f9ba48ffb27919e574c8d518f4a1d8fbf3 Mon Sep 17 00:00:00 2001
236
From: MikaelUrankar <mikael.urankar@gmail.com>
237
Date: Sat, 3 Oct 2020 17:27:46 +0200
238
Subject: [PATCH 02/24] Backport buildscripts/aggregate_tracefiles.py
239
240
---
241
 buildscripts/aggregate_tracefiles.py | 2 +-
242
 1 file changed, 1 insertion(+), 1 deletion(-)
243
244
diff --git a/buildscripts/aggregate_tracefiles.py b/buildscripts/aggregate_tracefiles.py
245
index 8f1db785..0b4bfd24 100644
246
--- buildscripts/aggregate_tracefiles.py
247
+++ buildscripts/aggregate_tracefiles.py
248
@@ -16,7 +16,7 @@ def aggregate(inputs, output):
249
 
250
     args += ['-o', output]
251
 
252
-    print ' '.join(args)
253
+    print(' '.join(args))
254
     
255
     return subprocess.call(args)  
256
 
257
-- 
258
2.28.0
259
260
261
From 035a04745cb159c2a971180d1d76bca51de9245c Mon Sep 17 00:00:00 2001
262
From: MikaelUrankar <mikael.urankar@gmail.com>
263
Date: Sat, 3 Oct 2020 17:32:28 +0200
264
Subject: [PATCH 03/24] Backport buildscripts/aws_ec2.py
265
266
---
267
 buildscripts/aws_ec2.py | 83 ++++++++++++++++++-----------------------
268
 1 file changed, 37 insertions(+), 46 deletions(-)
269
270
diff --git a/buildscripts/aws_ec2.py b/buildscripts/aws_ec2.py
271
index bc467d6e..f2e033a4 100755
272
--- buildscripts/aws_ec2.py
273
+++ buildscripts/aws_ec2.py
274
@@ -2,7 +2,7 @@
275
 
276
 """AWS EC2 instance launcher and controller."""
277
 
278
-from __future__ import print_function
279
+
280
 
281
 import base64
282
 import collections
283
@@ -94,12 +94,13 @@ class AwsEc2(object):
284
             if reached_state:
285
                 print(" Instance {}!".format(instance.state["Name"]), file=sys.stdout)
286
             else:
287
-                print(" Instance in state '{}', failed to reach state '{}'{}!".format(
288
-                    instance.state["Name"], state, client_error), file=sys.stdout)
289
+                print(
290
+                    " Instance in state '{}', failed to reach state '{}'{}!".format(
291
+                        instance.state["Name"], state, client_error), file=sys.stdout)
292
             sys.stdout.flush()
293
         return 0 if reached_state else 1
294
 
295
-    def control_instance(  #pylint: disable=too-many-arguments,too-many-branches
296
+    def control_instance(  #pylint: disable=too-many-arguments,too-many-branches,too-many-locals
297
             self, mode, image_id, wait_time_secs=0, show_progress=False, console_output_file=None,
298
             console_screenshot_file=None):
299
         """Control an AMI instance. Returns 0 & status information, if successful."""
300
@@ -257,40 +258,34 @@ def main():
301
     create_options = optparse.OptionGroup(parser, "Create options")
302
     status_options = optparse.OptionGroup(parser, "Status options")
303
 
304
-    parser.add_option("--mode",
305
-                      dest="mode",
306
-                      choices=_MODES,
307
-                      default="status",
308
-                      help="Operations to perform on an EC2 instance, choose one of"
309
-                           " '{}', defaults to '%default'.".format(", ".join(_MODES)))
310
+    parser.add_option(
311
+        "--mode", dest="mode", choices=_MODES, default="status",
312
+        help=("Operations to perform on an EC2 instance, choose one of"
313
+              " '{}', defaults to '%default'.".format(", ".join(_MODES))))
314
 
315
     control_options.add_option("--imageId",
316
                                dest="image_id",
317
                                default=None,
318
                                help="EC2 image_id to perform operation on [REQUIRED for control].")
319
 
320
-    control_options.add_option("--waitTimeSecs",
321
-                               dest="wait_time_secs",
322
-                               type=int,
323
-                               default=5 * 60,
324
-                               help="Time to wait for EC2 instance to reach it's new state,"
325
-                                    " defaults to '%default'.")
326
+    control_options.add_option(
327
+        "--waitTimeSecs", dest="wait_time_secs", type=int, default=5 * 60,
328
+        help=("Time to wait for EC2 instance to reach it's new state,"
329
+              " defaults to '%default'."))
330
+
331
 
332
     create_options.add_option("--ami",
333
                               dest="ami",
334
                               default=None,
335
                               help="EC2 AMI to launch [REQUIRED for create].")
336
 
337
-    create_options.add_option("--blockDevice",
338
-                              dest="block_devices",
339
-                              metavar="DEVICE-NAME DEVICE-SIZE-GB",
340
-                              action="append",
341
-                              default=[],
342
-                              nargs=2,
343
-                              help="EBS device name and volume size in GiB."
344
-                                   " More than one device can be attached, by specifying"
345
-                                   " this option more than once."
346
-                                   " The device will be deleted on termination of the instance.")
347
+    create_options.add_option(
348
+        "--blockDevice", dest="block_devices", metavar="DEVICE-NAME DEVICE-SIZE-GB",
349
+        action="append", default=[], nargs=2,
350
+        help=("EBS device name and volume size in GiB."
351
+              " More than one device can be attached, by specifying"
352
+              " this option more than once."
353
+              " The device will be deleted on termination of the instance."))
354
 
355
     create_options.add_option("--instanceType",
356
                               dest="instance_type",
357
@@ -302,19 +297,15 @@ def main():
358
                               default=None,
359
                               help="EC2 key name [REQUIRED for create].")
360
 
361
-    create_options.add_option("--securityGroupIds",
362
-                              dest="security_group_ids",
363
-                              action="append",
364
-                              default=[],
365
-                              help="EC2 security group ids. More than one security group id can be"
366
-                                   " added, by specifying this option more than once.")
367
+    create_options.add_option(
368
+        "--securityGroupIds", dest="security_group_ids", action="append", default=[],
369
+        help=("EC2 security group ids. More than one security group id can be"
370
+              " added, by specifying this option more than once."))
371
 
372
-    create_options.add_option("--securityGroup",
373
-                              dest="security_groups",
374
-                              action="append",
375
-                              default=[],
376
-                              help="EC2 security group. More than one security group can be added,"
377
-                                   " by specifying this option more than once.")
378
+    create_options.add_option(
379
+        "--securityGroup", dest="security_groups", action="append", default=[],
380
+        help=("EC2 security group. More than one security group can be added,"
381
+              " by specifying this option more than once."))
382
 
383
     create_options.add_option("--subnetId",
384
                               dest="subnet_id",
385
@@ -350,14 +341,15 @@ def main():
386
                               default=None,
387
                               help="Save the status into the specified YAML file.")
388
 
389
-    status_options.add_option("--consoleOutputFile", dest="console_output_file", default=None,
390
-                              help="Save the console output into the specified file, if"
391
-                              " available.")
392
+    status_options.add_option(
393
+        "--consoleOutputFile", dest="console_output_file", default=None,
394
+        help="Save the console output into the specified file, if"
395
+        " available.")
396
 
397
-    status_options.add_option("--consoleScreenshotFile", dest="console_screenshot_file",
398
-                              default=None,
399
-                              help="Save the console screenshot (JPG format) into the specified"
400
-                              " file, if available.")
401
+    status_options.add_option(
402
+        "--consoleScreenshotFile", dest="console_screenshot_file", default=None,
403
+        help="Save the console screenshot (JPG format) into the specified"
404
+        " file, if available.")
405
 
406
     parser.add_option_group(control_options)
407
     parser.add_option_group(create_options)
408
@@ -382,7 +374,6 @@ def main():
409
                 parser.error("Block size must be an integer")
410
             block_devices[device_name] = device_size
411
 
412
-        # The 'expire-on' key is a UTC time.
413
         expire_dt = datetime.datetime.utcnow() + datetime.timedelta(hours=options.tag_expire_hours)
414
         tags = [{"Key": "expire-on", "Value": expire_dt.strftime("%Y-%m-%d %H:%M:%S")},
415
                 {"Key": "Name", "Value": options.tag_name},
416
-- 
417
2.28.0
418
419
420
From b6f97aeb89868c62c3c01f7f2e6f47ecda846d94 Mon Sep 17 00:00:00 2001
421
From: MikaelUrankar <mikael.urankar@gmail.com>
422
Date: Sat, 3 Oct 2020 17:33:44 +0200
423
Subject: [PATCH 04/24] backport site_scons/mongo/__init__.py
424
425
---
426
 site_scons/mongo/__init__.py | 2 +-
427
 1 file changed, 1 insertion(+), 1 deletion(-)
428
429
diff --git a/site_scons/mongo/__init__.py b/site_scons/mongo/__init__.py
430
index 510bd7bc..f7747809 100644
431
--- site_scons/mongo/__init__.py
432
+++ site_scons/mongo/__init__.py
433
@@ -5,4 +5,4 @@
434
 def print_build_failures():
435
     from SCons.Script import GetBuildFailures
436
     for bf in GetBuildFailures():
437
-        print "%s failed: %s" % (bf.node, bf.errstr)
438
+        print("%s failed: %s" % (bf.node, bf.errstr))
439
-- 
440
2.28.0
441
442
443
From 054ba812f02c54663a76b7092aa0c1eeeaf9925e Mon Sep 17 00:00:00 2001
444
From: MikaelUrankar <mikael.urankar@gmail.com>
445
Date: Sat, 3 Oct 2020 17:35:06 +0200
446
Subject: [PATCH 05/24] backport site_scons/mongo/generators.py
447
448
---
449
 site_scons/mongo/generators.py | 75 +++++++++++++++++++++++++++-------
450
 1 file changed, 61 insertions(+), 14 deletions(-)
451
452
diff --git a/site_scons/mongo/generators.py b/site_scons/mongo/generators.py
453
index c07e86a4..052f18d3 100644
454
--- site_scons/mongo/generators.py
455
+++ site_scons/mongo/generators.py
456
@@ -1,6 +1,6 @@
457
 # -*- mode: python; -*-
458
 
459
-import md5
460
+import hashlib
461
 
462
 # Default and alternative generator definitions go here.
463
 
464
@@ -15,22 +15,69 @@ import md5
465
 # want to define them.
466
 def default_buildinfo_environment_data():
467
     return (
468
-        ('distmod', '$MONGO_DISTMOD', True, True,),
469
-        ('distarch', '$MONGO_DISTARCH', True, True,),
470
-        ('cc', '$CC_VERSION', True, False,),
471
-        ('ccflags', '$CCFLAGS', True, False,),
472
-        ('cxx', '$CXX_VERSION', True, False,),
473
-        ('cxxflags', '$CXXFLAGS', True, False,),
474
-        ('linkflags', '$LINKFLAGS', True, False,),
475
-        ('target_arch', '$TARGET_ARCH', True, True,),
476
-        ('target_os', '$TARGET_OS', True, False,),
477
+        (
478
+            'distmod',
479
+            '$MONGO_DISTMOD',
480
+            True,
481
+            True,
482
+        ),
483
+        (
484
+            'distarch',
485
+            '$MONGO_DISTARCH',
486
+            True,
487
+            True,
488
+        ),
489
+        (
490
+            'cc',
491
+            '$CC_VERSION',
492
+            True,
493
+            False,
494
+        ),
495
+        (
496
+            'ccflags',
497
+            '$CCFLAGS',
498
+            True,
499
+            False,
500
+        ),
501
+        (
502
+            'cxx',
503
+            '$CXX_VERSION',
504
+            True,
505
+            False,
506
+        ),
507
+        (
508
+            'cxxflags',
509
+            '$CXXFLAGS',
510
+            True,
511
+            False,
512
+        ),
513
+        (
514
+            'linkflags',
515
+            '$LINKFLAGS',
516
+            True,
517
+            False,
518
+        ),
519
+        (
520
+            'target_arch',
521
+            '$TARGET_ARCH',
522
+            True,
523
+            True,
524
+        ),
525
+        (
526
+            'target_os',
527
+            '$TARGET_OS',
528
+            True,
529
+            False,
530
+        ),
531
     )
532
 
533
+
534
 # If you want buildInfo and --version to be relatively empty, set
535
 # MONGO_BUILDINFO_ENVIRONMENT_DATA = empty_buildinfo_environment_data()
536
 def empty_buildinfo_environment_data():
537
     return ()
538
 
539
+
540
 def default_variant_dir_generator(target, source, env, for_signature):
541
 
542
     if env.GetOption('cache') != None:
543
@@ -44,11 +91,11 @@ def default_variant_dir_generator(target, source, env, for_signature):
544
 
545
     # Hash the named options and their values, and take the first 8 characters of the hash as
546
     # the variant name
547
-    hasher = md5.md5()
548
+    hasher = hashlib.md5()
549
     for option in variant_options:
550
-        hasher.update(option)
551
-        hasher.update(str(env.GetOption(option)))
552
-    variant_dir = hasher.hexdigest()[0:8]
553
+        hasher.update(option.encode('utf-8'))
554
+        hasher.update(str(env.GetOption(option)).encode('utf-8'))
555
+    variant_dir = str(hasher.hexdigest()[0:8])
556
 
557
     # If our option hash yields a well known hash, replace it with its name.
558
     known_variant_hashes = {
559
-- 
560
2.28.0
561
562
563
From 83a4ac06adfa2d7adfb6dedeb6fb258130ab3015 Mon Sep 17 00:00:00 2001
564
From: MikaelUrankar <mikael.urankar@gmail.com>
565
Date: Sat, 3 Oct 2020 17:36:14 +0200
566
Subject: [PATCH 06/24] backport buildscripts/utils.py
567
568
---
569
 buildscripts/utils.py | 6 +++---
570
 1 file changed, 3 insertions(+), 3 deletions(-)
571
572
diff --git a/buildscripts/utils.py b/buildscripts/utils.py
573
index 69a78921..1c08bdf8 100644
574
--- buildscripts/utils.py
575
+++ buildscripts/utils.py
576
@@ -107,7 +107,7 @@ def getGitDescribe():
577
             stderr=devnull,
578
             stdin=devnull,
579
             shell=True)
580
-        return proc.communicate()[0].strip()
581
+        return proc.communicate()[0].strip().decode('utf-8')
582
 
583
 def execsys( args ):
584
     import subprocess
585
@@ -122,7 +122,7 @@ def getprocesslist():
586
     raw = ""
587
     try:
588
         raw = execsys( "/bin/ps axww" )[0]
589
-    except Exception,e:
590
+    except Exception as e:
591
         print( "can't get processlist: " + str( e ) )
592
 
593
     r = re.compile( "[\r\n]+" )
594
@@ -176,7 +176,7 @@ def didMongodStart( port=27017 , timeout=20 ):
595
         try:
596
             checkMongoPort( port )
597
             return True
598
-        except Exception,e:
599
+        except Exception as e:
600
             print( e )
601
             timeout = timeout - 1
602
     return False
603
-- 
604
2.28.0
605
606
607
From f38206bde5a4e7cf14a7e17b67ccf074b222c9a6 Mon Sep 17 00:00:00 2001
608
From: MikaelUrankar <mikael.urankar@gmail.com>
609
Date: Sat, 3 Oct 2020 17:48:44 +0200
610
Subject: [PATCH 07/24] backport site_scons/libdeps.py
611
612
---
613
 site_scons/libdeps.py | 46 ++++++++++++++++++++++++++-----------------
614
 1 file changed, 28 insertions(+), 18 deletions(-)
615
616
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py
617
index 632ed29b..62272052 100644
618
--- site_scons/libdeps.py
619
+++ site_scons/libdeps.py
620
@@ -61,7 +61,7 @@ syslibdeps_env_var = 'SYSLIBDEPS'
621
 missing_syslibdep = 'MISSING_LIBDEP_'
622
 
623
 class dependency(object):
624
-    Public, Private, Interface = range(3)
625
+    Public, Private, Interface = list(range(3))
626
 
627
     def __init__(self, value, dynamic, deptype):
628
         self.target_node = value
629
@@ -74,7 +74,7 @@ class dependency(object):
630
 class DependencyCycleError(SCons.Errors.UserError):
631
     """Exception representing a cycle discovered in library dependencies."""
632
 
633
-    def __init__(self, first_node ):
634
+    def __init__(self, first_node):
635
         super(DependencyCycleError, self).__init__()
636
         self.cycle_nodes = [first_node]
637
 
638
@@ -89,8 +89,8 @@ def __get_sorted_direct_libdeps(node):
639
         setattr(node.attributes, "libdeps_direct_sorted", direct_sorted)
640
     return direct_sorted
641
 
642
-def __get_libdeps(node):
643
 
644
+def __get_libdeps(node):
645
     """Given a SCons Node, return its library dependencies, topologically sorted.
646
 
647
     Computes the dependencies if they're not already cached.
648
@@ -122,7 +122,7 @@ def __get_libdeps(node):
649
                 marked.add(n.target_node)
650
                 tsorted.append(n.target_node)
651
 
652
-            except DependencyCycleError, e:
653
+            except DependencyCycleError as e:
654
                 if len(e.cycle_nodes) == 1 or e.cycle_nodes[0] != e.cycle_nodes[-1]:
655
                     e.cycle_nodes.insert(0, n.target_node)
656
                 raise
657
@@ -139,6 +139,7 @@ def __get_libdeps(node):
658
 
659
     return tsorted
660
 
661
+
662
 def __get_syslibdeps(node):
663
     """ Given a SCons Node, return its system library dependencies.
664
 
665
@@ -150,11 +151,11 @@ def __get_syslibdeps(node):
666
         for lib in __get_libdeps(node):
667
             for syslib in node.get_env().Flatten(lib.get_env().get(syslibdeps_env_var, [])):
668
                 if syslib:
669
-                    if type(syslib) in (str, unicode) and syslib.startswith(missing_syslibdep):
670
-                        print("Target '%s' depends on the availability of a "
671
+                    if type(syslib) is str and syslib.startswith(missing_syslibdep):
672
+                        print(("Target '%s' depends on the availability of a "
673
                               "system provided library for '%s', "
674
                               "but no suitable library was found during configuration." %
675
-                              (str(node), syslib[len(missing_syslibdep):]))
676
+                              (str(node), syslib[len(missing_syslibdep):])))
677
                         node.get_env().Exit(1)
678
                     syslibdeps.append(syslib)
679
         setattr(node.attributes, cached_var_name, syslibdeps)
680
@@ -170,17 +171,20 @@ def update_scanner(builder):
681
 
682
     if old_scanner:
683
         path_function = old_scanner.path_function
684
+
685
         def new_scanner(node, env, path=()):
686
             result = old_scanner.function(node, env, path)
687
             result.extend(__get_libdeps(node))
688
             return result
689
     else:
690
         path_function = None
691
+
692
         def new_scanner(node, env, path=()):
693
             return __get_libdeps(node)
694
 
695
     builder.target_scanner = SCons.Scanner.Scanner(function=new_scanner,
696
-                                                    path_function=path_function)
697
+                                                   path_function=path_function)
698
+
699
 
700
 def get_libdeps(source, target, env, for_signature):
701
     """Implementation of the special _LIBDEPS environment variable.
702
@@ -191,6 +195,7 @@ def get_libdeps(source, target, env, for_signature):
703
     target = env.Flatten([target])
704
     return __get_libdeps(target[0])
705
 
706
+
707
 def get_libdeps_objs(source, target, env, for_signature):
708
     objs = []
709
     for lib in get_libdeps(source, target, env, for_signature):
710
@@ -198,6 +203,7 @@ def get_libdeps_objs(source, target, env, for_signature):
711
         objs.extend(lib.sources)
712
     return objs
713
 
714
+
715
 def get_syslibdeps(source, target, env, for_signature):
716
     deps = __get_syslibdeps(target[0])
717
     lib_link_prefix = env.subst('$LIBLINKPREFIX')
718
@@ -209,7 +215,7 @@ def get_syslibdeps(source, target, env, for_signature):
719
         # they're believed to represent library short names, that should be prefixed with -l
720
         # or the compiler-specific equivalent.  I.e., 'm' becomes '-lm', but 'File("m.a") is passed
721
         # through whole cloth.
722
-        if type(d) in (str, unicode):
723
+        if type(d) is str:
724
             result.append('%s%s%s' % (lib_link_prefix, d, lib_link_suffix))
725
         else:
726
             result.append(d)
727
@@ -252,8 +258,8 @@ def libdeps_emitter(target, source, env):
728
     prereqs.extend(dependency(l, False, dependency.Private) for l in env.get(libdeps_env_var + '_PRIVATE', []) if l)
729
 
730
     for prereq in prereqs:
731
-        prereqWithIxes = SCons.Util.adjustixes(
732
-            prereq.target_node, lib_builder.get_prefix(env), lib_builder.get_suffix(env))
733
+        prereqWithIxes = SCons.Util.adjustixes(prereq.target_node, lib_builder.get_prefix(env),
734
+                                               lib_builder.get_suffix(env))
735
         prereq.target_node = lib_node_factory(prereqWithIxes)
736
 
737
     for t in target:
738
@@ -264,16 +270,16 @@ def libdeps_emitter(target, source, env):
739
     for dependent in env.get('LIBDEPS_DEPENDENTS', []):
740
         if dependent is None:
741
             continue
742
-        dependentWithIxes = SCons.Util.adjustixes(
743
-            dependent, lib_builder.get_prefix(env), lib_builder.get_suffix(env))
744
+        dependentWithIxes = SCons.Util.adjustixes(dependent, lib_builder.get_prefix(env),
745
+                                                  lib_builder.get_suffix(env))
746
         dependentNode = lib_node_factory(dependentWithIxes)
747
         __append_direct_libdeps(dependentNode, [dependency(target[0], False, dependency.Public)])
748
 
749
     for dependent in env.get('PROGDEPS_DEPENDENTS', []):
750
         if dependent is None:
751
             continue
752
-        dependentWithIxes = SCons.Util.adjustixes(
753
-            dependent, prog_builder.get_prefix(env), prog_builder.get_suffix(env))
754
+        dependentWithIxes = SCons.Util.adjustixes(dependent, prog_builder.get_prefix(env),
755
+                                                  prog_builder.get_suffix(env))
756
         dependentNode = prog_node_factory(dependentWithIxes)
757
         __append_direct_libdeps(dependentNode, [dependency(target[0], False, dependency.Public)])
758
 
759
@@ -372,9 +378,11 @@ def setup_environment(env, emitting_shared=False):
760
                 if 'init-no-global-side-effects' in env.Entry(lib).get_env().get('LIBDEPS_TAGS', []):
761
                     result.append(str(lib))
762
                 else:
763
-                    result.extend(env.subst('$LINK_WHOLE_ARCHIVE_LIB_START'
764
-                                            '$TARGET'
765
-                                            '$LINK_WHOLE_ARCHIVE_LIB_END', target=lib).split())
766
+                    result.extend(
767
+                        env.subst(
768
+                            '$LINK_WHOLE_ARCHIVE_LIB_START'
769
+                            '$TARGET'
770
+                            '$LINK_WHOLE_ARCHIVE_LIB_END', target=lib).split())
771
             return result
772
 
773
         env['_LIBDEPS_LIBS_WITH_TAGS'] = expand_libdeps_with_extraction_flags
774
@@ -394,6 +402,7 @@ def setup_environment(env, emitting_shared=False):
775
         except KeyError:
776
             pass
777
 
778
+
779
 def setup_conftests(conf):
780
     def FindSysLibDep(context, name, libs, **kwargs):
781
         var = "LIBDEPS_" + name.upper() + "_SYSLIBDEP"
782
@@ -406,4 +415,5 @@ def setup_conftests(conf):
783
                 return context.Result(result)
784
         context.env[var] = __missing_syslib(name)
785
         return context.Result(result)
786
+
787
     conf.AddTest('FindSysLibDep', FindSysLibDep)
788
-- 
789
2.28.0
790
791
792
From 2bc91392ab7dba6a09aa4100a9e8666a82dd7941 Mon Sep 17 00:00:00 2001
793
From: MikaelUrankar <mikael.urankar@gmail.com>
794
Date: Sat, 3 Oct 2020 17:49:45 +0200
795
Subject: [PATCH 08/24] backport site_scons/site_tools/distsrc.py
796
797
---
798
 site_scons/site_tools/distsrc.py | 25 ++++++++++++++-----------
799
 1 file changed, 14 insertions(+), 11 deletions(-)
800
801
diff --git a/site_scons/site_tools/distsrc.py b/site_scons/site_tools/distsrc.py
802
index 861f5d9e..cc72c065 100644
803
--- site_scons/site_tools/distsrc.py
804
+++ site_scons/site_tools/distsrc.py
805
@@ -20,7 +20,7 @@ import shutil
806
 import tarfile
807
 import time
808
 import zipfile
809
-import StringIO
810
+import io
811
 
812
 from distutils.spawn import find_executable
813
 
814
@@ -28,7 +28,7 @@ __distsrc_callbacks = []
815
 
816
 class DistSrcFile:
817
     def __init__(self, **kwargs):
818
-        [ setattr(self, key, val) for (key, val) in kwargs.items() ]
819
+        [ setattr(self, key, val) for (key, val) in list(kwargs.items()) ]
820
 
821
     def __str__(self):
822
         return self.name
823
@@ -60,6 +60,7 @@ class DistSrcArchive:
824
     def close(self):
825
         self.archive_file.close()
826
 
827
+
828
 class DistSrcTarArchive(DistSrcArchive):
829
     def __iter__(self):
830
         file_list = self.archive_file.getnames()
831
@@ -82,7 +83,7 @@ class DistSrcTarArchive(DistSrcArchive):
832
 
833
     def append_file_contents(self, filename, file_contents,
834
             mtime=time.time(),
835
-            mode=0644,
836
+            mode=0o644,
837
             uname="root",
838
             gname="root"):
839
         file_metadata = tarfile.TarInfo(name=filename)
840
@@ -91,7 +92,7 @@ class DistSrcTarArchive(DistSrcArchive):
841
         file_metadata.uname = uname
842
         file_metadata.gname = gname
843
         file_metadata.size = len(file_contents)
844
-        file_buf = StringIO.StringIO(file_contents)
845
+        file_buf = io.BytesIO(file_contents.encode('utf-8'))
846
         if self.archive_mode == 'r':
847
             self.archive_file.close()
848
             self.archive_file = tarfile.open(
849
@@ -105,6 +106,7 @@ class DistSrcTarArchive(DistSrcArchive):
850
     def append_file(self, filename, localfile):
851
         self.archive_file.add(localfile, arcname=filename)
852
 
853
+
854
 class DistSrcZipArchive(DistSrcArchive):
855
     def __iter__(self):
856
         file_list = self.archive_file.namelist()
857
@@ -119,7 +121,7 @@ class DistSrcZipArchive(DistSrcArchive):
858
             name=key,
859
             size=item_data.file_size,
860
             mtime=time.mktime(fixed_time),
861
-            mode=0775 if is_dir else 0664,
862
+            mode=0o775 if is_dir else 0o664,
863
             type=tarfile.DIRTYPE if is_dir else tarfile.REGTYPE,
864
             uid=0,
865
             gid=0,
866
@@ -129,7 +131,7 @@ class DistSrcZipArchive(DistSrcArchive):
867
 
868
     def append_file_contents(self, filename, file_contents,
869
             mtime=time.time(),
870
-            mode=0644,
871
+            mode=0o644,
872
             uname="root",
873
             gname="root"):
874
         self.archive_file.writestr(filename, file_contents)
875
@@ -139,7 +141,7 @@ class DistSrcZipArchive(DistSrcArchive):
876
 
877
 def build_error_action(msg):
878
     def error_stub(target=None, source=None, env=None):
879
-        print msg
880
+        print(msg)
881
         env.Exit(1)
882
     return [ error_stub ]
883
 
884
@@ -162,7 +164,7 @@ def distsrc_action_generator(source, target, env, for_signature):
885
 
886
     target_ext = str(target[0])[-3:]
887
     if not target_ext in [ 'zip', 'tar' ]:
888
-        print "Invalid file format for distsrc. Must be tar or zip file"
889
+        print("Invalid file format for distsrc. Must be tar or zip file")
890
         env.Exit(1)
891
 
892
     git_cmd = "\"%s\" archive --format %s --output %s --prefix ${MONGO_DIST_SRC_PREFIX} HEAD" % (
893
@@ -173,14 +175,14 @@ def distsrc_action_generator(source, target, env, for_signature):
894
         SCons.Action.Action(run_distsrc_callbacks, "Running distsrc callbacks for $TARGET")
895
     ]
896
 
897
+
898
 def add_callback(env, fn):
899
     __distsrc_callbacks.append(fn)
900
 
901
+
902
 def generate(env, **kwargs):
903
     env.AddMethod(add_callback, 'AddDistSrcCallback')
904
-    env['BUILDERS']['__DISTSRC'] = SCons.Builder.Builder(
905
-        generator=distsrc_action_generator,
906
-    )
907
+    env['BUILDERS']['__DISTSRC'] = SCons.Builder.Builder(generator=distsrc_action_generator, )
908
 
909
     def DistSrc(env, target):
910
         result = env.__DISTSRC(target=target, source=[])
911
@@ -190,5 +192,6 @@ def generate(env, **kwargs):
912
 
913
     env.AddMethod(DistSrc, 'DistSrc')
914
 
915
+
916
 def exists(env):
917
     return True
918
-- 
919
2.28.0
920
921
922
From b27a4fc533e5290495f3b2d2bc78ea208d607bf5 Mon Sep 17 00:00:00 2001
923
From: MikaelUrankar <mikael.urankar@gmail.com>
924
Date: Sat, 3 Oct 2020 17:50:41 +0200
925
Subject: [PATCH 09/24] backport site_scons/site_tools/mongo_benchmark.py
926
927
---
928
 site_scons/site_tools/mongo_benchmark.py | 7 ++++---
929
 1 file changed, 4 insertions(+), 3 deletions(-)
930
931
diff --git a/site_scons/site_tools/mongo_benchmark.py b/site_scons/site_tools/mongo_benchmark.py
932
index 7c12627b..f3f84d73 100644
933
--- site_scons/site_tools/mongo_benchmark.py
934
+++ site_scons/site_tools/mongo_benchmark.py
935
@@ -11,10 +11,10 @@ def register_benchmark(env, test):
936
     env.Alias('$BENCHMARK_ALIAS', test)
937
 
938
 def benchmark_list_builder_action(env, target, source):
939
-    ofile = open(str(target[0]), 'wb')
940
+    ofile = open(str(target[0]), 'w')
941
     try:
942
         for s in _benchmarks:
943
-            print '\t' + str(s)
944
+            print('\t' + str(s))
945
             ofile.write('%s\n' % s)
946
     finally:
947
         ofile.close()
948
@@ -37,9 +37,10 @@ def build_benchmark(env, target, source, **kwargs):
949
     bmEnv.Install("#/build/benchmark/", result[0])
950
     return result
951
 
952
+
953
 def generate(env):
954
     env.Command('$BENCHMARK_LIST', env.Value(_benchmarks),
955
-            Action(benchmark_list_builder_action, "Generating $TARGET"))
956
+                Action(benchmark_list_builder_action, "Generating $TARGET"))
957
     env.AddMethod(register_benchmark, 'RegisterBenchmark')
958
     env.AddMethod(build_benchmark, 'Benchmark')
959
     env.Alias('$BENCHMARK_ALIAS', '$BENCHMARK_LIST')
960
-- 
961
2.28.0
962
963
964
From 2059bb295d0d440a615241a834094dba3c840d6f Mon Sep 17 00:00:00 2001
965
From: MikaelUrankar <mikael.urankar@gmail.com>
966
Date: Sat, 3 Oct 2020 17:51:30 +0200
967
Subject: [PATCH 10/24] backport site_scons/site_tools/mongo_integrationtest.py
968
969
---
970
 site_scons/site_tools/mongo_integrationtest.py | 7 ++++---
971
 1 file changed, 4 insertions(+), 3 deletions(-)
972
973
diff --git a/site_scons/site_tools/mongo_integrationtest.py b/site_scons/site_tools/mongo_integrationtest.py
974
index ff9a5f45..324cac63 100644
975
--- site_scons/site_tools/mongo_integrationtest.py
976
+++ site_scons/site_tools/mongo_integrationtest.py
977
@@ -12,10 +12,10 @@ def register_integration_test(env, test):
978
     env.Alias('$INTEGRATION_TEST_ALIAS', installed_test)
979
 
980
 def integration_test_list_builder_action(env, target, source):
981
-    ofile = open(str(target[0]), 'wb')
982
+    ofile = open(str(target[0]), 'w')
983
     try:
984
         for s in _integration_tests:
985
-            print '\t' + str(s)
986
+            print('\t' + str(s))
987
             ofile.write('%s\n' % s)
988
     finally:
989
         ofile.close()
990
@@ -30,9 +30,10 @@ def build_cpp_integration_test(env, target, source, **kwargs):
991
     env.RegisterIntegrationTest(result[0])
992
     return result
993
 
994
+
995
 def generate(env):
996
     env.Command('$INTEGRATION_TEST_LIST', env.Value(_integration_tests),
997
-            Action(integration_test_list_builder_action, "Generating $TARGET"))
998
+                Action(integration_test_list_builder_action, "Generating $TARGET"))
999
     env.AddMethod(register_integration_test, 'RegisterIntegrationTest')
1000
     env.AddMethod(build_cpp_integration_test, 'CppIntegrationTest')
1001
     env.Alias('$INTEGRATION_TEST_ALIAS', '$INTEGRATION_TEST_LIST')
1002
-- 
1003
2.28.0
1004
1005
1006
From 747ce174e66d87aa71d6a3943457228ecd1d6aa2 Mon Sep 17 00:00:00 2001
1007
From: MikaelUrankar <mikael.urankar@gmail.com>
1008
Date: Sat, 3 Oct 2020 17:54:25 +0200
1009
Subject: [PATCH 11/24] backport site_scons/site_tools/mongo_unittest.py
1010
1011
---
1012
 site_scons/site_tools/mongo_unittest.py | 7 ++++---
1013
 1 file changed, 4 insertions(+), 3 deletions(-)
1014
1015
diff --git a/site_scons/site_tools/mongo_unittest.py b/site_scons/site_tools/mongo_unittest.py
1016
index ec99ab2d..28504767 100644
1017
--- site_scons/site_tools/mongo_unittest.py
1018
+++ site_scons/site_tools/mongo_unittest.py
1019
@@ -11,10 +11,10 @@ def register_unit_test(env, test):
1020
     env.Alias('$UNITTEST_ALIAS', test)
1021
 
1022
 def unit_test_list_builder_action(env, target, source):
1023
-    ofile = open(str(target[0]), 'wb')
1024
+    ofile = open(str(target[0]), 'w')
1025
     try:
1026
         for s in _unittests:
1027
-            print '\t' + str(s)
1028
+            print('\t' + str(s))
1029
             ofile.write('%s\n' % s)
1030
     finally:
1031
         ofile.close()
1032
@@ -30,9 +30,10 @@ def build_cpp_unit_test(env, target, source, **kwargs):
1033
     env.Install("#/build/unittests/", result[0])
1034
     return result
1035
 
1036
+
1037
 def generate(env):
1038
     env.Command('$UNITTEST_LIST', env.Value(_unittests),
1039
-            Action(unit_test_list_builder_action, "Generating $TARGET"))
1040
+                Action(unit_test_list_builder_action, "Generating $TARGET"))
1041
     env.AddMethod(register_unit_test, 'RegisterUnitTest')
1042
     env.AddMethod(build_cpp_unit_test, 'CppUnitTest')
1043
     env.Alias('$UNITTEST_ALIAS', '$UNITTEST_LIST')
1044
-- 
1045
2.28.0
1046
1047
1048
From 72af34f1fbb1341dbb4f91147346eba24ad3bba1 Mon Sep 17 00:00:00 2001
1049
From: MikaelUrankar <mikael.urankar@gmail.com>
1050
Date: Sat, 3 Oct 2020 17:54:44 +0200
1051
Subject: [PATCH 12/24] backport site_scons/site_tools/split_dwarf.py
1052
1053
---
1054
 site_scons/site_tools/split_dwarf.py | 5 ++++-
1055
 1 file changed, 4 insertions(+), 1 deletion(-)
1056
1057
diff --git a/site_scons/site_tools/split_dwarf.py b/site_scons/site_tools/split_dwarf.py
1058
index 95130c9e..c57b9e96 100644
1059
--- site_scons/site_tools/split_dwarf.py
1060
+++ site_scons/site_tools/split_dwarf.py
1061
@@ -26,6 +26,7 @@ _CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++']
1062
 if SCons.Util.case_sensitive_suffixes('.c', '.C'):
1063
     _CXXSuffixes.append('.C')
1064
 
1065
+
1066
 def _dwo_emitter(target, source, env):
1067
     new_targets = []
1068
     for t in target:
1069
@@ -40,6 +41,7 @@ def _dwo_emitter(target, source, env):
1070
     targets = target + new_targets
1071
     return (targets, source)
1072
 
1073
+
1074
 def generate(env):
1075
     suffixes = []
1076
     if _splitDwarfFlag in env['CCFLAGS']:
1077
@@ -52,7 +54,7 @@ def generate(env):
1078
 
1079
     for object_builder in SCons.Tool.createObjBuilders(env):
1080
         emitterdict = object_builder.builder.emitter
1081
-        for suffix in emitterdict.iterkeys():
1082
+        for suffix in emitterdict.keys():
1083
             if not suffix in suffixes:
1084
                 continue
1085
             base = emitterdict[suffix]
1086
@@ -61,5 +63,6 @@ def generate(env):
1087
                 _dwo_emitter,
1088
             ])
1089
 
1090
+
1091
 def exists(env):
1092
     return any(_splitDwarfFlag in env[f] for f in ['CCFLAGS', 'CFLAGS', 'CXXFLAGS'])
1093
-- 
1094
2.28.0
1095
1096
1097
From 1e6b16c197766c1f9b19d32cacb658dff44b52b5 Mon Sep 17 00:00:00 2001
1098
From: MikaelUrankar <mikael.urankar@gmail.com>
1099
Date: Sat, 3 Oct 2020 17:56:46 +0200
1100
Subject: [PATCH 13/24] backport site_scons/site_tools/thin_archive.py
1101
1102
---
1103
 site_scons/site_tools/thin_archive.py | 18 +++++++++++-------
1104
 1 file changed, 11 insertions(+), 7 deletions(-)
1105
1106
diff --git a/site_scons/site_tools/thin_archive.py b/site_scons/site_tools/thin_archive.py
1107
index 511c0ef6..500c3355 100644
1108
--- site_scons/site_tools/thin_archive.py
1109
+++ site_scons/site_tools/thin_archive.py
1110
@@ -17,6 +17,7 @@ import SCons
1111
 import re
1112
 import subprocess
1113
 
1114
+
1115
 def exists(env):
1116
     if not 'AR' in env:
1117
         return False
1118
@@ -30,10 +31,9 @@ def exists(env):
1119
     if not "rc" in env['ARFLAGS']:
1120
         return False
1121
 
1122
-    pipe = SCons.Action._subproc(env, SCons.Util.CLVar(ar) + ['--version'],
1123
-                                 stdin = 'devnull',
1124
-                                 stderr = 'devnull',
1125
-                                 stdout = subprocess.PIPE)
1126
+    pipe = SCons.Action._subproc(env,
1127
+                                 SCons.Util.CLVar(ar) + ['--version'], stdin='devnull',
1128
+                                 stderr='devnull', stdout=subprocess.PIPE)
1129
     if pipe.wait() != 0:
1130
         return False
1131
 
1132
@@ -41,7 +41,7 @@ def exists(env):
1133
     for line in pipe.stdout:
1134
         if isgnu:
1135
             continue  # consume all data
1136
-        isgnu = re.search(r'^GNU ar', line)
1137
+        isgnu = re.search(r'^GNU ar', line.decode('utf-8'))
1138
 
1139
     return bool(isgnu)
1140
 
1141
@@ -56,6 +56,7 @@ def _add_emitter(builder):
1142
     new_emitter = SCons.Builder.ListEmitter([base_emitter, new_emitter])
1143
     builder.emitter = new_emitter
1144
 
1145
+
1146
 def _add_scanner(builder):
1147
     old_scanner = builder.target_scanner
1148
     path_function = old_scanner.path_function
1149
@@ -69,13 +70,16 @@ def _add_scanner(builder):
1150
                 new_results.extend(base.children())
1151
         return new_results
1152
 
1153
-    builder.target_scanner = SCons.Scanner.Scanner(function=new_scanner, path_function=path_function)
1154
+    builder.target_scanner = SCons.Scanner.Scanner(function=new_scanner,
1155
+                                                   path_function=path_function)
1156
+
1157
 
1158
 def generate(env):
1159
     if not exists(env):
1160
         return
1161
 
1162
-    env['ARFLAGS'] = SCons.Util.CLVar([arflag if arflag != "rc" else "rcsTD" for arflag in env['ARFLAGS']])
1163
+    env['ARFLAGS'] = SCons.Util.CLVar(
1164
+        [arflag if arflag != "rc" else "rcsTD" for arflag in env['ARFLAGS']])
1165
 
1166
     def noop_action(env, target, source):
1167
         pass
1168
-- 
1169
2.28.0
1170
1171
1172
From 5c0d6355043aa07402eea9e85100f7cfc19897ce Mon Sep 17 00:00:00 2001
1173
From: MikaelUrankar <mikael.urankar@gmail.com>
1174
Date: Sat, 3 Oct 2020 18:07:05 +0200
1175
Subject: [PATCH 14/24] python3 buildscripts/errorcodes.py
1176
1177
---
1178
 buildscripts/errorcodes.py | 14 +++++++-------
1179
 1 file changed, 7 insertions(+), 7 deletions(-)
1180
1181
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py
1182
index cc467899..7d83b11e 100755
1183
--- buildscripts/errorcodes.py
1184
+++ buildscripts/errorcodes.py
1185
@@ -9,7 +9,7 @@ Optionally replaces zero codes in source code with new distinct values.
1186
 import bisect
1187
 import os
1188
 import sys
1189
-import utils
1190
+from . import utils
1191
 from collections import defaultdict, namedtuple
1192
 from optparse import OptionParser
1193
 
1194
@@ -66,7 +66,7 @@ def parseSourceFiles( callback ):
1195
 
1196
     for sourceFile in utils.getAllSourceFiles(prefix='src/mongo/'):
1197
         if list_files:
1198
-            print 'scanning file: ' + sourceFile
1199
+            print ('scanning file: ' + sourceFile)
1200
 
1201
         with open(sourceFile) as f:
1202
             text = f.read()
1203
@@ -159,7 +159,7 @@ def readErrorCodes():
1204
 
1205
     parseSourceFiles( checkDups )
1206
 
1207
-    if seen.has_key("0"):
1208
+    if "0" in seen:
1209
         code = "0"
1210
         bad = seen[code]
1211
         errors.append( bad )
1212
@@ -196,12 +196,12 @@ def replaceBadCodes( errors, nextCode ):
1213
     for assertLoc in reversed(sorted(set(zero_errors))):
1214
         (sourceFile, byteOffset, lines, code) = assertLoc
1215
         lineNum, _ = getLineAndColumnForPosition(assertLoc)
1216
-        print "UPDATING_FILE: %s:%s" % (sourceFile, lineNum)
1217
+        print ("UPDATING_FILE: %s:%s" % (sourceFile, lineNum))
1218
 
1219
         ln = lineNum - 1
1220
 
1221
         with open(sourceFile, 'r+') as f:
1222
-            print "LINE_%d_BEFORE:%s" % (lineNum, f.readlines()[ln].rstrip())
1223
+            print ("LINE_%d_BEFORE:%s" % (lineNum, f.readlines()[ln].rstrip()))
1224
 
1225
             f.seek(0)
1226
             text = f.read()
1227
@@ -212,7 +212,7 @@ def replaceBadCodes( errors, nextCode ):
1228
             f.write(text[byteOffset+1:])
1229
             f.seek(0)
1230
 
1231
-            print "LINE_%d_AFTER :%s" % (lineNum, f.readlines()[ln].rstrip())
1232
+            print ("LINE_%d_AFTER :%s" % (lineNum, f.readlines()[ln].rstrip()))
1233
         nextCode += 1
1234
 
1235
 
1236
@@ -281,7 +281,7 @@ def main():
1237
     elif options.replace:
1238
         replaceBadCodes(errors, next)
1239
     else:
1240
-        print ERROR_HELP
1241
+        print (ERROR_HELP)
1242
         sys.exit(1)
1243
 
1244
 
1245
-- 
1246
2.28.0
1247
1248
1249
From 6aec2eae836c40b8c3a3f0663ada65a85d593a4e Mon Sep 17 00:00:00 2001
1250
From: MikaelUrankar <mikael.urankar@gmail.com>
1251
Date: Sat, 3 Oct 2020 18:22:46 +0200
1252
Subject: [PATCH 15/24] backport src/mongo/SConscript
1253
1254
---
1255
 src/mongo/SConscript | 8 ++++----
1256
 1 file changed, 4 insertions(+), 4 deletions(-)
1257
1258
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
1259
index d93eb08f..aa4f6123 100644
1260
--- src/mongo/SConscript
1261
+++ src/mongo/SConscript
1262
@@ -157,9 +157,9 @@ js_engine_ver = get_option("js-engine") if get_option("server-js") == "on" else
1263
 
1264
 # On windows, we need to escape the backslashes in the command-line
1265
 # so that windows paths look okay.
1266
-cmd_line = " ".join(sys.argv).encode('string-escape')
1267
+cmd_line = " ".join(sys.argv).encode('unicode_escape')
1268
 if env.TargetOSIs('windows'):
1269
-    cmd_line = cmd_line.replace('\\', r'\\')
1270
+    cmd_line = cmd_line.replace(b'\\', b'\\')
1271
 
1272
 module_list = '{ %s }' % ', '.join([ '"{0}"'.format(x) for x in env['MONGO_MODULES'] ])
1273
 
1274
@@ -613,7 +613,7 @@ env.Append(MODULE_BANNERS = [distsrc.File('README'),
1275
                              distsrc.File('MPL-2')])
1276
 
1277
 # If no module has introduced a file named LICENSE.txt, then inject the license.
1278
-if sum(itertools.imap(lambda x: x.name == "LICENSE.txt", env['MODULE_BANNERS'])) == 0:
1279
+if sum(map(lambda x: x.name == "LICENSE.txt", env['MODULE_BANNERS'])) == 0:
1280
     env.Append(MODULE_BANNERS = [distsrc.File('LICENSE-Community.txt')])
1281
 
1282
 # All module banners get staged to the top level of the tarfile, so we
1283
@@ -632,7 +632,7 @@ module_banner_transforms = ["--transform %s=$SERVER_DIST_BASENAME" % d for d in
1284
 # Allow modules to map original file name directories to subdirectories
1285
 # within the archive (e.g. { "src/mongo/db/modules/enterprise/docs": "snmp"})
1286
 archive_addition_transforms = []
1287
-for full_dir, archive_dir in env["ARCHIVE_ADDITION_DIR_MAP"].items():
1288
+for full_dir, archive_dir in list(env["ARCHIVE_ADDITION_DIR_MAP"].items()):
1289
   archive_addition_transforms.append("--transform \"%s=$SERVER_DIST_BASENAME/%s\"" %
1290
                                      (full_dir, archive_dir))
1291
 
1292
-- 
1293
2.28.0
1294
1295
1296
From 0ef150e257dedb2fbe3512020ce9583b604b836d Mon Sep 17 00:00:00 2001
1297
From: MikaelUrankar <mikael.urankar@gmail.com>
1298
Date: Sat, 3 Oct 2020 18:25:00 +0200
1299
Subject: [PATCH 16/24] backport buildscripts/idl/idlc.py
1300
1301
---
1302
 buildscripts/idl/idlc.py | 2 --
1303
 1 file changed, 2 deletions(-)
1304
1305
diff --git a/buildscripts/idl/idlc.py b/buildscripts/idl/idlc.py
1306
index c6bf5056..90cb9ac1 100644
1307
--- buildscripts/idl/idlc.py
1308
+++ buildscripts/idl/idlc.py
1309
@@ -29,8 +29,6 @@
1310
 #
1311
 """IDL Compiler Driver Main Entry point."""
1312
 
1313
-from __future__ import absolute_import, print_function
1314
-
1315
 import argparse
1316
 import logging
1317
 import sys
1318
-- 
1319
2.28.0
1320
1321
1322
From 18d0c5440d9c6f6b6d2a38d600347c92eb47e4d8 Mon Sep 17 00:00:00 2001
1323
From: MikaelUrankar <mikael.urankar@gmail.com>
1324
Date: Sat, 3 Oct 2020 18:25:52 +0200
1325
Subject: [PATCH 17/24] backport src/mongo/db/auth/generate_action_types.py
1326
1327
---
1328
 src/mongo/db/auth/generate_action_types.py | 12 ++++++------
1329
 1 file changed, 6 insertions(+), 6 deletions(-)
1330
1331
diff --git a/src/mongo/db/auth/generate_action_types.py b/src/mongo/db/auth/generate_action_types.py
1332
index 3d3a36c0..618669fd 100755
1333
--- src/mongo/db/auth/generate_action_types.py
1334
+++ src/mongo/db/auth/generate_action_types.py
1335
@@ -26,7 +26,6 @@
1336
 # delete this exception statement from your version. If you delete this
1337
 # exception statement from all source files in the program, then also delete
1338
 # it in the license file.
1339
-
1340
 """Generate action_type.{h,cpp}
1341
 
1342
 Usage:
1343
@@ -35,7 +34,6 @@ Usage:
1344
 
1345
 import sys
1346
 
1347
-
1348
 headerFileTemplate = """// AUTO-GENERATED FILE DO NOT EDIT
1349
 // See src/mongo/db/auth/generate_action_types.py
1350
 /**
1351
@@ -194,14 +192,14 @@ namespace mongo {
1352
 } // namespace mongo
1353
 """
1354
 
1355
+
1356
 def writeSourceFile(actionTypes, sourceOutputFile):
1357
     actionTypeConstants = ""
1358
     fromStringIfStatements = ""
1359
     toStringCaseStatements = ""
1360
     for actionType in actionTypes:
1361
         actionTypeConstants += ("    const ActionType ActionType::%(actionType)s"
1362
-                                "(%(actionType)sValue);\n" %
1363
-                                dict(actionType=actionType))
1364
+                                "(%(actionType)sValue);\n" % dict(actionType=actionType))
1365
         fromStringIfStatements += """        if (action == "%(actionType)s") {
1366
             *result = %(actionType)s;
1367
             return Status::OK();
1368
@@ -215,6 +213,7 @@ def writeSourceFile(actionTypes, sourceOutputFile):
1369
 
1370
     pass
1371
 
1372
+
1373
 def writeHeaderFile(actionTypes, headerOutputFile):
1374
     actionTypeConstants = ""
1375
     actionTypeIdentifiers = ""
1376
@@ -225,6 +224,7 @@ def writeHeaderFile(actionTypes, headerOutputFile):
1377
                                                     actionTypeIdentifiers=actionTypeIdentifiers)
1378
     headerOutputFile.write(formattedHeaderFile)
1379
 
1380
+
1381
 def hasDuplicateActionTypes(actionTypes):
1382
     sortedActionTypes = sorted(actionTypes)
1383
 
1384
@@ -232,7 +232,7 @@ def hasDuplicateActionTypes(actionTypes):
1385
     prevActionType = sortedActionTypes[0]
1386
     for actionType in sortedActionTypes[1:]:
1387
         if actionType == prevActionType:
1388
-            print 'Duplicate actionType %s\n' % actionType
1389
+            print('Duplicate actionType %s\n' % actionType)
1390
             didFail = True
1391
         prevActionType = actionType
1392
 
1393
@@ -245,7 +245,7 @@ def parseActionTypesFromFile(actionTypesFilename):
1394
 
1395
 if __name__ == "__main__":
1396
     if len(sys.argv) != 4:
1397
-        print "Usage: generate_action_types.py <path to action_types.txt> <header file path> <source file path>"
1398
+        print("Usage: generate_action_types.py <path to action_types.txt> <header file path> <source file path>")
1399
         sys.exit(-1)
1400
 
1401
     actionTypes = parseActionTypesFromFile(sys.argv[1])
1402
-- 
1403
2.28.0
1404
1405
1406
From 6df9773b207f90692bda010f2778f57f957944ff Mon Sep 17 00:00:00 2001
1407
From: MikaelUrankar <mikael.urankar@gmail.com>
1408
Date: Sat, 3 Oct 2020 18:29:19 +0200
1409
Subject: [PATCH 18/24] backport buildscripts/idl/idl/compiler.py
1410
1411
---
1412
 buildscripts/idl/idl/compiler.py | 10 ++++------
1413
 1 file changed, 4 insertions(+), 6 deletions(-)
1414
1415
diff --git a/buildscripts/idl/idl/compiler.py b/buildscripts/idl/idl/compiler.py
1416
index 0905a18e..19aaf436 100644
1417
--- buildscripts/idl/idl/compiler.py
1418
+++ buildscripts/idl/idl/compiler.py
1419
@@ -31,8 +31,6 @@ IDL compiler driver.
1420
 Orchestrates the 3 passes (parser, binder, and generator) together.
1421
 """
1422
 
1423
-from __future__ import absolute_import, print_function, unicode_literals
1424
-
1425
 import io
1426
 import logging
1427
 import os
1428
@@ -66,14 +64,14 @@ class CompilerImportResolver(parser.ImportResolverBase):
1429
     """Class for the IDL compiler to resolve imported files."""
1430
 
1431
     def __init__(self, import_directories):
1432
-        # type: (List[unicode]) -> None
1433
+        # type: (List[str]) -> None
1434
         """Construct a ImportResolver."""
1435
         self._import_directories = import_directories
1436
 
1437
         super(CompilerImportResolver, self).__init__()
1438
 
1439
     def resolve(self, base_file, imported_file_name):
1440
-        # type: (unicode, unicode) -> unicode
1441
+        # type: (str, str) -> str
1442
         """Return the complete path to an imported file name."""
1443
 
1444
         logging.debug("Resolving imported file '%s' for file '%s'", imported_file_name, base_file)
1445
@@ -104,7 +102,7 @@ class CompilerImportResolver(parser.ImportResolverBase):
1446
         raise errors.IDLError(msg)
1447
 
1448
     def open(self, resolved_file_name):
1449
-        # type: (unicode) -> Any
1450
+        # type: (str) -> Any
1451
         """Return an io.Stream for the requested file."""
1452
         return io.open(resolved_file_name, encoding='utf-8')
1453
 
1454
@@ -121,7 +119,7 @@ def _write_dependencies(spec):
1455
 
1456
 
1457
 def _update_import_includes(args, spec, header_file_name):
1458
-    # type: (CompilerArgs, syntax.IDLSpec, unicode) -> None
1459
+    # type: (CompilerArgs, syntax.IDLSpec, str) -> None
1460
     """Update the list of imports with a list of include files for each import with structs."""
1461
     # This function is fragile:
1462
     # In order to try to generate headers with an "include what you use" set of headers, the IDL
1463
-- 
1464
2.28.0
1465
1466
1467
From 8e28ce9f7b396b16ad9d574a754b5e40fd063ed4 Mon Sep 17 00:00:00 2001
1468
From: MikaelUrankar <mikael.urankar@gmail.com>
1469
Date: Sat, 3 Oct 2020 18:31:51 +0200
1470
Subject: [PATCH 19/24] backport buildscripts/idl/idl/syntax.py
1471
1472
---
1473
 buildscripts/idl/idl/syntax.py | 83 ++++++++++++++++------------------
1474
 1 file changed, 40 insertions(+), 43 deletions(-)
1475
1476
diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py
1477
index 492a7b99..96ac5090 100644
1478
--- buildscripts/idl/idl/syntax.py
1479
+++ buildscripts/idl/idl/syntax.py
1480
@@ -33,8 +33,6 @@ It maps 1-1 to the YAML file, and has not been checked if
1481
 it follows the rules of the IDL, etc.
1482
 """
1483
 
1484
-from __future__ import absolute_import, print_function, unicode_literals
1485
-
1486
 import itertools
1487
 from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
1488
 
1489
@@ -70,7 +68,7 @@ class IDLSpec(object):
1490
 
1491
 
1492
 def parse_array_type(name):
1493
-    # type: (unicode) -> unicode
1494
+    # type: (str) -> str
1495
     """Parse a type name of the form 'array<type>' and extract type."""
1496
     if not name.startswith("array<") and not name.endswith(">"):
1497
         return None
1498
@@ -94,8 +92,7 @@ def _zip_scalar(items, obj):
1499
 def _item_and_type(dic):
1500
     # type: (Dict[Any, List[Any]]) -> Iterator[Tuple[Any, Any]]
1501
     """Return an Iterator of (key, value) pairs from a dictionary."""
1502
-    return itertools.chain.from_iterable((_zip_scalar(value, key)
1503
-                                          for (key, value) in dic.viewitems()))
1504
+    return itertools.chain.from_iterable((_zip_scalar(value, key) for (key, value) in dic.items()))
1505
 
1506
 
1507
 class SymbolTable(object):
1508
@@ -115,7 +112,7 @@ class SymbolTable(object):
1509
         self.types = []  # type: List[Type]
1510
 
1511
     def _is_duplicate(self, ctxt, location, name, duplicate_class_name):
1512
-        # type: (errors.ParserContext, common.SourceLocation, unicode, unicode) -> bool
1513
+        # type: (errors.ParserContext, common.SourceLocation, str, str) -> bool
1514
         """Return true if the given item already exist in the symbol table."""
1515
         for (item, entity_type) in _item_and_type({
1516
                 "command": self.commands,
1517
@@ -179,12 +176,12 @@ class SymbolTable(object):
1518
             self.add_type(ctxt, idltype)
1519
 
1520
     def resolve_field_type(self, ctxt, location, field_name, type_name):
1521
-        # type: (errors.ParserContext, common.SourceLocation, unicode, unicode) -> Optional[Union[Command, Enum, Struct, Type]]
1522
+        # type: (errors.ParserContext, common.SourceLocation, str, str) -> Optional[Union[Command, Enum, Struct, Type]]
1523
         """Find the type or struct a field refers to or log an error."""
1524
         return self._resolve_field_type(ctxt, location, field_name, type_name)
1525
 
1526
     def _resolve_field_type(self, ctxt, location, field_name, type_name):
1527
-        # type: (errors.ParserContext, common.SourceLocation, unicode, unicode) -> Optional[Union[Command, Enum, Struct, Type]]
1528
+        # type: (errors.ParserContext, common.SourceLocation, str, str) -> Optional[Union[Command, Enum, Struct, Type]]
1529
         """Find the type or struct a field refers to or log an error."""
1530
         # pylint: disable=too-many-return-statements
1531
 
1532
@@ -237,15 +234,15 @@ class Import(common.SourceLocation):
1533
     """IDL imports object."""
1534
 
1535
     def __init__(self, file_name, line, column):
1536
-        # type: (unicode, int, int) -> None
1537
+        # type: (str, int, int) -> None
1538
         """Construct an Imports section."""
1539
-        self.imports = []  # type: List[unicode]
1540
+        self.imports = []  # type: List[str]
1541
 
1542
         # These are not part of the IDL syntax but are produced by the parser.
1543
         # List of imports with structs.
1544
-        self.resolved_imports = []  # type: List[unicode]
1545
+        self.resolved_imports = []  # type: List[str]
1546
         # All imports directly or indirectly included
1547
-        self.dependencies = []  # type: List[unicode]
1548
+        self.dependencies = []  # type: List[str]
1549
 
1550
         super(Import, self).__init__(file_name, line, column)
1551
 
1552
@@ -262,16 +259,16 @@ class Type(common.SourceLocation):
1553
     # pylint: disable=too-many-instance-attributes
1554
 
1555
     def __init__(self, file_name, line, column):
1556
-        # type: (unicode, int, int) -> None
1557
+        # type: (str, int, int) -> None
1558
         """Construct a Type."""
1559
-        self.name = None  # type: unicode
1560
-        self.description = None  # type: unicode
1561
-        self.cpp_type = None  # type: unicode
1562
-        self.bson_serialization_type = None  # type: List[unicode]
1563
-        self.bindata_subtype = None  # type: unicode
1564
-        self.serializer = None  # type: unicode
1565
-        self.deserializer = None  # type: unicode
1566
-        self.default = None  # type: unicode
1567
+        self.name = None  # type: str
1568
+        self.description = None  # type: str
1569
+        self.cpp_type = None  # type: str
1570
+        self.bson_serialization_type = None  # type: List[str]
1571
+        self.bindata_subtype = None  # type: str
1572
+        self.serializer = None  # type: str
1573
+        self.deserializer = None  # type: str
1574
+        self.default = None  # type: str
1575
 
1576
         super(Type, self).__init__(file_name, line, column)
1577
 
1578
@@ -288,15 +285,15 @@ class Field(common.SourceLocation):
1579
     # pylint: disable=too-many-instance-attributes
1580
 
1581
     def __init__(self, file_name, line, column):
1582
-        # type: (unicode, int, int) -> None
1583
+        # type: (str, int, int) -> None
1584
         """Construct a Field."""
1585
-        self.name = None  # type: unicode
1586
-        self.cpp_name = None  # type: unicode
1587
-        self.description = None  # type: unicode
1588
-        self.type = None  # type: unicode
1589
+        self.name = None  # type: str
1590
+        self.cpp_name = None  # type: str
1591
+        self.description = None  # type: str
1592
+        self.type = None  # type: str
1593
         self.ignore = False  # type: bool
1594
         self.optional = False  # type: bool
1595
-        self.default = None  # type: unicode
1596
+        self.default = None  # type: str
1597
         self.supports_doc_sequence = False  # type: bool
1598
 
1599
         # Internal fields - not generated by parser
1600
@@ -314,10 +311,10 @@ class ChainedStruct(common.SourceLocation):
1601
     """
1602
 
1603
     def __init__(self, file_name, line, column):
1604
-        # type: (unicode, int, int) -> None
1605
+        # type: (str, int, int) -> None
1606
         """Construct a Type."""
1607
-        self.name = None  # type: unicode
1608
-        self.cpp_name = None  # type: unicode
1609
+        self.name = None  # type: str
1610
+        self.cpp_name = None  # type: str
1611
 
1612
         super(ChainedStruct, self).__init__(file_name, line, column)
1613
 
1614
@@ -330,10 +327,10 @@ class ChainedType(common.SourceLocation):
1615
     """
1616
 
1617
     def __init__(self, file_name, line, column):
1618
-        # type: (unicode, int, int) -> None
1619
+        # type: (str, int, int) -> None
1620
         """Construct a Type."""
1621
-        self.name = None  # type: unicode
1622
-        self.cpp_name = None  # type: unicode
1623
+        self.name = None  # type: str
1624
+        self.cpp_name = None  # type: str
1625
 
1626
         super(ChainedType, self).__init__(file_name, line, column)
1627
 
1628
@@ -348,10 +345,10 @@ class Struct(common.SourceLocation):
1629
     # pylint: disable=too-many-instance-attributes
1630
 
1631
     def __init__(self, file_name, line, column):
1632
-        # type: (unicode, int, int) -> None
1633
+        # type: (str, int, int) -> None
1634
         """Construct a Struct."""
1635
-        self.name = None  # type: unicode
1636
-        self.description = None  # type: unicode
1637
+        self.name = None  # type: str
1638
+        self.description = None  # type: str
1639
         self.strict = True  # type: bool
1640
         self.immutable = False  # type: bool
1641
         self.inline_chained_structs = False  # type: bool
1642
@@ -389,10 +386,10 @@ class EnumValue(common.SourceLocation):
1643
     """
1644
 
1645
     def __init__(self, file_name, line, column):
1646
-        # type: (unicode, int, int) -> None
1647
+        # type: (str, int, int) -> None
1648
         """Construct an Enum."""
1649
-        self.name = None  # type: unicode
1650
-        self.value = None  # type: unicode
1651
+        self.name = None  # type: str
1652
+        self.value = None  # type: str
1653
 
1654
         super(EnumValue, self).__init__(file_name, line, column)
1655
 
1656
@@ -405,11 +402,11 @@ class Enum(common.SourceLocation):
1657
     """
1658
 
1659
     def __init__(self, file_name, line, column):
1660
-        # type: (unicode, int, int) -> None
1661
+        # type: (str, int, int) -> None
1662
         """Construct an Enum."""
1663
-        self.name = None  # type: unicode
1664
-        self.description = None  # type: unicode
1665
-        self.type = None  # type: unicode
1666
+        self.name = None  # type: str
1667
+        self.description = None  # type: str
1668
+        self.type = None  # type: str
1669
         self.values = None  # type: List[EnumValue]
1670
 
1671
         # Internal property that is not represented as syntax. An imported enum is read from an
1672
-- 
1673
2.28.0
1674
1675
1676
From 90f2a9fb3ebe659b3d884e3a94bb5fc0a8ef5f69 Mon Sep 17 00:00:00 2001
1677
From: MikaelUrankar <mikael.urankar@gmail.com>
1678
Date: Sat, 3 Oct 2020 18:35:50 +0200
1679
Subject: [PATCH 20/24] backport src/mongo/base/generate_error_codes.py
1680
1681
---
1682
 src/mongo/base/generate_error_codes.py | 24 ++++++++++++++----------
1683
 1 file changed, 14 insertions(+), 10 deletions(-)
1684
1685
diff --git a/src/mongo/base/generate_error_codes.py b/src/mongo/base/generate_error_codes.py
1686
index 5de9e524..6538b6b5 100644
1687
--- src/mongo/base/generate_error_codes.py
1688
+++ src/mongo/base/generate_error_codes.py
1689
@@ -26,7 +26,6 @@
1690
 # delete this exception statement from your version. If you delete this
1691
 # exception statement from all source files in the program, then also delete
1692
 # it in the license file.
1693
-
1694
 """Generate error_codes.{h,cpp} from error_codes.err.
1695
 
1696
 Format of error_codes.err:
1697
@@ -51,10 +50,9 @@ def render_template(template_path, **kw):
1698
        returns the result as a string'''
1699
 
1700
     template = Template.compile(
1701
-            file=template_path,
1702
-            compilerSettings=dict(directiveStartToken="//#",directiveEndToken="//#"),
1703
-            baseclass=dict,
1704
-            useCache=False)
1705
+         file=template_path,
1706
+         compilerSettings=dict(directiveStartToken="//#", directiveEndToken="//#",
1707
+                               commentStartToken="//##"), baseclass=dict, useCache=False)
1708
     return str(template(**kw))
1709
 
1710
 class ErrorCode:
1711
@@ -63,11 +61,13 @@ class ErrorCode:
1712
         self.code = code
1713
         self.categories = []
1714
 
1715
+
1716
 class ErrorClass:
1717
     def __init__(self, name, codes):
1718
         self.name = name
1719
         self.codes = codes
1720
 
1721
+
1722
 def main(argv):
1723
     # Parse and validate argv.
1724
     if len(sys.argv) < 2:
1725
@@ -94,7 +94,7 @@ def main(argv):
1726
                 categories=error_classes,
1727
                 )
1728
 
1729
-        with open(output, 'wb') as outfile:
1730
+        with open(output, 'w') as outfile:
1731
             outfile.write(text)
1732
 
1733
 def die(message=None):
1734
@@ -126,6 +126,7 @@ def check_for_conflicts(error_codes, error_classes):
1735
     if failed:
1736
         die()
1737
 
1738
+
1739
 def has_duplicate_error_codes(error_codes):
1740
     sorted_by_name = sorted(error_codes, key=lambda x: x.name)
1741
     sorted_by_code = sorted(error_codes, key=lambda x: x.code)
1742
@@ -134,21 +135,22 @@ def has_duplicate_error_codes(error_codes):
1743
     prev = sorted_by_name[0]
1744
     for curr in sorted_by_name[1:]:
1745
         if curr.name == prev.name:
1746
-            sys.stdout.write('Duplicate name %s with codes %s and %s\n'
1747
-                    % (curr.name, curr.code, prev.code))
1748
+            sys.stdout.write(
1749
+                'Duplicate name %s with codes %s and %s\n' % (curr.name, curr.code, prev.code))
1750
             failed = True
1751
         prev = curr
1752
 
1753
     prev = sorted_by_code[0]
1754
     for curr in sorted_by_code[1:]:
1755
         if curr.code == prev.code:
1756
-            sys.stdout.write('Duplicate code %s with names %s and %s\n'
1757
-                    % (curr.code, curr.name, prev.name))
1758
+            sys.stdout.write(
1759
+                'Duplicate code %s with names %s and %s\n' % (curr.code, curr.name, prev.name))
1760
             failed = True
1761
         prev = curr
1762
 
1763
     return failed
1764
 
1765
+
1766
 def has_duplicate_error_classes(error_classes):
1767
     names = sorted(ec.name for ec in error_classes)
1768
 
1769
@@ -161,6 +163,7 @@ def has_duplicate_error_classes(error_classes):
1770
         prev_name = name
1771
     return failed
1772
 
1773
+
1774
 def has_missing_error_codes(error_codes, error_classes):
1775
     code_names = dict((ec.name, ec) for ec in error_codes)
1776
     failed = False
1777
@@ -174,5 +177,6 @@ def has_missing_error_codes(error_codes, error_classes):
1778
 
1779
     return failed
1780
 
1781
+
1782
 if __name__ == '__main__':
1783
     main(sys.argv)
1784
-- 
1785
2.28.0
1786
1787
1788
From 4418d8f8c9e432e380a4e611f5475ba3a4d76699 Mon Sep 17 00:00:00 2001
1789
From: MikaelUrankar <mikael.urankar@gmail.com>
1790
Date: Sat, 3 Oct 2020 19:34:19 +0200
1791
Subject: [PATCH 21/24] backport site_scons/site_tools/idl_tool.py
1792
1793
---
1794
 site_scons/site_tools/idl_tool.py | 14 +++++---------
1795
 1 file changed, 5 insertions(+), 9 deletions(-)
1796
1797
diff --git a/site_scons/site_tools/idl_tool.py b/site_scons/site_tools/idl_tool.py
1798
index 78bedfaa..fc53b3ae 100755
1799
--- site_scons/site_tools/idl_tool.py
1800
+++ site_scons/site_tools/idl_tool.py
1801
@@ -21,6 +21,7 @@ import sys
1802
 
1803
 import SCons
1804
 
1805
+
1806
 def idlc_emitter(target, source, env):
1807
     """For each input IDL file, the tool produces a .cpp and .h file."""
1808
     first_source = str(source[0])
1809
@@ -43,7 +44,7 @@ IDLCAction = SCons.Action.Action('$IDLCCOM', '$IDLCCOMSTR')
1810
 def idl_scanner(node, env, path):
1811
     # Use the import scanner mode of the IDL compiler to file imported files
1812
     cmd = [sys.executable, "buildscripts/idl/idlc.py",  '--include','src', str(node), '--write-dependencies']
1813
-    deps_str = subprocess.check_output(cmd)
1814
+    deps_str = subprocess.check_output(cmd).decode('utf-8')
1815
 
1816
     deps_list = deps_str.splitlines()
1817
 
1818
@@ -57,19 +58,14 @@ def idl_scanner(node, env, path):
1819
 idl_scanner = SCons.Scanner.Scanner(function=idl_scanner, skeys=['.idl'])
1820
 
1821
 # TODO: create a scanner for imports when imports are implemented
1822
-IDLCBuilder = SCons.Builder.Builder(
1823
-    action=IDLCAction,
1824
-    emitter=idlc_emitter,
1825
-    srcsuffx=".idl",
1826
-    suffix=".cpp",
1827
-    source_scanner = idl_scanner
1828
-    )
1829
+IDLCBuilder = SCons.Builder.Builder(action=IDLCAction, emitter=idlc_emitter, srcsuffx=".idl",
1830
+                                    suffix=".cpp", source_scanner=idl_scanner)
1831
 
1832
 
1833
 def generate(env):
1834
     bld = IDLCBuilder
1835
 
1836
-    env.Append(SCANNERS = idl_scanner)
1837
+    env.Append(SCANNERS=idl_scanner)
1838
 
1839
     env['BUILDERS']['Idlc'] = bld
1840
 
1841
-- 
1842
2.28.0
1843
1844
1845
From 185809c361b8c495002ed26485237164d31de367 Mon Sep 17 00:00:00 2001
1846
From: MikaelUrankar <mikael.urankar@gmail.com>
1847
Date: Sat, 3 Oct 2020 19:53:37 +0200
1848
Subject: [PATCH 22/24] backport
1849
 src/mongo/db/query/collation/generate_icu_init_cpp.py
1850
1851
---
1852
 src/mongo/db/query/collation/generate_icu_init_cpp.py | 6 ++++--
1853
 1 file changed, 4 insertions(+), 2 deletions(-)
1854
1855
diff --git a/src/mongo/db/query/collation/generate_icu_init_cpp.py b/src/mongo/db/query/collation/generate_icu_init_cpp.py
1856
index a95740b8..2a550a0c 100755
1857
--- src/mongo/db/query/collation/generate_icu_init_cpp.py
1858
+++ src/mongo/db/query/collation/generate_icu_init_cpp.py
1859
@@ -31,6 +31,7 @@ import optparse
1860
 import os
1861
 import sys
1862
 
1863
+
1864
 def main(argv):
1865
     parser = optparse.OptionParser()
1866
     parser.add_option('-o', '--output', action='store', dest='output_cpp_file',
1867
@@ -46,6 +47,7 @@ def main(argv):
1868
         parser.error("input ICU data file unspecified")
1869
     generate_cpp_file(options.input_data_file, options.output_cpp_file)
1870
 
1871
+
1872
 def generate_cpp_file(data_file_path, cpp_file_path):
1873
     source_template = '''// AUTO-GENERATED FILE DO NOT EDIT
1874
 // See generate_icu_init_cpp.py.
1875
@@ -112,8 +114,8 @@ MONGO_INITIALIZER(LoadICUData)(InitializerContext* context) {
1876
 '''
1877
     decimal_encoded_data = ''
1878
     with open(data_file_path, 'rb') as data_file:
1879
-        decimal_encoded_data = ','.join([str(ord(byte)) for byte in data_file.read()])
1880
-    with open(cpp_file_path, 'wb') as cpp_file:
1881
+        decimal_encoded_data = ','.join([str(byte) for byte in data_file.read()])
1882
+    with open(cpp_file_path, 'w') as cpp_file:
1883
         cpp_file.write(source_template % dict(decimal_encoded_data=decimal_encoded_data))
1884
 
1885
 if __name__ == '__main__':
1886
-- 
1887
2.28.0
1888
1889
1890
From 636d99fde6ba86fb3d4ae959e5ea9433e94f2390 Mon Sep 17 00:00:00 2001
1891
From: MikaelUrankar <mikael.urankar@gmail.com>
1892
Date: Sat, 3 Oct 2020 20:02:29 +0200
1893
Subject: [PATCH 23/24] backport site_scons/site_tools/jstoh.py
1894
1895
---
1896
 site_scons/site_tools/jstoh.py | 6 +++---
1897
 1 file changed, 3 insertions(+), 3 deletions(-)
1898
1899
diff --git a/site_scons/site_tools/jstoh.py b/site_scons/site_tools/jstoh.py
1900
index dc90b324..d8998179 100644
1901
--- site_scons/site_tools/jstoh.py
1902
+++ site_scons/site_tools/jstoh.py
1903
@@ -39,8 +39,8 @@ def jsToHeader(target, source):
1904
 
1905
     text = '\n'.join(h)
1906
 
1907
-    print "writing: %s" % outFile
1908
-    with open(outFile, 'wb') as out:
1909
+    print ("writing: %s" % outFile)
1910
+    with open(outFile, 'w') as out:
1911
         try:
1912
             out.write(text)
1913
         finally:
1914
@@ -49,7 +49,7 @@ def jsToHeader(target, source):
1915
 
1916
 if __name__ == "__main__":
1917
     if len(sys.argv) < 3:
1918
-        print "Must specify [target] [source] "
1919
+        print("Must specify [target] [source] ")
1920
         sys.exit(1)
1921
 
1922
     jsToHeader(sys.argv[1], sys.argv[2:])
1923
-- 
1924
2.28.0
1925
1926
1927
From 7edbc7b873c0dc04fb96b125a8749fa29f7b8baf Mon Sep 17 00:00:00 2001
1928
From: MikaelUrankar <mikael.urankar@gmail.com>
1929
Date: Sat, 3 Oct 2020 20:08:21 +0200
1930
Subject: [PATCH 24/24] backport src/mongo/db/fts/generate_stop_words.py
1931
1932
---
1933
 src/mongo/db/fts/generate_stop_words.py | 9 +++++----
1934
 1 file changed, 5 insertions(+), 4 deletions(-)
1935
1936
diff --git a/src/mongo/db/fts/generate_stop_words.py b/src/mongo/db/fts/generate_stop_words.py
1937
index e0dc801c..6893ba91 100644
1938
--- src/mongo/db/fts/generate_stop_words.py
1939
+++ src/mongo/db/fts/generate_stop_words.py
1940
@@ -7,7 +7,7 @@ def generate( header, source, language_files ):
1941
     for x in language_files:
1942
         print( "\t%s" % x )
1943
 
1944
-    out = open( header, "wb" )
1945
+    out = open( header, "w" )
1946
     out.write( """
1947
 #pragma once
1948
 #include <set>
1949
@@ -24,8 +24,8 @@ namespace fts {
1950
 
1951
 
1952
 
1953
-    out = open( source, "wb" )
1954
-    out.write( '#include "%s"' % header.rpartition( "/" )[2].rpartition( "\\" )[2] )
1955
+    out = open( source, "w", encoding='utf-8')
1956
+    out.write( '#include "{}"'.format(header.rpartition( "/" )[2].rpartition( "\\" )[2]) )
1957
     out.write( """
1958
 namespace mongo {
1959
 namespace fts {
1960
@@ -41,12 +41,13 @@ namespace fts {
1961
         out.write( '  {\n' )
1962
         out.write( '   const char* const words[] = {\n' )
1963
         for word in open( l_file, "rb" ):
1964
-            out.write( '       "%s",\n' % word.strip() )
1965
+            out.write( '       "%s",\n' % word.decode('utf-8').strip() )
1966
         out.write( '   };\n' )
1967
         out.write( '   const size_t wordcnt = sizeof(words) / sizeof(words[0]);\n' )
1968
         out.write( '   std::set< std::string >& l = (*m)["%s"];\n' % l )
1969
         out.write( '   l.insert(&words[0], &words[wordcnt]);\n' )
1970
         out.write( '  }\n' )
1971
+
1972
     out.write( """
1973
   }
1974
 } // namespace fts
1975
-- 
1976
2.28.0
1977

Return to bug 249597