Nuitka-0.6.19.1/ 0000700 0003721 0003721 00000000000 14167275622 020273 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/ 0000700 0003721 0003721 00000000000 14167275622 021435 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/run-tests 0000700 0003721 0003721 00000002331 14166627112 023320 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Part of "Nuitka", an optimizing Python compiler that is compatible and
# integrates with CPython, but also works on its own.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Main front-end to the tests of Nuitka.
Has many options, read --help output.
"""
import os
import sys
# Unchanged, running from checkout, use the parent directory, the nuitka
# package ought be there.
sys.path.insert(
0,
os.path.normpath(
os.path.join(
os.path.dirname(__file__),
"..",
)
)
)
# isort:start
from nuitka.tools.testing.run_nuitka_tests.__main__ import main
main()
Nuitka-0.6.19.1/tests/packages/ 0000700 0003721 0003721 00000000000 14167275622 023213 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/ 0000700 0003721 0003721 00000000000 14167275622 032620 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011211 L ustar 0000000 0000000 Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/PackageImportSuccessAfterFailure.py Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/PackageImportSuccessAfterFailure0000600 0003721 0003721 00000004516 14166627112 041116 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
# nuitka-project: --follow-import-to=variable_package
ORIG = None
def display_difference(dct):
print(ORIG.symmetric_difference(dct))
# Python2 has this in globals() so force it there for Python3
# to have same ORIG.
if str is bytes:
e = None
ORIG = set(globals())
print("Initial try on top level package:")
try:
import variable_package
except BaseException as e:
print("Occurred", str(e))
display_difference(globals())
print("Retry with submodule import:")
try:
from variable_package.SomeModule import Class4
except BaseException as e:
print("Occurred", str(e))
display_difference(globals())
print("Try with import from submodule:")
try:
from variable_package import SomeModule
except BaseException as e:
print("Occurred", str(e))
display_difference(globals())
print("Try with variable import from top level package assigned before raise:")
try:
from variable_package import raisy
except BaseException as e:
print("Occurred", str(e))
display_difference(globals())
print("Try with variable import from top level package assigned after raise:")
try:
from variable_package import Class5
except BaseException as e:
print("Occurred", str(e))
display_difference(globals())
print("Try with variable import from top level package assigned before raise:")
try:
from variable_package import Class3
except BaseException as e:
print("Occurred", str(e))
display_difference(globals().keys())
Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/variable_package/ 0000700 0003721 0003721 00000000000 14167275622 036060 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/variable_package/SomeModule.py 0000600 0003721 0003721 00000001656 14166627112 040507 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class Class4(object):
VALUE = "some_value"
Nuitka-0.6.19.1/tests/packages/package_import_success_after_failure/variable_package/__init__.py 0000600 0003721 0003721 00000002217 14166627112 040167 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
class Class3(object):
pass
def raisy():
if os.getenv("SHALL_FAIL", "1") == "1":
print("RAISING!")
raise Exception("AHOJ")
raisy()
class Class5(object):
PASSW = "Secret"
def __init__(self):
print(self.PASSW, 2 + 3)
Nuitka-0.6.19.1/tests/packages/sub_package/ 0000700 0003721 0003721 00000000000 14167275622 025457 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/packages/sub_package/kitty/ 0000700 0003721 0003721 00000000000 14167275622 026623 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/packages/sub_package/kitty/smallkitty.py 0000600 0003721 0003721 00000001616 14166627112 031372 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
size = "small"
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/bigkitty.py 0000600 0003721 0003721 00000001614 14166627112 031021 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
size = "big"
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/__init__.py 0000600 0003721 0003721 00000002315 14166627112 030731 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
print("__name__ is", __name__)
if sys.version_info[:2] != (3,2):
print("__package__ is", __package__)
else:
print("__package__ is correct:", __package__ is None or __package__ == "kitty")
print("From sys.modules", sys.modules["kitty"])
from kitty.speak.hello import speak
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/speak/ 0000700 0003721 0003721 00000000000 14167275622 027726 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/packages/sub_package/kitty/speak/purr.py 0000600 0003721 0003721 00000001707 14166627112 031271 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def speak():
print("mrrruu")
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/speak/miau.py 0000600 0003721 0003721 00000001705 14166627112 031232 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def speak():
print("miau")
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/speak/__init__.py 0000600 0003721 0003721 00000002043 14166627112 032032 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
try:
print("__loader__ present:", __loader__ is not None)
except NameError:
print("No __loader__ found, OK for Python2")
print("OK,", __name__, "loaded.")
Nuitka-0.6.19.1/tests/packages/sub_package/kitty/speak/hello.py 0000600 0003721 0003721 00000002034 14166627112 031376 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def speak():
print( "hello kitty" )
# Test Issue#115, in recursing modules, this was misbehaving.
import types
assert type(speak) == types.FunctionType
Nuitka-0.6.19.1/tests/packages/run_all.py 0000700 0003721 0003721 00000006613 14166627112 025224 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for package tests of Nuitka.
Package tests are typically aiming at checking specific module constellations
in module mode and making sure the details are being right there. These are
synthetic small packages, each of which try to demonstrate one or more points
or special behaviour.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
compareWithCPython,
createSearchMode,
getTempDir,
my_print,
setup,
)
def main():
setup(suite="packages")
search_mode = createSearchMode()
for filename in sorted(os.listdir(".")):
if not os.path.isdir(filename) or filename.endswith(".build"):
continue
extra_flags = [
"--module",
"expect_success",
"remove_output",
"two_step_execution",
]
active = search_mode.consider(dirname=None, filename=filename)
if active:
my_print("Consider output of compiled package:", filename)
filename_main = None
filename_main = os.path.join(
filename, "".join(part.title() for part in filename.split("_")) + ".py"
)
if os.path.exists(filename_main):
filename_main = os.path.basename(filename_main)
else:
filename_main = None
if filename_main is None:
for filename_main in os.listdir(filename):
if not os.path.isdir(os.path.join(filename, filename_main)):
continue
if filename_main not in ("..", "."):
break
else:
search_mode.onErrorDetected(
"""\
Error, no package in test directory '%s' found, incomplete test case."""
% filename
)
extra_flags.append(
"--include-package=%s" % os.path.basename(filename_main)
)
extra_flags.append("--output-dir=%s" % getTempDir())
compareWithCPython(
dirname=filename,
filename=filename_main,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/syntax/ 0000700 0003721 0003721 00000000000 14167275622 022763 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/syntax/ClassReturn.py 0000600 0003721 0003721 00000001427 14166627112 025602 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class X:
return 3
Nuitka-0.6.19.1/tests/syntax/YieldInAsync35.py 0000600 0003721 0003721 00000001444 14166627112 026037 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
async def g():
yield from None
Nuitka-0.6.19.1/tests/syntax/NonAsciiWithoutEncoding_2.py 0000600 0003721 0003721 00000001563 14166627112 030315 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# No encoding declared, but non-ASCII in that string.
s = "'\0\"\n\r\t abcd\x85é\U00012fff\uD800\U0001D121xxx."
Nuitka-0.6.19.1/tests/syntax/TryExceptAllNotLast.py 0000600 0003721 0003721 00000001531 14166627112 027216 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f():
try:
raise A
except:
print("caught")
except A:
print("hit")
Nuitka-0.6.19.1/tests/syntax/AsyncgenReturn36.py 0000600 0003721 0003721 00000001451 14166627112 026452 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
async def gen():
yield 1
return 2
Nuitka-0.6.19.1/tests/syntax/BreakWithoutLoop.py 0000600 0003721 0003721 00000001542 14166627112 026575 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# marker1
def test_from_format(self):
if sys.version_info >= (3, 3):
break
# marker2
Nuitka-0.6.19.1/tests/syntax/TryFinallyContinue_37.py 0000600 0003721 0003721 00000001553 14166627112 027450 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f():
for i in range(10):
try:
undefined
finally:
continue
Nuitka-0.6.19.1/tests/syntax/FutureBraces.py 0000600 0003721 0003721 00000001472 14166627112 025727 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import braces
print("Look ma, braces.")
Nuitka-0.6.19.1/tests/syntax/StarImportExtra.py 0000600 0003721 0003721 00000001577 14166627112 026453 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
try:
from sys import not_there, *
except Exception as e:
print( "Star import with extra stuff not present gave", e )
Nuitka-0.6.19.1/tests/syntax/YieldInModule.py 0000600 0003721 0003721 00000001420 14166627112 026031 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
x = (yield i)
Nuitka-0.6.19.1/tests/syntax/YieldFromInModule.py 0000600 0003721 0003721 00000001434 14166627112 026662 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
x = (yield from range(8))
Nuitka-0.6.19.1/tests/syntax/run_all.py 0000700 0003721 0003721 00000004233 14166627112 024770 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for syntax tests of Nuitka.
In some cases, the ast module doesn't raise the syntax errors for us, but
we need to check them manually and raise explicitly. This aims at showing
we do it in the same way.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
compareWithCPython,
createSearchMode,
decideFilenameVersionSkip,
setup,
)
def main():
setup(suite="syntax", needs_io_encoding=True)
search_mode = createSearchMode()
for filename in sorted(os.listdir(".")):
if not filename.endswith(".py"):
continue
if not decideFilenameVersionSkip(filename):
continue
active = search_mode.consider(dirname=None, filename=filename)
if active:
extra_flags = [
"expect_failure",
"remove_output",
"syntax_errors",
"--nofollow-imports",
]
compareWithCPython(
dirname=None,
filename=filename,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/syntax/NonlocalNotFound32.py 0000600 0003721 0003721 00000001542 14166627112 026722 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def testNonlocal():
x = 0
y = 0
def f():
nonlocal z
f()
testNonlocal()
Nuitka-0.6.19.1/tests/syntax/UnpackNoTuple.py 0000600 0003721 0003721 00000001410 14166627112 026055 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
*a = 1
Nuitka-0.6.19.1/tests/syntax/SyntaxError.py 0000600 0003721 0003721 00000001545 14166627112 025636 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Test the syntax error case:
def nested():
claxss ProxyBase(metaclass=ProxyType):
pass
Nuitka-0.6.19.1/tests/syntax/NonlocalForParameter32.py 0000600 0003721 0003721 00000001433 14166627112 027554 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f(a):
nonlocal a
Nuitka-0.6.19.1/tests/syntax/UnpackTwoStars32.py 0000600 0003721 0003721 00000001451 14166627112 026427 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
foo, *bar, baz, *a, b = name.split('/')
Nuitka-0.6.19.1/tests/syntax/MisplacedFutureImport.py 0000600 0003721 0003721 00000001512 14166627112 027617 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f():
from __future__ import print_function
print(locals())
Nuitka-0.6.19.1/tests/syntax/ModuleReturn.py 0000600 0003721 0003721 00000001441 14166627112 025756 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
lalala = 3
return
lelele = 7
Nuitka-0.6.19.1/tests/syntax/DuplicateArgument.py 0000600 0003721 0003721 00000001427 14166627112 026752 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f(a, a):
pass
Nuitka-0.6.19.1/tests/syntax/FutureUnknown.py 0000600 0003721 0003721 00000001445 14166627112 026167 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import not_existing
Nuitka-0.6.19.1/tests/syntax/GlobalForParameter.py 0000600 0003721 0003721 00000001431 14166627112 027040 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f(a):
global a
Nuitka-0.6.19.1/tests/syntax/YieldInGenexp38.py 0000600 0003721 0003721 00000001632 14166627112 026212 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def strangeLambdaGeneratorExpression():
x = ((yield) for i in (1,2) if (yield))
print("Strange lambda generator expression")
print(list(x))
Nuitka-0.6.19.1/tests/syntax/GeneratorExpressions38.py 0000600 0003721 0003721 00000002021 14166627112 027670 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test case with generator expression form only allow until Python 3.7
"""
def strangeLambdaGeneratorExpression():
x = ((yield) for i in (1, 2) if (yield))
print("Strange lambda generator expression:")
print(list(x))
strangeLambdaGeneratorExpression()
Nuitka-0.6.19.1/tests/syntax/LateFutureImport.py 0000600 0003721 0003721 00000001604 14166627112 026605 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Not allowed to do future imports that are not the first statements of the
# module.
a = 1
from __future__ import print_function
Nuitka-0.6.19.1/tests/syntax/ContinueWithoutLoop.py 0000600 0003721 0003721 00000001522 14166627112 027333 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def test_from_format(self):
if sys.version_info >= (3, 3):
continue
Nuitka-0.6.19.1/tests/syntax/IndentationError.py 0000600 0003721 0003721 00000001437 14166627112 026624 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def someFunc():
a
b
Nuitka-0.6.19.1/tests/syntax/GeneratorReturn_2.py 0000600 0003721 0003721 00000001557 14166627112 026710 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def g():
for a in range(3):
yield a
return 7
print("Yielder with return value", list(g()))
Nuitka-0.6.19.1/tests/syntax/ExecWithNesting_2.py 0000600 0003721 0003721 00000002127 14166627112 026624 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# In Python2, it is not allowed to take closure variables, in a function that
# has an "exec". For Python3, the problem doesn't exist, as there is no exec
# statement anymore.
def someFunctionWithUnqualifiedExecAndCallback():
exec "def f(): pass"
def callback():
return nested
someFunctionWithUnqualifiedExecAndCallback()
Nuitka-0.6.19.1/tests/syntax/Importing32.py 0000600 0003721 0003721 00000001743 14166627112 025453 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def starImportFailure():
from doctest import *
try:
sys
print("but it does not")
except NameError:
print("and it does")
print("Star import needs to respect __all__", starImportFailure())
Nuitka-0.6.19.1/tests/syntax/ClosureDel_2.py 0000600 0003721 0003721 00000001712 14166627112 025614 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def deletingClosure():
a = 1
def closureTaker():
return a
del a
try:
x = closureTaker()
except Exception as e:
print "Occurred %r" % e
deletingClosure()
Nuitka-0.6.19.1/tests/reflected/ 0000700 0003721 0003721 00000000000 14167275622 023372 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/reflected/compile_itself.py 0000700 0003721 0003721 00000031743 14166627112 026747 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test Nuitka compiling itself and compiling itself in compiled form again.
This should not only give no errors, but the same source for modules being
compiled when Nuitka is running compiled and uncompiled, so we can discover
changes in order of execution in this test.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
import difflib
import shutil
import subprocess
import time
from nuitka.tools.testing.Common import (
getTempDir,
my_print,
setup,
test_logger,
)
from nuitka.utils.Execution import wrapCommandForDebuggerForSubprocess
from nuitka.utils.FileOperations import copyTree, listDir, removeDirectory
from nuitka.utils.Importing import getSharedLibrarySuffix
nuitka_main_path = os.path.join("..", "..", "bin", "nuitka")
tmp_dir = getTempDir()
# Cannot detect this more automatic, so we need to list them, avoiding
# the ones not needed.
PACKAGE_LIST = (
"nuitka",
"nuitka/nodes",
"nuitka/specs",
"nuitka/nodes/shapes",
"nuitka/tree",
"nuitka/importing",
"nuitka/build",
"nuitka/freezer",
"nuitka/codegen",
"nuitka/codegen/templates",
"nuitka/codegen/c_types",
"nuitka/optimizations",
"nuitka/finalizations",
"nuitka/plugins",
"nuitka/plugins/standard",
"nuitka/plugins/commercial",
"nuitka/pgo",
"nuitka/constants",
"nuitka/containers",
"nuitka/utils",
)
exe_suffix = ".exe" if os.name == "nt" else ".bin"
def readSource(filename):
if str is bytes:
return open(filename, "rb").read()
else:
return open(filename, "rb").read().decode("latin1")
def diffRecursive(dir1, dir2):
# Complex in nature, pylint: disable=too-many-branches
done = set()
result = False
for path1, filename in listDir(dir1):
if "cache-" in path1:
continue
path2 = os.path.join(dir2, filename)
done.add(path1)
# Skip these binary files and scons build database of course.
# TODO: Temporary ignore ".bin", until we have something better than marshal which behaves
# differently in compiled Nuitka:
if filename.endswith(
(
".o",
".os",
".obj",
".dblite",
".tmp",
".sconsign",
".txt",
".bin",
".const",
".exp",
)
):
continue
if not os.path.exists(path2):
test_logger.warning("Only in %s: %s" % (dir1, filename))
result = False
continue
if os.path.isdir(path1):
r = diffRecursive(path1, path2)
if r:
result = True
elif os.path.isfile(path1):
fromdate = time.ctime(os.stat(path1).st_mtime)
todate = time.ctime(os.stat(path2).st_mtime)
diff = difflib.unified_diff(
a=readSource(path1).splitlines(),
b=readSource(path2).splitlines(),
fromfile=path1,
tofile=path2,
fromfiledate=fromdate,
tofiledate=todate,
n=3,
)
diff_list = list(diff)
if diff_list:
for line in diff_list:
try:
my_print(line)
except UnicodeEncodeError:
my_print(repr(line))
result = True
else:
assert False, path1
for path1, filename in listDir(dir2):
if "cache-" in path1:
continue
path2 = os.path.join(dir2, filename)
if path1 in done:
continue
if not os.path.exists(path1):
test_logger.warning("Only in %s: %s" % (dir2, filename))
result = False
continue
return result
def _traceCompilation(path, pass_number):
test_logger.info("Compiling '%s' (PASS %d)." % (path, pass_number))
def executePASS1():
test_logger.info(
"PASS 1: Compiling to many compiled modules from compiler running from .py files."
)
base_dir = os.path.join("..", "..")
for package in PACKAGE_LIST:
package = package.replace("/", os.path.sep)
source_dir = os.path.join(base_dir, package)
target_dir = package
removeDirectory(path=target_dir, ignore_errors=False)
os.mkdir(target_dir)
for path, filename in listDir(target_dir):
if filename.endswith(".so"):
os.unlink(path)
for path, filename in listDir(source_dir):
if not filename.endswith(".py"):
continue
if filename.startswith(".#"):
continue
if filename != "__init__.py":
_traceCompilation(path=path, pass_number=1)
command = [
os.environ["PYTHON"],
nuitka_main_path,
"--module",
"--nofollow-imports",
"--plugin-enable=pylint-warnings",
"--output-dir=%s" % target_dir,
"--no-pyi-file",
path,
]
command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split()
my_print("Command: ", " ".join(command))
result = subprocess.call(command)
if result != 0:
sys.exit(result)
else:
shutil.copyfile(path, os.path.join(target_dir, filename))
_traceCompilation(path=nuitka_main_path, pass_number=1)
shutil.copyfile(nuitka_main_path, "nuitka-runner.py")
command = [
os.environ["PYTHON"],
nuitka_main_path,
"--nofollow-imports",
"--plugin-enable=pylint-warnings",
"--output-dir=.",
"--python-flag=-S",
"nuitka-runner.py",
]
command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split()
my_print("Command: ", " ".join(command))
result = subprocess.call(command)
if result != 0:
sys.exit(result)
shutil.move("nuitka-runner" + exe_suffix, "nuitka" + exe_suffix)
scons_inline_copy_path = os.path.join(base_dir, "nuitka", "build", "inline_copy")
if os.path.exists(scons_inline_copy_path):
copyTree(scons_inline_copy_path, os.path.join("nuitka", "build", "inline_copy"))
# Copy required data files.
for filename in (
"nuitka/build/Backend.scons",
"nuitka/plugins/standard/anti-bloat.yml",
"nuitka/plugins/standard/implicit-imports.yml",
"nuitka/plugins/standard/data-files.yml",
):
shutil.copyfile(
os.path.join(base_dir, filename),
filename,
)
copyTree(
os.path.join(base_dir, "nuitka", "codegen", "templates_c"),
os.path.join("nuitka", "codegen", "templates_c"),
)
copyTree(
os.path.join(base_dir, "nuitka", "build", "static_src"),
os.path.join("nuitka", "build", "static_src"),
)
copyTree(
os.path.join(base_dir, "nuitka", "build", "include"),
os.path.join("nuitka", "build", "include"),
)
# The data composer tool, use it by source.
copyTree(
os.path.join(base_dir, "nuitka", "tools"),
os.path.join("nuitka", "tools"),
)
test_logger.info("OK.")
def compileAndCompareWith(nuitka, pass_number):
if "PYTHONHASHSEED" not in os.environ:
os.environ["PYTHONHASHSEED"] = "0"
base_dir = os.path.join("..", "..")
for package in PACKAGE_LIST:
package = package.replace("/", os.path.sep)
source_dir = os.path.join(base_dir, package)
for path, filename in listDir(source_dir):
if not filename.endswith(".py"):
continue
if filename.startswith(".#"):
continue
path = os.path.join(source_dir, filename)
if filename != "__init__.py":
_traceCompilation(path=path, pass_number=pass_number)
target = filename.replace(".py", ".build")
target_dir = os.path.join(tmp_dir, target)
removeDirectory(path=target_dir, ignore_errors=False)
command = [
nuitka,
"--module",
"--plugin-enable=pylint-warnings",
"--output-dir=%s" % tmp_dir,
"--no-pyi-file",
path,
]
command += os.environ.get("NUITKA_EXTRA_OPTIONS", "").split()
my_print("Command: ", " ".join(command))
exit_nuitka = subprocess.call(command)
# In case of segfault or assertion triggered, run in debugger.
if exit_nuitka in (-11, -6) and sys.platform != "nt":
command2 = wrapCommandForDebuggerForSubprocess(*command)
subprocess.call(command2)
if exit_nuitka != 0:
my_print("An error exit %s occurred, aborting." % exit_nuitka)
sys.exit(exit_nuitka)
has_diff = diffRecursive(os.path.join(package, target), target_dir)
if has_diff:
sys.exit("There were differences!")
shutil.rmtree(target_dir)
target_filename = filename.replace(
".py", getSharedLibrarySuffix(preferred=True)
)
os.unlink(os.path.join(tmp_dir, target_filename))
def executePASS2():
test_logger.info(
"PASS 2: Compiling from compiler running from entry .exe and many .so files."
)
# Windows will load the compiled modules (pyd) only from PYTHONPATH, so we
# have to add it.
if os.name == "nt":
os.environ["PYTHONPATH"] = ":".join(PACKAGE_LIST)
compileAndCompareWith(
nuitka=os.path.join(".", "nuitka" + exe_suffix), pass_number=2
)
# Undo the damage from above.
if os.name == "nt":
del os.environ["PYTHONPATH"]
test_logger.info("OK.")
def executePASS3():
test_logger.info(
"PASS 3: Compiling from compiler running from .py files to single .exe."
)
exe_path = os.path.join(tmp_dir, "nuitka" + exe_suffix)
if os.path.exists(exe_path):
os.unlink(exe_path)
build_path = os.path.join(tmp_dir, "nuitka.build")
if os.path.exists(build_path):
shutil.rmtree(build_path)
path = os.path.join("..", "..", "bin", "nuitka")
_traceCompilation(path=path, pass_number=3)
command = [
os.environ["PYTHON"],
nuitka_main_path,
path,
"--output-dir=%s" % tmp_dir,
"--python-flag=-S",
"--follow-imports",
# "--include-package=nuitka.plugins",
]
my_print("Command: ", " ".join(command))
result = subprocess.call(command)
if result != 0:
sys.exit(result)
shutil.rmtree(build_path)
test_logger.info("OK.")
def executePASS4():
test_logger.info("PASS 4: Compiling the compiler running from single exe.")
exe_path = os.path.join(tmp_dir, "nuitka" + exe_suffix)
compileAndCompareWith(exe_path, pass_number=4)
test_logger.info("OK.")
def executePASS5():
my_print("PASS 5: Compiling the compiler 'nuitka' package to single '.so' file.")
path = os.path.join("..", "..", "nuitka")
command = [
os.environ["PYTHON"],
nuitka_main_path,
"--plugin-enable=pylint-warnings",
"--output-dir=%s" % tmp_dir,
"--include-plugin-dir=%s" % path,
"--nofollow-import-to=nuitka.build.inline_copy",
"--nofollow-import-to=nuitka.build.include",
"--nofollow-import-to=nuitka.build.static_src",
"--module",
path,
]
result = subprocess.call(command)
if result != 0:
sys.exit(result)
os.unlink(os.path.join(tmp_dir, "nuitka" + getSharedLibrarySuffix(preferred=True)))
os.unlink(os.path.join(tmp_dir, "nuitka.pyi"))
shutil.rmtree(os.path.join(tmp_dir, "nuitka.build"))
def main():
setup(needs_io_encoding=True)
executePASS1()
executePASS2()
executePASS3()
executePASS4()
shutil.rmtree("nuitka")
executePASS5()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/plugins/ 0000700 0003721 0003721 00000000000 14167275622 023116 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/plugins/run_all.py 0000700 0003721 0003721 00000007005 14166627112 025123 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for plugins tests of Nuitka.
Plugin tests are typically aiming at covering plugin interfaces and their
correctness, not concrete standard plugins.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
compareWithCPython,
createSearchMode,
getMainProgramFilename,
my_print,
setup,
withPythonPathChange,
)
def main():
# Complex stuff, even more should become common code though.
setup(suite="plugins", needs_io_encoding=True)
search_mode = createSearchMode()
extra_options = os.environ.get("NUITKA_EXTRA_OPTIONS", "")
# TODO: Add a directory test case scanner instead of duplicating this kind of code.
for filename in sorted(os.listdir(".")):
if (
not os.path.isdir(filename)
or filename.endswith(".build")
or filename.endswith(".dist")
):
continue
filename = os.path.relpath(filename)
extra_flags = ["expect_success"]
# We annotate some tests, use that to lower warnings.
extra_flags.append("plugin_enable:pylint-warnings")
extra_flags.append("remove_output")
extra_flags.append("--follow-imports")
plugin_files = [p for p in os.listdir(filename) if p.endswith("-plugin.py")]
assert plugin_files
extra_flags.extend(
"user_plugin:" + os.path.abspath(os.path.join(filename, p))
for p in plugin_files
)
if filename == "parameters":
os.environ["NUITKA_EXTRA_OPTIONS"] = extra_options + " --trace-my-plugin"
else:
os.environ["NUITKA_EXTRA_OPTIONS"] = extra_options
active = search_mode.consider(dirname=None, filename=filename)
if active:
my_print("Consider output of recursively compiled program:", filename)
filename_main = getMainProgramFilename(filename)
extra_python_path = [
os.path.abspath(os.path.join(filename, entry))
for entry in os.listdir(filename)
if entry.startswith("path")
]
with withPythonPathChange(extra_python_path):
compareWithCPython(
dirname=filename,
filename=filename_main,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/plugins/parameters/ 0000700 0003721 0003721 00000000000 14167275622 025261 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/plugins/parameters/parameter-using-plugin.py 0000600 0003721 0003721 00000004164 14166627112 032233 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Parameter using Nuitka plugin.
"""
import os
import sys
# from nuitka import Options
from nuitka.plugins.PluginBase import NuitkaPluginBase
class NuitkaPluginForTesting(NuitkaPluginBase):
plugin_name = __name__.split(".")[-1]
def __init__(self, trace_my_plugin):
# demo only: extract and display my options list
# check whether some specific option is set
self.check = trace_my_plugin
self.info("The 'trace' value is set to '%s'" % self.check)
# do more init work here ...
@classmethod
def addPluginCommandLineOptions(cls, group):
group.add_option(
"--trace-my-plugin",
action="store_true",
dest="trace_my_plugin",
default=False,
help="This is show in help output."
)
def onModuleSourceCode(self, module_name, source_code):
# if this is the main script and tracing should be done ...
if module_name == "__main__" and self.check:
self.info("")
self.info(" Calls to 'math' module:")
for i, l in enumerate(source_code.splitlines()):
if "math." in l:
self.info(" %i: %s" % (i+1, l))
self.info("")
return source_code
Nuitka-0.6.19.1/tests/plugins/parameters/ParametersMain.py 0000600 0003721 0003721 00000001772 14166627112 030546 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Just something to allow the plugin to look at.
"""
from __future__ import print_function
import math
print(math.pi)
Nuitka-0.6.19.1/tests/optimizations/ 0000700 0003721 0003721 00000000000 14167275622 024346 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/optimizations/Operations.py 0000600 0003721 0003721 00000004303 14166627112 027037 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This test is SPECIAL. Everything in here, MUST be statically optimized,
# and be a print of a constant, or a function that becomes a return value
# that is constant.
print(not bool)
print(not {})
print(not 7)
print(bool or len)
print(False or dict)
print(type(Ellipsis))
print("a" in "abba")
print("a" not in "abba")
print(len("a"*10000))
print(len(10000*"a"))
print(len((1,) *20000))
print(len(20000*(1,)))
print(len([1]*30000))
print(len(30000*[1]))
print(len(unicode("a")*40000))
print(len(40000*unicode("a")))
# For operations, we use function return values of local variables that will
# have to become constant.
def simpleAssignment():
x = 2
return x
def inplaceOperationIncrement():
x = 2
x += 1
return x
def inplaceOperationProduct():
x = 2
x *= 2
return x
def inplaceOperationExponentiate():
x = 2
x **= 2
return x
def inplaceOperationDecrement():
x = 2
x -= 8
return x
# x //= 5
def inplaceOperationFloorDivison():
x = 2
x //= 5
return x
def inplaceOperationModulus():
x = 2
x %= 3
return x
def inplaceOperationAnd():
x = 2
x &= 2
return x
def inplaceOperationOr():
x = 2
x |= 5
return x
def inplaceOperationXor():
x = 2
x ^= 1
return x
def inplaceOperationDivison():
x = 2
x /= 2
return x
Nuitka-0.6.19.1/tests/optimizations/Len.py 0000600 0003721 0003721 00000002333 14166627112 025433 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print(len(range(266)))
print(len(range(266,9999)))
print(len(range(266,9999,3)))
print(len(range(266,9999,-3)))
print(len(range(22266,9999,-3)))
print(len(range(22266,9998,-3)))
print(len(range(22266,9997,-3)))
print(len(range(22266,9996,-3)))
print(len(range(0,3,3)))
print(len([3,3.3]))
print(len((3,3.3)))
Nuitka-0.6.19.1/tests/optimizations/Iterations.py 0000600 0003721 0003721 00000001625 14166627112 027041 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
z = next(iter((3,4)))
Nuitka-0.6.19.1/tests/optimizations/Conditions.py 0000600 0003721 0003721 00000001631 14166627112 027026 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print(1 if [1,2] else 2)
Nuitka-0.6.19.1/tests/optimizations/FormatStrings36.py 0000600 0003721 0003721 00000002272 14166627112 027672 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Format string with local compile time constants fully optimized:
def f():
a = "1"
b = "2"
return f'r:{a!r} and a:{a!a} and s:{a!s}'
print(f())
# Empty f string fully optimized:
def f():
return f''
print(f())
# Text only f string fully optimized:
def f():
return f'some_text'
print(f())
Nuitka-0.6.19.1/tests/optimizations/run_all.py 0000700 0003721 0003721 00000020255 14166627112 026355 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test runners test
This shows that known good existing static optimization works and produces
constant results. This should be used to preserve successful optimization
at compile time against later changes breaking them undetected.
"""
from __future__ import print_function
import os
import sys
# The test runner needs "lxml" itself.
try:
import lxml.etree
except ImportError:
print("Warning, no 'lxml' module installed, cannot do XML based tests.")
sys.exit(0)
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
check_output,
convertUsing2to3,
createSearchMode,
decideFilenameVersionSkip,
my_print,
setup,
)
from nuitka.TreeXML import toString
python_version = setup(suite="optimiations")
search_mode = createSearchMode()
def getKind(node):
result = node.attrib["kind"]
result = result.replace("Statements", "")
result = result.replace("Statement", "")
result = result.replace("Expression", "")
return result
def getRole(node, role):
for child in node:
if child.tag == "role" and child.attrib["name"] == role:
return child
return None
def getSourceRef(filename, node):
return "%s:%s" % (filename, node.attrib["line"])
def isConstantExpression(expression):
kind = getKind(expression)
return kind.startswith("Constant") or kind in (
"ImportModuleHard",
"ImportModuleNameHard",
"ModuleAttributeFileRef",
"ModuleLoaderRef",
)
def checkSequence(filename, statements):
# Complex stuff, pylint: disable=too-many-branches
for statement in statements:
kind = getKind(statement)
# Printing is fine.
if kind == "PrintValue":
(print_arg,) = getRole(statement, "value")
if not isConstantExpression(print_arg):
search_mode.onErrorDetected(
"%s: Error, print of non-constant '%s'."
% (getSourceRef(filename, statement), getKind(print_arg))
)
continue
if kind == "PrintNewline":
continue
# Printing in Python3 is a function call whose return value is ignored.
if kind == "Only":
only_expression = getRole(statement, "expression")[0]
if getKind(only_expression) == "CallNoKeywords":
called_expression = getRole(only_expression, "called")[0]
if getKind(called_expression) == "BuiltinRef":
if called_expression.attrib["builtin_name"] == "print":
continue
if kind == "FrameModule":
checkSequence(filename, getRole(statement, "statements"))
continue
if kind == "FrameFunction":
checkSequence(filename, getRole(statement, "statements"))
continue
if kind == "AssignmentVariable":
variable_name = statement.attrib["variable_name"]
# Ignore "__spec__" assignment for Python3.4, it is not going
# to be static.
if variable_name == "__spec__":
continue
(assign_source,) = getRole(statement, "source")
if getKind(assign_source) == "FunctionCreation":
continue
if not isConstantExpression(assign_source):
search_mode.onErrorDetected(
"Error, assignment from non-constant '%s'." % getKind(assign_source)
)
continue
if kind == "AssignmentAttribute":
(assign_source,) = getRole(statement, "expression")
if getKind(assign_source) == "ModuleAttributeSpecRef":
continue
search_mode.onErrorDetected(
"Error, attribute assignment to '%s'." % getKind(assign_source)
)
if kind in ("ReturnNone", "ReturnConstant"):
continue
print(toString(statement))
search_mode.onErrorDetected(
"Error, non-print statement of unknown kind '%s'." % kind
)
def main():
# Complex stuff, pylint: disable=too-many-branches
for filename in sorted(os.listdir(".")):
if not filename.endswith(".py") or filename.startswith("run_"):
continue
if not decideFilenameVersionSkip(filename):
continue
active = search_mode.consider(dirname=None, filename=filename)
if active:
# Apply 2to3 conversion if necessary.
if python_version >= (3,):
filename, changed = convertUsing2to3(filename)
else:
changed = False
my_print("Consider", filename, end=" ")
command = [
os.environ["PYTHON"],
os.path.abspath(os.path.join("..", "..", "bin", "nuitka")),
"--xml",
"--quiet",
"--module",
filename,
]
if search_mode.isCoverage():
# To avoid re-execution, which is not acceptable to coverage.
if "PYTHONHASHSEED" not in os.environ:
os.environ["PYTHONHASHSEED"] = "0"
# Coverage modules hates Nuitka to re-execute, and so we must avoid
# that.
python_path = check_output(
[
os.environ["PYTHON"],
"-c",
"import sys, os; print(os.pathsep.join(sys.path))",
]
)
if sys.version_info >= (3,):
python_path = python_path.decode("utf8")
os.environ["PYTHONPATH"] = python_path.strip()
command.insert(2, "--must-not-re-execute")
command = (
command[0:1]
+ ["-S", "-m", "coverage", "run", "--rcfile", os.devnull, "-a"]
+ command[1:]
)
result = check_output(command)
# Parse the result into XML and check it.
try:
root = lxml.etree.fromstring(result)
except lxml.etree.XMLSyntaxError:
my_print("Problematic XML output:")
my_print(result)
raise
module_body = root[0]
module_statements_sequence = module_body[0]
assert len(module_statements_sequence) == 1
module_statements = next(iter(module_statements_sequence))
try:
checkSequence(filename, module_statements)
for function in root.xpath('role[@name="functions"]/node'):
(function_body,) = function.xpath('role[@name="body"]')
function_statements_sequence = function_body[0]
assert len(function_statements_sequence) == 1
function_statements = next(iter(function_statements_sequence))
checkSequence(filename, function_statements)
if changed:
os.unlink(filename)
except SystemExit:
my_print("FAIL.")
raise
my_print("OK.")
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/optimizations/HardImports.py 0000600 0003721 0003721 00000002175 14166627112 027155 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import os
def sysAttributes():
return (
sys.version_info,
sys.version_info[0],
sys.version_info.major,
sys.version,
sys.platform,
sys.maxsize,
)
def osAttributes():
return os.name
Nuitka-0.6.19.1/tests/optimizations/Subscripts.py 0000600 0003721 0003721 00000002414 14166627112 027056 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print( (1,2,3)[1] )
print( (1,2,3)[1:] )
print( (1,2,3)[:2] )
print( (1,2,3)[:] )
print( (1,2,3)[1:2] )
print( (1,2,3,4,5,6)[1::2])
print( (1,2,3,4,5,6)[4::-2])
print( (1,2,3,4,5,6)[-1])
print( (1,2,3,4,5,6)[-3:])
print( (1,2,3,4,5,6)[:-1])
print( (1,2,3,4,5,6)[::])
print( (1,2,3,4,5,6)[-3:-1])
print( (1,2,3,4,5,6)[:-1:2])
print( (1,2,3,4,5,6)[-1::-2])
print( (1,2,3,4,5,6)[slice(-1,None,-2)])
Nuitka-0.6.19.1/tests/optimizations/Attributes.py 0000600 0003721 0003721 00000002040 14166627112 027036 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print((1).imag)
print(int.__name__)
print((1).__class__)
print(getattr(1, "real"))
print(getattr(1, "real", None))
print(hasattr(1, "real"))
print((0.0).real)
Nuitka-0.6.19.1/tests/optimizations/HardImports_2.py 0000600 0003721 0003721 00000001715 14166627112 027375 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
def sysOptionalAttribute():
return sys.maxint, sys.subversion
Nuitka-0.6.19.1/tests/optimizations/DecodingOperations.py 0000600 0003721 0003721 00000001615 14166627112 030477 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print(chr(7))
Nuitka-0.6.19.1/tests/optimizations/ArgumentTypes.py 0000600 0003721 0003721 00000001676 14166627112 027535 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f(b, *args, **kwargs):
return type(args), type(kwargs)
Nuitka-0.6.19.1/tests/optimizations/Calls.py 0000600 0003721 0003721 00000001775 14166627112 025764 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Optimization of calls
TODO: This is only a placeholder, currently no real calls will be optimized.
"""
print(range(4))
Nuitka-0.6.19.1/tests/onefile/ 0000700 0003721 0003721 00000000000 14167275622 023056 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/onefile/run_all.py 0000700 0003721 0003721 00000012632 14166627112 025065 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for onefile program tests of Nuitka.
These tests aim at showing that one specific functions work in onefile
mode, trying to find issues with that form of packaging.
"""
import os
import sys
# Find nuitka package relative to us. The replacement is for POSIX python
# and Windows paths on command line.
sys.path.insert(
0,
os.path.normpath(
os.path.join(
os.path.dirname(os.path.abspath(__file__.replace("\\", os.sep))), "..", ".."
)
),
)
# isort:start
from nuitka.freezer.RuntimeTracing import getRuntimeTraceOfLoadedFiles
from nuitka.tools.testing.Common import (
addExtendedExtraOptions,
checkLoadedFileAccesses,
checkRequirements,
compareWithCPython,
createSearchMode,
decideFilenameVersionSkip,
displayFileContents,
displayRuntimeTraces,
reportSkip,
setup,
test_logger,
)
from nuitka.utils.Timing import TimerReport
from nuitka.utils.Utils import getOS
def displayError(dirname, filename):
assert dirname is None
inclusion_log_path = filename[:-3] + ".py.inclusion.log"
displayFileContents("inclusion log", inclusion_log_path)
def main():
python_version = setup(suite="onefile", needs_io_encoding=True)
search_mode = createSearchMode()
if getOS() == "Linux":
addExtendedExtraOptions(
"--linux-onefile-icon=../../doc/Logo/Nuitka-Logo-Symbol.svg"
)
for filename in sorted(os.listdir(".")):
if not filename.endswith(".py"):
continue
if not decideFilenameVersionSkip(filename):
continue
active = search_mode.consider(dirname=None, filename=filename)
if not active:
test_logger.info("Skipping %s" % filename)
continue
extra_flags = [
"expect_success",
"remove_output",
# Keep the binary, normally "remove_output" includes that.
"--keep-binary",
# Cache the CPython results for re-use, they will normally not change.
"cpython_cache",
# To understand what is slow.
"timing",
]
if filename == "KeyboardInteruptTest.py":
if getOS() == "Darwin":
reportSkip(
"Exit code from KeybaordInterrupt on macOS is not yet good.",
".",
filename,
)
continue
if python_version < (3,):
reportSkip(
"Python2 reports KeyboardInterrupt, but too late",
".",
filename,
)
continue
if os.name == "nt":
reportSkip(
"Testing cannot send KeyboardInterrupt on Windows yet",
".",
filename,
)
continue
extra_flags.append("--send-ctrl-c")
# skip each test if their respective requirements are not met
requirements_met, error_message = checkRequirements(filename)
if not requirements_met:
reportSkip(error_message, ".", filename)
continue
test_logger.info(
"Consider output of onefile mode compiled program: %s" % filename
)
# First compare so we know the program behaves identical.
compareWithCPython(
dirname=None,
filename=filename,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
on_error=displayError,
)
binary_filename = filename[:-3] + (".exe" if os.name == "nt" else ".bin")
if filename == "KeyboardInteruptTest.py":
continue
# Then use "strace" on the result.
with TimerReport(
"Determining run time loaded files took %.2f", logger=test_logger
):
loaded_filenames = getRuntimeTraceOfLoadedFiles(
logger=test_logger, command=[binary_filename]
)
illegal_accesses = checkLoadedFileAccesses(
loaded_filenames=loaded_filenames, current_dir=os.getcwd()
)
if illegal_accesses:
displayError(None, filename)
displayRuntimeTraces(test_logger, binary_filename)
test_logger.warning(
"Should not access these file(s): '%s'." % ",".join(illegal_accesses)
)
search_mode.onErrorDetected(1)
os.unlink(binary_filename)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/onefile/KeyboardInteruptTest.py 0000600 0003721 0003721 00000002417 14166627112 027563 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" In this test, we get killed after some time has passed, and want to see the KeyboardInterrupt exit.
"""
# nuitka-project: --onefile
import sys
import time
print("Hello world, will you kill me?")
print(sys.version_info)
try:
time.sleep(10)
except KeyboardInterrupt:
print("Received KeyboardInterrupt.")
sys.exit(0)
else:
print("Received no KeyboardInterrupt.")
sys.exit(1)
Nuitka-0.6.19.1/tests/onefile/HelloWorldTest.py 0000600 0003721 0003721 00000001740 14166627112 026341 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
# nuitka-project: --onefile
print("Hello Onefile World!") Nuitka-0.6.19.1/tests/standalone/ 0000700 0003721 0003721 00000000000 14167275622 023565 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/standalone/PyQt5SSLSupport.py 0000600 0003721 0003721 00000002011 14166627112 027066 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from PyQt5.QtNetwork import QSslSocket
# nuitka-skip-unless-imports: PyQt5.QtGui
print("SSL support: %r" % (QSslSocket.supportsSsl(),))
Nuitka-0.6.19.1/tests/standalone/Win32ComUsing.py 0000600 0003721 0003721 00000002260 14166627112 026502 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that uses win32com superficially.
Please help make it more useful, ideally by adding something
that would work on every machine.
"""
# nuitka-project: --standalone
from win32com import storagecon
from win32com.shell import shell, shellcon
# nuitka-skip-unless-imports: win32com
print("OK.")
Nuitka-0.6.19.1/tests/standalone/IdnaUsing.py 0000600 0003721 0003721 00000002036 14166627112 026015 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
import idna.core
# nuitka-skip-unless-imports: idna.core
print(idna.core, "idna.idnadata" in sys.modules)
Nuitka-0.6.19.1/tests/standalone/BrotliUsing.py 0000600 0003721 0003721 00000002041 14166627112 026371 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import brotli
# nuitka-skip-unless-imports: brotli
print("Compressed data:", brotli.compress(b"README.txt"))
print("OK.") Nuitka-0.6.19.1/tests/standalone/PyQt5Using.py 0000600 0003721 0003721 00000003716 14166627112 026132 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtCore import QSettings
from PyQt5.QtCore import QMetaObject, QObject, pyqtSignal, pyqtSlot
# This test is playing with configuration settings and checking that works.
# nuitka-skip-unless-imports: PyQt5.QtGui
app = QCoreApplication([])
app.setOrganizationName("BOGUS_NAME")
app.setOrganizationDomain("bogosity.com")
app.setApplicationName("BOGUS")
print("OK.")
# This test is using signals and will only work if PySide properly accepts
# compiled functions as callables.
class Communicate(QObject):
speak = pyqtSignal(int)
def __init__(self, name="", parent=None):
QObject.__init__(self, parent)
self.setObjectName(name)
class Speaker(QObject):
@pyqtSlot(int)
def on_communicator_speak(self, stuff):
print(stuff)
speaker = Speaker()
someone = Communicate(name="communicator", parent=speaker)
QMetaObject.connectSlotsByName(speaker)
print("The answer is:", end="")
# emit 'speak' signal
someone.speak.emit(42)
print("Slot should have made output by now.")
Nuitka-0.6.19.1/tests/standalone/CtypesUsing.py 0000600 0003721 0003721 00000004724 14166627112 026417 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# nuitka-project: --standalone
import ctypes
import os
if os.name == "nt":
# adapted from http://code.activestate.com/recipes/578513
from ctypes import wintypes
# Lets allow this to match Windows API it reflects,
# pylint: disable=invalid-name
class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
_fields_ = [
("cb", wintypes.DWORD),
("PageFaultCount", wintypes.DWORD),
("PeakWorkingSetSize", ctypes.c_size_t),
("WorkingSetSize", ctypes.c_size_t),
("QuotaPeakPagedPoolUsage", ctypes.c_size_t),
("QuotaPagedPoolUsage", ctypes.c_size_t),
("QuotaPeakNonPagedPoolUsage", ctypes.c_size_t),
("QuotaNonPagedPoolUsage", ctypes.c_size_t),
("PagefileUsage", ctypes.c_size_t),
("PeakPagefileUsage", ctypes.c_size_t),
("PrivateUsage", ctypes.c_size_t),
]
GetProcessMemoryInfo = ctypes.windll.psapi.GetProcessMemoryInfo
GetProcessMemoryInfo.argtypes = [
wintypes.HANDLE,
ctypes.POINTER(PROCESS_MEMORY_COUNTERS_EX),
wintypes.DWORD,
]
GetProcessMemoryInfo.restype = wintypes.BOOL
counters = PROCESS_MEMORY_COUNTERS_EX()
rv = GetProcessMemoryInfo(
ctypes.windll.kernel32.GetCurrentProcess(),
ctypes.byref(counters),
ctypes.sizeof(counters),
)
if not rv:
raise ctypes.WinError()
print("OK.")
else:
# TODO: How to get this to work.
if False:
libc = ctypes.CDLL("libc")
printf = libc.printf
printf("Hello, %s\n", "World!")
print("OK.")
Nuitka-0.6.19.1/tests/standalone/run_all.py 0000700 0003721 0003721 00000023671 14166627112 025601 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for standalone program tests of Nuitka.
These tests aim at showing that one specific module works in standalone
mode, trying to find issues with that packaging.
"""
import os
import sys
# Find nuitka package relative to us. The replacement is for POSIX python
# and Windows paths on command line.
sys.path.insert(
0,
os.path.normpath(
os.path.join(
os.path.dirname(os.path.abspath(__file__.replace("\\", os.sep))), "..", ".."
)
),
)
# isort:start
from nuitka.freezer.RuntimeTracing import getRuntimeTraceOfLoadedFiles
from nuitka.tools.testing.Common import (
checkLoadedFileAccesses,
checkRequirements,
compareWithCPython,
createSearchMode,
decideFilenameVersionSkip,
displayFileContents,
displayFolderContents,
displayRuntimeTraces,
reportSkip,
setup,
test_logger,
)
from nuitka.utils.FileOperations import removeDirectory
from nuitka.utils.Timing import TimerReport
from nuitka.utils.Utils import getOS
def displayError(dirname, filename):
assert dirname is None
dist_path = filename[:-3] + ".dist"
displayFolderContents("dist folder", dist_path)
inclusion_log_path = filename[:-3] + ".py.inclusion.log"
displayFileContents("inclusion log", inclusion_log_path)
def main():
# Complex stuff, even more should become common code or project options though.
# pylint: disable=too-many-branches,too-many-statements
python_version = setup(suite="standalone", needs_io_encoding=True)
search_mode = createSearchMode()
for filename in sorted(os.listdir(".")):
if not filename.endswith(".py"):
continue
if not decideFilenameVersionSkip(filename):
continue
active = search_mode.consider(dirname=None, filename=filename)
if not active:
test_logger.info("Skipping %s" % filename)
continue
extra_flags = [
"expect_success",
"--standalone",
"remove_output",
# Cache the CPython results for re-use, they will normally not change.
"cpython_cache",
# To understand what is slow.
"timing",
]
# skip each test if their respective requirements are not met
requirements_met, error_message = checkRequirements(filename)
if not requirements_met:
reportSkip(error_message, ".", filename)
continue
if filename == "Urllib3Using.py" and os.name == "nt":
reportSkip(
"Socket module early import not working on Windows currently",
".",
filename,
)
continue
if "Idna" in filename:
# For the warnings of Python2.
if python_version < (3,):
extra_flags.append("ignore_stderr")
if filename == "CtypesUsing.py":
extra_flags.append("plugin_disable:pylint-warnings")
if filename == "GtkUsing.py":
# Don't test on platforms not supported by current Debian testing, and
# which should be considered irrelevant by now.
if python_version < (2, 7):
reportSkip("irrelevant Python version", ".", filename)
continue
# For the warnings.
extra_flags.append("ignore_warnings")
if filename.startswith("Win"):
if os.name != "nt":
reportSkip("Windows only test", ".", filename)
continue
if filename == "TkInterUsing.py":
if getOS() == "Darwin":
reportSkip("Not working macOS yet", ".", filename)
continue
if getOS() == "Windows":
reportSkip("Can hang on Windows CI.", ".", filename)
continue
# For the plug-in information.
extra_flags.append("plugin_enable:tk-inter")
if filename == "FlaskUsing.py":
# For the warnings.
extra_flags.append("ignore_warnings")
# TODO: Once we have a noqt Plugin, we should use that.
if filename == "MatplotlibUsing.py":
# For the plugin warnings.
extra_flags.append("ignore_warnings")
if filename == "NumpyUsing.py":
# TODO: Disabled for now.
reportSkip("numpy.test not fully working yet", ".", filename)
continue
if filename == "PandasUsing.py":
extra_flags.append("plugin_enable:numpy")
extra_flags.append("plugin_disable:pylint-warnings")
extra_flags.append("plugin_disable:pyqt5")
extra_flags.append("plugin_disable:pyside2")
extra_flags.append("plugin_disable:pyside6")
if filename == "PmwUsing.py":
extra_flags.append("plugin_enable:pmw-freezer")
if filename == "OpenGLUsing.py":
# For the warnings.
extra_flags.append("ignore_warnings")
if filename == "GlfwUsing.py":
# For the warnings.
extra_flags.append("plugin_enable:numpy")
if filename == "PasslibUsing.py":
# For the warnings.
extra_flags.append("ignore_warnings")
if filename == "Win32ComUsing.py":
# For the warnings.
extra_flags.append("ignore_warnings")
if filename.startswith(("PySide2", "PySide6", "PyQt5", "PyQt6")):
# Don't test on platforms not supported by current Debian testing, and
# which should be considered irrelevant by now.
if python_version < (2, 7) or ((3,) <= python_version < (3, 7)):
reportSkip("irrelevant Python version", ".", filename)
continue
# For the plug-in information
if filename.startswith("PySide2"):
extra_flags.append("plugin_enable:pyside6")
elif filename.startswith("PySide6"):
extra_flags.append("plugin_enable:pyside6")
elif filename.startswith("PyQt5"):
extra_flags.append("plugin_enable:pyqt5")
elif filename.startswith("PyQt6"):
extra_flags.append("plugin_enable:pyqt6")
test_logger.info(
"Consider output of standalone mode compiled program: %s" % filename
)
# First compare so we know the program behaves identical.
compareWithCPython(
dirname=None,
filename=filename,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
on_error=displayError,
)
# Second check if glibc libraries haven't been accidentally
# shipped with the standalone executable
found_glibc_libs = []
for dist_filename in os.listdir(os.path.join(filename[:-3] + ".dist")):
if os.path.basename(dist_filename).startswith(
(
"ld-linux-x86-64.so",
"libc.so.",
"libpthread.so.",
"libm.so.",
"libdl.so.",
"libBrokenLocale.so.",
"libSegFault.so",
"libanl.so.",
"libcidn.so.",
"libcrypt.so.",
"libmemusage.so",
"libmvec.so.",
"libnsl.so.",
"libnss_compat.so.",
"libnss_db.so.",
"libnss_dns.so.",
"libnss_files.so.",
"libnss_hesiod.so.",
"libnss_nis.so.",
"libnss_nisplus.so.",
"libpcprofile.so",
"libresolv.so.",
"librt.so.",
"libthread_db-1.0.so",
"libthread_db.so.",
"libutil.so.",
)
):
found_glibc_libs.append(dist_filename)
if found_glibc_libs:
test_logger.warning(
"Should not ship glibc libraries with the standalone executable (found %s)"
% found_glibc_libs
)
sys.exit(1)
binary_filename = os.path.join(
filename[:-3] + ".dist", filename[:-3] + (".exe" if os.name == "nt" else "")
)
# Then use "strace" on the result.
with TimerReport(
"Determining run time loaded files took %.2f", logger=test_logger
):
loaded_filenames = getRuntimeTraceOfLoadedFiles(
logger=test_logger, command=[binary_filename]
)
illegal_accesses = checkLoadedFileAccesses(
loaded_filenames=loaded_filenames, current_dir=os.getcwd()
)
if illegal_accesses:
displayError(None, filename)
displayRuntimeTraces(test_logger, binary_filename)
test_logger.warning(
"Should not access these file(s): '%r'." % illegal_accesses
)
search_mode.onErrorDetected(1)
removeDirectory(filename[:-3] + ".dist", ignore_errors=True)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/standalone/ShlibUsing.py 0000600 0003721 0003721 00000001716 14166627112 026207 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# nuitka-skip-unless-imports: pyexpat
import pyexpat
print(pyexpat.__doc__)
Nuitka-0.6.19.1/tests/standalone/PendulumUsing.py 0000600 0003721 0003721 00000002157 14166627112 026737 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Pendulum standalone basic test.
When this import works, locales are there.
"""
# nuitka-project: --standalone
from __future__ import print_function
import pendulum.locales
# nuitka-skip-unless-imports: pendulum.locales
print("OK") Nuitka-0.6.19.1/tests/standalone/LxmlUsing.py 0000600 0003721 0003721 00000002177 14166627112 026064 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Lxml standalone basic test.
"""
from __future__ import print_function
import lxml.etree
# nuitka-skip-unless-imports: lxml.etree
tree = lxml.etree.fromstring("value")
assert tree.tag == "root"
assert tree.text == "value"
print("OK")
Nuitka-0.6.19.1/tests/standalone/FlaskUsing.py 0000600 0003721 0003721 00000002160 14166627112 026200 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from flask import Flask
# nuitka-skip-unless-imports: flask
app = Flask(__name__)
@app.route("/")
def main():
return "Welcome!"
if __name__ == "__main__":
pass
# TODO: Find something other meaningful to do.
# app.run()
Nuitka-0.6.19.1/tests/standalone/zip_importer/ 0000700 0003721 0003721 00000000000 14167275622 026310 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/standalone/zip_importer/ZipImporterMain.py 0000600 0003721 0003721 00000002254 14166627112 031752 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# nuitka-project: --standalone
# nuitka-project: --include-data-file={MAIN_DIRECTORY}/for_import.zip=for_import.zip
import sys, os
zip_filename = os.path.join(os.path.dirname(__file__) or ".", "for_import.zip")
assert os.path.exists(zip_filename)
sys.path.insert(0, zip_filename)
import zip_module
Nuitka-0.6.19.1/tests/standalone/PandasUsing.py 0000600 0003721 0003721 00000001774 14166627112 026360 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Low coverage Pandas importing test. """
import pandas as pd
# nuitka-skip-unless-imports: pandas
print(pd.__version__) Nuitka-0.6.19.1/tests/standalone/TkInterUsing.py 0000600 0003721 0003721 00000002747 14166627112 026533 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" TkInter standalone test, trying to make sure it loads.
"""
# nuitka-project: --standalone
# nuitka-project: --enable-plugin=tk-inter
from __future__ import print_function
# Python3 changed module name.
if str is bytes:
import Tkinter as tkinter
else:
import tkinter
# nuitka-skip-unless-expression: __import__("Tkinter" if sys.version_info[0] < 3 else "tkinter")
try:
root = tkinter.Tk() # this will fail in absence of TCL
except tkinter.TclError as e:
print("TCLError exception happened.")
assert "connect to display" in str(e) or "no display" in str(e), str(e)
else:
print("OK")
Nuitka-0.6.19.1/tests/standalone/Urllib3Using.py 0000600 0003721 0003721 00000006170 14166627112 026461 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
# testing JSON content
import json
import os
# test ssl
import socket
import ssl
from threading import Thread
import urllib3
# nuitka-skip-unless-imports: urllib3,ssl
if str is bytes:
# running on python2, pylint: disable=import-error,I0021
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
#running on python3
else:
from http.server import HTTPServer, BaseHTTPRequestHandler
started = False
def runHTTPServer():
class myServer(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == "/":
self.path = "/index.html"
try:
file_to_open = open(self.path[1:], "rb").read()
self.send_response(200)
self.end_headers()
self.wfile.write(file_to_open)
except IOError:
self.send_response(404)
self.end_headers()
# No logging due to races.
def log_request(self, code):
pass
global port
global server
for port in range(8020, 9000):
server_address = ("127.0.0.1", port)
try:
server = HTTPServer(server_address, myServer)
except OSError:
continue
else:
break
global started
started = True
server.serve_forever()
Thread(target=runHTTPServer).start()
while not started:
pass
print("Server started.")
# testing request
http = urllib3.PoolManager()
r = http.request("GET", "http://localhost:%d/" % port)
# print response
print(r.status, r.data)
# make a temporary test file
with open("testjson.json", "w") as f:
f.write('{"origin": "some, value"}')
r = http.request("GET", "http://localhost:%d/testjson.json" % port)
data = json.loads(r.data.decode("utf-8"))
if "Date" in data:
del data["Date"]
print("DATA:", data)
os.remove("testjson.json")
server.shutdown()
print("Server shutdown")
# TODO: Testing via network is not allowed, but SSL on localhost
# is not easy.
if False:
hostname = "www.google.com"
context = ssl.create_default_context()
with socket.create_connection((hostname, 443)) as sock:
with context.wrap_socket(sock, server_hostname=hostname) as ssock:
print(ssock.version())
print("OK.")
Nuitka-0.6.19.1/tests/standalone/GtkUsing.py 0000600 0003721 0003721 00000002161 14166627112 025666 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" pygtk standalone basic test.
"""
from __future__ import print_function
import warnings
warnings.filterwarnings("ignore", "")
import sys
import gtk
import pygtk
# nuitka-skip-unless-imports: pygtk
pygtk.require("2.0")
print("OK")
Nuitka-0.6.19.1/tests/standalone/PyQt5Plugins.py 0000600 0003721 0003721 00000001765 14166627112 026470 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from PyQt5 import QtGui
# nuitka-skip-unless-imports: PyQt5.QtGui
print(QtGui.QImageReader.supportedImageFormats())
Nuitka-0.6.19.1/tests/standalone/MatplotlibUsing.py 0000600 0003721 0003721 00000002633 14166627112 027254 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test using matplotlib, should actually do something with it. """
import matplotlib # pylint:disable=unused-import
# nuitka-skip-unless-imports: matplotlib
# nuitka-project: --standalone
# Make sure, the usual bad ones are not included with anti-bloat.
# nuitka-project: --enable-plugin=anti-bloat
# nuitka-project: --noinclude-setuptools-mode=error
# nuitka-project: --noinclude-pytest-mode=error
# nuitka-project: --noinclude-custom-mode=numpy.distutils:error
# nuitka-project: --noinclude-custom-mode=IPython:error
print("OK.") Nuitka-0.6.19.1/tests/standalone/NumpyUsing.py 0000600 0003721 0003721 00000002577 14166627112 026264 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
# nuitka-skip-unless-imports: numpy
# nuitka-project: --standalone
# nuitka-project: --enable-plugin=numpy
# Make sure, the usual bad ones are not included with anti-bloat.
# nuitka-project: --enable-plugin=anti-bloat
# nuitka-project: --noinclude-setuptools-mode=error
# nuitka-project: --noinclude-pytest-mode=error
# nuitka-project: --noinclude-custom-mode=numpy.distutils:error
import numpy as np
a = np.arange(15).reshape(3, 5)
print("An array", a)
print("OK.") Nuitka-0.6.19.1/tests/standalone/OpenGLUsing.py 0000600 0003721 0003721 00000001663 14166627112 026273 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import OpenGL
# nuitka-skip-unless-imports: OpenGL
Nuitka-0.6.19.1/tests/standalone/PySide6Using.py 0000600 0003721 0003721 00000003217 14166627112 026427 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This test is using signals and will only work if PySide properly accepts
# compiled functions as callables.
from __future__ import print_function
from PySide6.QtCore import QMetaObject, QObject, Signal, Slot
# nuitka-skip-unless-imports: PySide6.QtCore
class Communicate(QObject):
speak = Signal(int)
def __init__(self, name="", parent=None):
QObject.__init__(self, parent)
self.setObjectName(name)
class Speaker(QObject):
@Slot(int)
def on_communicator_speak(self, stuff):
print(stuff)
speaker = Speaker()
someone = Communicate(name="communicator", parent=speaker)
QMetaObject.connectSlotsByName(speaker)
print("The answer is:", end="")
# emit 'speak' signal
someone.speak.emit(42)
print("Slot should have made output by now.")
Nuitka-0.6.19.1/tests/standalone/PasslibUsing.py 0000600 0003721 0003721 00000002052 14166627112 026535 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from passlib.hash import sha512_crypt as sha512
# nuitka-skip-unless-imports: passlib
print("hello")
print(len(sha512.using(rounds=1000).hash("password")))
print("bye")
Nuitka-0.6.19.1/tests/standalone/GlfwUsing.py 0000600 0003721 0003721 00000001656 14166627112 026050 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import glfw
# nuitka-skip-unless-imports: glfw Nuitka-0.6.19.1/tests/standalone/RsaUsing.py 0000600 0003721 0003721 00000002453 14166627112 025672 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import rsa
# nuitka-skip-unless-imports: rsa
(tambe_pub, tambe_priv) = rsa.newkeys(512)
message = "beautiful Tambe!".encode("utf8")
encrypted_msg = rsa.encrypt(message, tambe_pub)
message = rsa.decrypt(encrypted_msg, tambe_priv)
def encryption_decryption():
"""Function to test encryption and decryption"""
assert message.decode("utf8") == "beautiful Tambe!"
if __name__ == "__main__":
encryption_decryption()
Nuitka-0.6.19.1/tests/standalone/SocketUsing.py 0000600 0003721 0003721 00000002736 14166627112 026401 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright 2021, Paweł Kierzkowski, mailto:
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that shows that the socket module can properly be used.
"""
import signal
import socket
import sys
# Set up a timeout, seems to happen that below call stalls.
def onTimeout(_signum, _frame):
sys.exit(0)
# Not available on Windows, but there we didn't see the problem anyway,
# not going to make this use threading for now.
try:
signal.signal(signal.SIGALRM, onTimeout)
signal.alarm(1)
except AttributeError:
pass
# Call to socket.getfqdn with a non-local address will cause libresolv.so glibc
# library to be loaded
socket.getfqdn("1.1.1.1")
Nuitka-0.6.19.1/tests/standalone/PmwUsing.py 0000600 0003721 0003721 00000002033 14166627112 025702 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import Pmw
# nuitka-skip-unless-expression: __import__("Tkinter" if sys.version_info[0] < 3 else "tkinter")
# nuitka-skip-unless-imports: Pmw
print("OK.") Nuitka-0.6.19.1/tests/standalone/Issue116_2.py 0000600 0003721 0003721 00000001635 14166627112 025701 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Software where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("4B4159".decode("hex"))
Nuitka-0.6.19.1/tests/programs/ 0000700 0003721 0003721 00000000000 14167275622 023267 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/ 0000700 0003721 0003721 00000000000 14167275622 027362 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/ 0000700 0003721 0003721 00000000000 14167275622 032000 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package1/ 0000700 0003721 0003721 00000000000 14167275622 034325 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package1/SomeModuleC.py 0000600 0003721 0003721 00000001401 14166627112 037043 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package1/SomeModuleD.py 0000600 0003721 0003721 00000001401 14166627112 037044 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package1/__init__.py 0000600 0003721 0003721 00000001401 14166627112 036426 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package2/ 0000700 0003721 0003721 00000000000 14167275622 034326 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package2/SomeModuleB.py 0000600 0003721 0003721 00000001401 14166627112 037043 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package2/SomeModuleA.py 0000600 0003721 0003721 00000001401 14166627112 037042 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/sub_package2/__init__.py 0000600 0003721 0003721 00000001401 14166627112 036427 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/some_package/__init__.py 0000600 0003721 0003721 00000001401 14166627112 034101 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/pkgutil_itermodules/PkgUtilIterModulesMain.py 0000600 0003721 0003721 00000002550 14166627112 034273 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import pkgutil
import some_package.sub_package1.SomeModuleC
import some_package.sub_package1.SomeModuleD
import some_package.sub_package2.SomeModuleA
import some_package.sub_package2.SomeModuleB
print("Checking with 'pkg_util.iter_modules' what was included:")
pkg = __import__("some_package")
print("Package is", pkg)
it = pkgutil.iter_modules(pkg.__path__)
for r in it:
print(r[1], r[2])
if r[2]:
sub_pkg = __import__("some_package." + r[1])
for r2 in pkgutil.iter_modules(sub_pkg.__path__):
print(" ", r2[1], r2[2])
print("Done")
Nuitka-0.6.19.1/tests/programs/stdlib_overload/ 0000700 0003721 0003721 00000000000 14167275622 026443 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/stdlib_overload/StdlibOverloadMain.py 0000600 0003721 0003721 00000002166 14166627112 032540 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Main importing nearby package")
import pyexpat
from some_package import normal_importing, star_importing
try:
print(pyexpat.defined_in_pyexpat)
except AttributeError:
print("Must be Python3, where absolute imports are default.")
print("Main importing from package doing star import")
print("Main importing from package doing normal import")
print("Done.")
Nuitka-0.6.19.1/tests/programs/stdlib_overload/pyexpat.py 0000600 0003721 0003721 00000001437 14166627112 030510 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
defined_in_pyexpat = "see me"
Nuitka-0.6.19.1/tests/programs/stdlib_overload/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031061 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/stdlib_overload/some_package/star_importing.py 0000600 0003721 0003721 00000002254 14166627112 034473 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Make a star import, and demonstrate that it has impact on the modules dict.
"""
from __future__ import print_function
from .pyexpat import * # pylint: disable=unused-wildcard-import,wildcard-import
print("some_package.star_importing, doing the star import")
print("Before", sorted(x for x in dir() if x != "__compiled__"))
lala = 1
print("After", sorted(x for x in dir() if x != "__compiled__"))
print("Finished")
Nuitka-0.6.19.1/tests/programs/stdlib_overload/some_package/pyexpat.py 0000600 0003721 0003721 00000001452 14166627112 033123 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
defined_in_pyexpat_subpackage = "see me"
Nuitka-0.6.19.1/tests/programs/stdlib_overload/some_package/normal_importing.py 0000600 0003721 0003721 00000001571 14166627112 035013 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pyexpat
print("Imported pyexpat, should use our one.")
print([x for x in dir(pyexpat) if x != "__compiled__"])
Nuitka-0.6.19.1/tests/programs/stdlib_overload/some_package/__init__.py 0000600 0003721 0003721 00000001401 14166627112 033162 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/named_imports/ 0000700 0003721 0003721 00000000000 14167275622 026130 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/named_imports/NamedImportsMain.py 0000600 0003721 0003721 00000001516 14166627112 031710 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from some_package import SomeModule
print(__name__, "imported", SomeModule)
Nuitka-0.6.19.1/tests/programs/named_imports/some_package/ 0000700 0003721 0003721 00000000000 14167275622 030546 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/named_imports/some_package/sub_package/ 0000700 0003721 0003721 00000000000 14167275622 033012 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/named_imports/some_package/sub_package/SomeModule.py 0000600 0003721 0003721 00000001401 14166627112 035425 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/named_imports/some_package/SomeModule.py 0000600 0003721 0003721 00000001401 14166627112 033161 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/named_imports/some_package/__init__.py 0000600 0003721 0003721 00000001470 14166627112 032655 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .sub_package import SomeModule
print(SomeModule)
Nuitka-0.6.19.1/tests/programs/dunderinit_imports/ 0000700 0003721 0003721 00000000000 14167275622 027211 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/dunderinit_imports/package/ 0000700 0003721 0003721 00000000000 14167275622 030604 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/dunderinit_imports/package/SubModule.py 0000600 0003721 0003721 00000001435 14166627112 033054 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .__init__ import value
Nuitka-0.6.19.1/tests/programs/dunderinit_imports/package/__init__.py 0000600 0003721 0003721 00000001531 14166627112 032711 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("Package as __name__", __name__)
value = 1
Nuitka-0.6.19.1/tests/programs/dunderinit_imports/DunderInitImportsMain.py 0000600 0003721 0003721 00000001432 14166627112 034007 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import package.SubModule
Nuitka-0.6.19.1/tests/programs/case_imports1/ 0000700 0003721 0003721 00000000000 14167275622 026040 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports1/path1/ 0000700 0003721 0003721 00000000000 14167275622 027055 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports1/path1/Some_Package/ 0000700 0003721 0003721 00000000000 14167275622 031373 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports1/path1/Some_Package/__init__.py 0000600 0003721 0003721 00000001437 14166627112 033505 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Package")
Nuitka-0.6.19.1/tests/programs/case_imports1/path1/Some_Module.py 0000600 0003721 0003721 00000001436 14166627112 031637 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Module")
Nuitka-0.6.19.1/tests/programs/case_imports1/CasedImportingMain.py 0000600 0003721 0003721 00000001450 14166627112 032123 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import Some_Module
import some_package
Nuitka-0.6.19.1/tests/programs/case_imports1/path2/ 0000700 0003721 0003721 00000000000 14167275622 027056 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports1/path2/some_module.py 0000600 0003721 0003721 00000001436 14166627112 031740 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is some_module")
Nuitka-0.6.19.1/tests/programs/case_imports1/path2/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031474 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports1/path2/some_package/__init__.py 0000600 0003721 0003721 00000001437 14166627112 033606 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is some_package")
Nuitka-0.6.19.1/tests/programs/main_raises2/ 0000700 0003721 0003721 00000000000 14167275622 025643 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/main_raises2/ErrorRaising.py 0000600 0003721 0003721 00000001450 14166627112 030617 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def raiseException():
return 1 / 0
Nuitka-0.6.19.1/tests/programs/main_raises2/ErrorInFunctionMain.py 0000600 0003721 0003721 00000002070 14166627112 032103 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Just plain exception from the function level, supposed to report the correct file and line
def generator_function():
import ErrorRaising
x = (lambda: ErrorRaising.raiseException() for z in range(3))
next(x)()
def normal_function():
y = generator_function()
y()
normal_function()
Nuitka-0.6.19.1/tests/programs/package_init_import/ 0000700 0003721 0003721 00000000000 14167275622 027277 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_init_import/PackageInitImportMain.py 0000600 0003721 0003721 00000001467 14166627112 034034 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import some_package
print(some_package.PackageLocal)
Nuitka-0.6.19.1/tests/programs/package_init_import/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031715 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_init_import/some_package/PackageLocal.py 0000600 0003721 0003721 00000001760 14166627112 034575 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
print(
"Imported PackageLocal",
__name__,
"in",
__package__
if __package__ is not None or sys.version_info[:2] != (3, 2)
else ".".join(__name__.split(".")[:-1]),
)
Nuitka-0.6.19.1/tests/programs/package_init_import/some_package/__init__.py 0000600 0003721 0003721 00000002221 14166627112 034017 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
print(
"This is some_package",
__name__,
"in",
"__package__: ",
__package__
if __package__ is not None or sys.version_info[:2] != (3, 2)
else ".".join(__name__.split(".")[:-1]),
)
try:
import PackageLocal
except ImportError:
print("This must be Python3, doing local import then.")
from . import PackageLocal
Nuitka-0.6.19.1/tests/programs/reimport_main_static/ 0000700 0003721 0003721 00000000000 14167275622 027503 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/reimport_main_static/ImportItselfStaticMain.py 0000600 0003721 0003721 00000001602 14166627112 034446 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import ImportItselfStaticMain
print("Here I am before import", __name__)
print("Here I am after import", __name__)
Nuitka-0.6.19.1/tests/programs/multiprocessing_using/ 0000700 0003721 0003721 00000000000 14167275622 027723 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/multiprocessing_using/MultiprocessingUsingMain.py 0000600 0003721 0003721 00000002231 14166627112 035271 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that checks that accelerated mode usage of multiprocessing works too. """
# nuitka-project-if: {OS} == "Windows":
# nuitka-project: --enable-plugin=multiprocessing
# nuitka-project-if: {OS} != "Windows":
# nuitka-project: --disable-plugin=multiprocessing
from multiprocessing import freeze_support
if __name__ == "__main__":
freeze_support()
from foo import entry
entry.main()
Nuitka-0.6.19.1/tests/programs/multiprocessing_using/foo/ 0000700 0003721 0003721 00000000000 14167275622 030506 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/multiprocessing_using/foo/__main__.py 0000600 0003721 0003721 00000001504 14166627112 032574 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from foo import entry
if __name__ == "__main__":
entry.main()
Nuitka-0.6.19.1/tests/programs/multiprocessing_using/foo/entry.py 0000600 0003721 0003721 00000003336 14166627112 032222 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from multiprocessing import Pipe, Process
class MyProcess(Process):
def __init__(self, connection):
super(MyProcess, self).__init__()
self.connection = connection
self.close_issued = False
def run(self):
while not self.close_issued:
op, arg = self.connection.recv()
if op == "add":
self.connection.send(arg + 1)
elif op == "close":
self.close_issued = True
elif op == "method":
self.connection.send(repr(self.run))
def main():
server_channel, client_channel = Pipe()
my_process = MyProcess(client_channel)
my_process.start()
server_channel.send(("add", 4))
print(server_channel.recv())
server_channel.send(("add", 12))
print(server_channel.recv())
server_channel.send(("method", None))
print(("compiled" in server_channel.recv()) == ("compiled" in repr(MyProcess.run)))
server_channel.send(("close", 0))
Nuitka-0.6.19.1/tests/programs/multiprocessing_using/foo/__init__.py 0000600 0003721 0003721 00000001401 14166627112 032607 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/reimport_main_dynamic/ 0000700 0003721 0003721 00000000000 14167275622 027640 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/reimport_main_dynamic/ImportItselfDynamicMain.py 0000600 0003721 0003721 00000001617 14166627112 034746 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
print("Here I am before import", __name__)
c = "ImportItselfDynamicMain"
__import__(c)
print("Here I am after import", __name__)
Nuitka-0.6.19.1/tests/programs/run_all.py 0000700 0003721 0003721 00000015246 14167275603 025307 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for program tests of Nuitka.
Program tests are typically aiming at checking specific module constellations
and making sure the details are being right there. These are synthetic small
programs, each of which try to demonstrate one or more points or special
behaviour.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
compareWithCPython,
createSearchMode,
my_print,
reportSkip,
scanDirectoryForTestCaseFolders,
setup,
withPythonPathChange,
)
def main():
# Complex stuff, even more should become common code though.
# pylint: disable=too-many-branches,too-many-statements
python_version = setup(suite="programs", needs_io_encoding=True)
search_mode = createSearchMode()
extra_options = os.environ.get("NUITKA_EXTRA_OPTIONS", "")
for filename, filename_main in scanDirectoryForTestCaseFolders("."):
# For these, we expect that they will fail.
expected_errors = [
"module_exits",
"main_raises",
"main_raises2",
"package_contains_main",
]
# After Python3 those have been made to work.
if python_version < (3, 5):
expected_errors.append("cyclic_imports")
# Allowed with Python3, packages need no more "__init__.py"
if python_version < (3,):
expected_errors.append("package_missing_init")
# Allowed with Python3.5 only:
if python_version < (3, 5):
expected_errors.append("package_init_issue")
# Allowed with Python3, name imports can be module imports
if python_version < (3,):
expected_errors.append("named_imports")
extra_variant = []
if filename not in expected_errors:
extra_flags = ["expect_success"]
else:
extra_flags = ["expect_failure"]
# We annotate some tests, use that to lower warnings.
extra_flags.append("plugin_enable:pylint-warnings")
if filename in (
"reimport_main_static",
"package_missing_init",
"dash_import",
"package_contains_main",
"case_imports3",
"import_variants",
"package_init_import",
"pkgutil_itermodules",
):
extra_flags.append("ignore_warnings")
extra_flags.append("remove_output")
extra_flags.append("--follow-imports")
# Use the original __file__ value, at least one case warns about things
# with filename included, but for pkgutil iteration, make sure we do not
# see original Python dirs.
if filename != "pkgutil_itermodules":
extra_flags.append("--file-reference-choice=original")
else:
extra_flags.append("--file-reference-choice=runtime")
# Run it as a package and also as directory.
if filename == "package_program":
# Not really supported for 2.6
if python_version >= (2, 7):
extra_variant.append("--python-flag=-m")
# Cannot include the files with syntax errors, these would then become
# ImportError, but that's not the test. In all other cases, use two
# step execution, which will not add the program original source to
# PYTHONPATH.
if filename != "syntax_errors":
extra_flags.append("two_step_execution")
else:
extra_flags.append("binary_python_path")
if filename == "plugin_import":
os.environ["NUITKA_EXTRA_OPTIONS"] = (
extra_options + " --include-package=some_package"
)
elif filename == "reimport_main_dynamic":
if python_version < (3,):
os.environ[
"NUITKA_EXTRA_OPTIONS"
] = extra_options + " --include-plugin-directory=%s" % (
os.path.abspath(filename)
)
else:
os.environ[
"NUITKA_EXTRA_OPTIONS"
] = extra_options + " --include-plugin-files=%s/*.py" % (
os.path.abspath(filename)
)
extra_flags.append("ignore_warnings")
elif filename == "multiprocessing_using":
# TODO: Still true?
if sys.platform == "darwin" and python_version >= (3, 8):
reportSkip("Hangs for unknown reasons", ".", filename)
continue
else:
os.environ["NUITKA_EXTRA_OPTIONS"] = extra_options
active = search_mode.consider(dirname=None, filename=filename)
if active:
my_print("Consider output of recursively compiled program:", filename)
extra_python_path = [
os.path.abspath(os.path.join(filename, entry))
for entry in os.listdir(filename)
if entry.startswith("path")
]
if extra_python_path:
my_print("Applying extra PYTHONPATH %r." % extra_python_path)
with withPythonPathChange(extra_python_path):
compareWithCPython(
dirname=filename,
filename=filename_main,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=False,
)
if extra_variant:
my_print("Extra variation %r." % extra_variant)
compareWithCPython(
dirname=filename,
filename=filename_main,
extra_flags=extra_flags + extra_variant,
search_mode=search_mode,
needs_2to3=False,
)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/programs/dash_main/ 0000700 0003721 0003721 00000000000 14167275622 025212 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/dash_main/Dash-Main.py 0000600 0003721 0003721 00000001451 14166627112 027322 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is running from", __file__)
Nuitka-0.6.19.1/tests/programs/unicode_bom/ 0000700 0003721 0003721 00000000000 14167275622 025552 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/unicode_bom/unicode_bom.py 0000600 0003721 0003721 00000001516 14166627112 030406 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# import unicodedata
print("This is from file with BOM unicode marker")
Nuitka-0.6.19.1/tests/programs/unicode_bom/UnicodeBomMain.py 0000600 0003721 0003721 00000001703 14166627112 030752 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Program that imports a BOM using module.
"""
from __future__ import print_function
import unicode_bom # pylint: disable=unused-import
print("Importing unicode BOM file:")
print("OK.")
Nuitka-0.6.19.1/tests/programs/package_init_issue/ 0000700 0003721 0003721 00000000000 14167275622 027115 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_init_issue/PackageInitIssueMain.py 0000600 0003721 0003721 00000001425 14166627112 033462 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import some_package
Nuitka-0.6.19.1/tests/programs/package_init_issue/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031533 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_init_issue/some_package/child_package/ 0000700 0003721 0003721 00000000000 14167275622 034271 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_init_issue/some_package/child_package/SomeModule.py 0000600 0003721 0003721 00000001436 14166627112 036714 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .. import child_package
Nuitka-0.6.19.1/tests/programs/package_init_issue/some_package/child_package/__init__.py 0000600 0003721 0003721 00000001433 14166627112 036377 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .SomeModule import *
Nuitka-0.6.19.1/tests/programs/package_init_issue/some_package/__init__.py 0000600 0003721 0003721 00000001436 14166627112 033644 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .child_package import *
Nuitka-0.6.19.1/tests/programs/module_exits/ 0000700 0003721 0003721 00000000000 14167275622 025770 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_exits/Main.py 0000600 0003721 0003721 00000001525 14166627112 027225 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print(type(__builtins__))
import ErrorExitingModule
print("Should not get here!")
Nuitka-0.6.19.1/tests/programs/module_exits/ErrorExitingModule.py 0000600 0003721 0003721 00000001545 14166627112 032132 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
print(type(__builtins__))
sys.exit("Module doing sys.exit")
print("This won't happen!")
Nuitka-0.6.19.1/tests/programs/pkgutil_usage/ 0000700 0003721 0003721 00000000000 14167275622 026132 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_usage/package/ 0000700 0003721 0003721 00000000000 14167275622 027525 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/pkgutil_usage/package/DATA_FILE.txt 0000600 0003721 0003721 00000000015 14166627112 031566 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 DATA_CONTENT
Nuitka-0.6.19.1/tests/programs/pkgutil_usage/package/__init__.py 0000600 0003721 0003721 00000001616 14166627112 031636 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pkgutil
__version__ = (
pkgutil.get_data(__package__ or __name__, "DATA_FILE.txt").decode("ascii").strip()
)
print(__version__)
Nuitka-0.6.19.1/tests/programs/pkgutil_usage/PkgUtilUsageMain.py 0000600 0003721 0003721 00000001420 14166627112 031646 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import package
Nuitka-0.6.19.1/tests/programs/relative_import/ 0000700 0003721 0003721 00000000000 14167275622 026474 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/relative_import/RelativeImportMain.py 0000600 0003721 0003721 00000001512 14166627112 032614 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import absolute_import
import dircache
print(dircache)
Nuitka-0.6.19.1/tests/programs/relative_import/dircache.py 0000600 0003721 0003721 00000001401 14166627112 030600 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/package_contains_main/ 0000700 0003721 0003721 00000000000 14167275622 027564 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_contains_main/PackageContainsMain.py 0000600 0003721 0003721 00000001425 14166627112 033773 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from . import local
Nuitka-0.6.19.1/tests/programs/package_contains_main/local.py 0000600 0003721 0003721 00000001441 14166627112 031224 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Imported local package")
Nuitka-0.6.19.1/tests/programs/package_contains_main/__init__.py 0000600 0003721 0003721 00000001401 14166627112 031665 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/plugin_import/ 0000700 0003721 0003721 00000000000 14167275622 026157 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/plugin_import/PluginImportMain.py 0000600 0003721 0003721 00000001533 14166627112 031765 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name = "some_module"
module = getattr(__import__("some_package", fromlist=[name]), name)
Nuitka-0.6.19.1/tests/programs/plugin_import/some_package/ 0000700 0003721 0003721 00000000000 14167275622 030575 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/plugin_import/some_package/some_module.py 0000600 0003721 0003721 00000001415 14166627112 033454 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("hi")
Nuitka-0.6.19.1/tests/programs/plugin_import/some_package/__init__.py 0000600 0003721 0003721 00000001403 14166627112 032700 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
Nuitka-0.6.19.1/tests/programs/package_overload/ 0000700 0003721 0003721 00000000000 14167275622 026555 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_overload/Main.py 0000600 0003721 0003721 00000001524 14166627112 030011 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from foo import bar, bar2, not_overloaded
print(bar, not_overloaded)
print(bar2)
Nuitka-0.6.19.1/tests/programs/package_overload/foo/ 0000700 0003721 0003721 00000000000 14167275622 027340 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_overload/foo/bar2.py 0000600 0003721 0003721 00000001401 14166627112 030530 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/package_overload/foo/__init__.py 0000600 0003721 0003721 00000001437 14166627112 031452 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
bar = 42
not_overloaded = 45
Nuitka-0.6.19.1/tests/programs/package_overload/foo/bar.py 0000600 0003721 0003721 00000001401 14166627112 030446 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/import_variants/ 0000700 0003721 0003721 00000000000 14167275622 026510 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/import_variants/ImportVariationsMain.py 0000600 0003721 0003721 00000001755 14166627112 033205 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import some_package.Child2
print("*** Main: Importing")
print("*** Main: Imported")
print("*** Main: Some package", some_package)
print("*** Main: Imported package child", some_package.Child2)
Nuitka-0.6.19.1/tests/programs/import_variants/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031126 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/import_variants/some_package/Child2.py 0000600 0003721 0003721 00000002112 14166627112 032575 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("*** Child2: Begin", __name__)
try:
import Child1
except ImportError:
print("This must be Python3, doing local import then.")
from . import Child1
print("*** Child2: Child2 is in", __package__)
print("*** Child2: Imported nearby child", Child1)
print("*** Child2: End")
Nuitka-0.6.19.1/tests/programs/import_variants/some_package/Child3.py 0000600 0003721 0003721 00000001466 14166627112 032611 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("*** Child3: Begin")
print("*** Child3: End")
Nuitka-0.6.19.1/tests/programs/import_variants/some_package/Child1.py 0000600 0003721 0003721 00000001662 14166627112 032605 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
from . import Child3 as localname
print("*** Child1: Begin")
print("*** Child1: Imported Child3", localname)
print("*** Child1: End")
Nuitka-0.6.19.1/tests/programs/import_variants/some_package/__init__.py 0000600 0003721 0003721 00000001742 14166627112 033237 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("*** some_package: Coming from '%s'" % __file__.replace(".pyc", ".py"))
print("*** some_package: Path is '%s'" % __path__)
print("*** some_package: Package is '%s'" % __package__)
Nuitka-0.6.19.1/tests/programs/package_program/ 0000700 0003721 0003721 00000000000 14167275622 026411 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_program/PackageAsMain/ 0000700 0003721 0003721 00000000000 14167275622 031035 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_program/PackageAsMain/__main__.py 0000600 0003721 0003721 00000003136 14166627112 033126 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Test case, where __main__ is the main program in a directory.
"""
from __future__ import print_function
import sys
# There is a fake module with just "__name__" for package mode created by CPython.
real_name = __name__
print("Hello world!")
print("I am thinking of myself as __name__", repr(__name__))
print("Module object has __name__", repr(sys.modules[real_name].__name__))
print("My package value is", repr(__package__))
if not __package__:
print("Module has package value", repr(sys.modules[real_name].__package__))
print("Module repr", sys.modules[real_name])
print("__file__", __file__)
print("Try to import from module in main package:")
for_import = "something from __main__"
try:
from . import for_import as value
print("Imported", value)
except (ImportError, SystemError, ValueError) as e:
print("Gave exception:", e)
Nuitka-0.6.19.1/tests/programs/package_program/PackageAsMain/__init__.py 0000600 0003721 0003721 00000001570 14166627112 033145 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
for_import = "something from __init__"
print("Importing", __name__, "package")
Nuitka-0.6.19.1/tests/programs/package_module_collision/ 0000700 0003721 0003721 00000000000 14167275622 030302 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_module_collision/something.py 0000600 0003721 0003721 00000001441 14166627112 032645 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Importing something.py")
Nuitka-0.6.19.1/tests/programs/package_module_collision/PackageAndModuleNamedSameMain.py 0000600 0003721 0003721 00000001605 14166627112 036356 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import Something
import something
print("This would collide on Windows generated source names:")
print(Something)
print(something)
Nuitka-0.6.19.1/tests/programs/package_module_collision/Something/ 0000700 0003721 0003721 00000000000 14167275622 032237 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_module_collision/Something/__init__.py 0000600 0003721 0003721 00000001452 14166627112 034346 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Importing Something/__init__.py")
Nuitka-0.6.19.1/tests/programs/main_raises/ 0000700 0003721 0003721 00000000000 14167275622 025561 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/main_raises/ErrorRaising.py 0000600 0003721 0003721 00000001450 14166627112 030535 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def raiseException():
return 1 / 0
Nuitka-0.6.19.1/tests/programs/main_raises/ErrorMain.py 0000600 0003721 0003721 00000001617 14166627112 030032 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Just plain exception from the module level, supposed to report the correct file and line
import ErrorRaising
ErrorRaising.raiseException()
Nuitka-0.6.19.1/tests/programs/dash_import/ 0000700 0003721 0003721 00000000000 14167275622 025600 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/dash_import/dash-module.py 0000600 0003721 0003721 00000001461 14166627112 030352 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Module with dash imported as", __name__)
Nuitka-0.6.19.1/tests/programs/dash_import/plus+module.py 0000600 0003721 0003721 00000001461 14166627112 030414 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Module with plus imported as", __name__)
Nuitka-0.6.19.1/tests/programs/dash_import/DashImportMain.py 0000600 0003721 0003721 00000001570 14166627112 031030 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__import__("dash-module")
b = "dash-module"
__import__(b)
__import__("plus+module")
c = "plus+module"
__import__(c)
Nuitka-0.6.19.1/tests/programs/case_imports2/ 0000700 0003721 0003721 00000000000 14167275622 026041 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports2/path1/ 0000700 0003721 0003721 00000000000 14167275622 027056 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports2/path1/some_module.py 0000600 0003721 0003721 00000001401 14166627112 031730 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/case_imports2/path1/some_package/ 0000700 0003721 0003721 00000000000 14167275622 031474 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports2/path1/some_package/__init__.py 0000600 0003721 0003721 00000001401 14166627112 033575 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/case_imports2/CasedImportingMain.py 0000600 0003721 0003721 00000001450 14166627112 032124 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import Some_Module
import some_package
Nuitka-0.6.19.1/tests/programs/case_imports2/path2/ 0000700 0003721 0003721 00000000000 14167275622 027057 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports2/path2/Some_Package/ 0000700 0003721 0003721 00000000000 14167275622 031375 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports2/path2/Some_Package/__init__.py 0000600 0003721 0003721 00000001437 14166627112 033507 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Package")
Nuitka-0.6.19.1/tests/programs/case_imports2/path2/Some_Module.py 0000600 0003721 0003721 00000001436 14166627112 031641 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Module")
Nuitka-0.6.19.1/tests/programs/deep/ 0000700 0003721 0003721 00000000000 14167275622 024204 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/deep/DeepProgramMain.py 0000600 0003721 0003721 00000001536 14166627112 027571 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import some_package.deep_package.DeepDeepChild
import some_package.DeepChild
print("Done.")
Nuitka-0.6.19.1/tests/programs/deep/some_package/ 0000700 0003721 0003721 00000000000 14167275622 026622 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/deep/some_package/deep_package/ 0000700 0003721 0003721 00000000000 14167275622 031212 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/deep/some_package/deep_package/DeepDeepChild.py 0000600 0003721 0003721 00000001554 14166627112 034204 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
from .. import DeepBrother
print("This is DeepDeepChild talking.")
Nuitka-0.6.19.1/tests/programs/deep/some_package/deep_package/__init__.py 0000600 0003721 0003721 00000001670 14166627112 033323 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
print("The deep package has __package__", __package__)
print("The deep package has __package__", sys.modules[__name__].__package__)
Nuitka-0.6.19.1/tests/programs/deep/some_package/DeepBrother.py 0000600 0003721 0003721 00000001724 14166627112 031377 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("This is deep brother module talking.", __name__)
def someBrotherFunction():
pass
print("The __module__ of function here is", someBrotherFunction.__module__)
Nuitka-0.6.19.1/tests/programs/deep/some_package/DeepChild.py 0000600 0003721 0003721 00000001615 14166627112 031014 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("Importing child.")
class A:
pass
print("Class defined here, has these vars", vars(A))
Nuitka-0.6.19.1/tests/programs/deep/some_package/__init__.py 0000600 0003721 0003721 00000001401 14166627112 030723 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/programs/package_missing_init/ 0000700 0003721 0003721 00000000000 14167275622 027436 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_missing_init/PackageMissingInitMain.py 0000600 0003721 0003721 00000001636 14166627112 034330 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import some_package.some_module
import some_package.sub_package.some_sub_module
print(some_package.__package__)
print(some_package.sub_package.__package__)
Nuitka-0.6.19.1/tests/programs/package_missing_init/some_package/ 0000700 0003721 0003721 00000000000 14167275622 032054 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_missing_init/some_package/sub_package/ 0000700 0003721 0003721 00000000000 14167275622 034320 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_missing_init/some_package/sub_package/some_sub_module.py 0000600 0003721 0003721 00000001720 14166627112 040047 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This must be Python3 which no longer needs __init__.py to accept a package.")
import sys
print("The parent path is", sys.modules["some_package.sub_package"].__path__)
def s():
pass
print(s)
Nuitka-0.6.19.1/tests/programs/package_missing_init/some_package/some_module.py 0000600 0003721 0003721 00000001704 14166627112 034734 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This must be Python3 which no longer needs __init__.py to accept a package.")
import sys
print("The parent path is", sys.modules["some_package"].__path__)
def f():
pass
print(f)
Nuitka-0.6.19.1/tests/programs/with space/ 0000700 0003721 0003721 00000000000 14167275622 025316 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/with space/Space Main.py 0000700 0003721 0003721 00000001472 14166627112 027571 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Hello from main program with space in its paths")
Nuitka-0.6.19.1/tests/programs/case_imports3/ 0000700 0003721 0003721 00000000000 14167275622 026042 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports3/path1/ 0000700 0003721 0003721 00000000000 14167275622 027057 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports3/path1/Some_Package/ 0000700 0003721 0003721 00000000000 14167275622 031375 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports3/path1/Some_Package/__init__.py 0000600 0003721 0003721 00000001452 14166627112 033504 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Package from path1")
Nuitka-0.6.19.1/tests/programs/case_imports3/path1/Some_Module.py 0000600 0003721 0003721 00000001451 14166627112 031636 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Module from path1")
Nuitka-0.6.19.1/tests/programs/case_imports3/CasedImportingMain.py 0000600 0003721 0003721 00000002063 14166627112 032126 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
try:
import some_module
except ImportError:
print("Cannot import wrongly cased module.")
else:
print("OK, imported wrongly cased module.")
try:
import some_package
except ImportError:
print("Cannot import wrongly cased package.")
else:
print("OK, imported wrongly cased package.")
Nuitka-0.6.19.1/tests/programs/case_imports3/path2/ 0000700 0003721 0003721 00000000000 14167275622 027060 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports3/path2/Some_Package/ 0000700 0003721 0003721 00000000000 14167275622 031376 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/case_imports3/path2/Some_Package/__init__.py 0000600 0003721 0003721 00000001452 14166627112 033505 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Package from path2")
Nuitka-0.6.19.1/tests/programs/case_imports3/path2/Some_Module.py 0000600 0003721 0003721 00000001451 14166627112 031637 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("This is Some_Module from path2")
Nuitka-0.6.19.1/tests/programs/package_code/ 0000700 0003721 0003721 00000000000 14167275622 025654 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_code/PackageInitCodeMain.py 0000600 0003721 0003721 00000001440 14166627112 032000 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import some_package.SomeModule
Nuitka-0.6.19.1/tests/programs/package_code/some_package/ 0000700 0003721 0003721 00000000000 14167275622 030272 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_code/some_package/SomeModule.py 0000600 0003721 0003721 00000001452 14166627112 032713 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Thanks for importing SomeModule")
Nuitka-0.6.19.1/tests/programs/package_code/some_package/__init__.py 0000600 0003721 0003721 00000001451 14166627112 032400 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Thanks for importing", __name__)
Nuitka-0.6.19.1/tests/programs/cyclic_imports/ 0000700 0003721 0003721 00000000000 14167275622 026312 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/cyclic_imports/CyclicImportsMain.py 0000600 0003721 0003721 00000001441 14166627112 032251 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import cyclic_importing_package
Nuitka-0.6.19.1/tests/programs/cyclic_imports/cyclic_importing_package/ 0000700 0003721 0003721 00000000000 14167275622 033323 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/cyclic_imports/cyclic_importing_package/Child2.py 0000600 0003721 0003721 00000001535 14166627112 035002 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Child2:", __name__)
from . import Child1
print("Value of Child1", Child1.__name__)
Nuitka-0.6.19.1/tests/programs/cyclic_imports/cyclic_importing_package/Child1.py 0000600 0003721 0003721 00000001535 14166627112 035001 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Child1:", __name__)
from . import Child2
print("Value of Child2", Child2.__name__)
Nuitka-0.6.19.1/tests/programs/cyclic_imports/cyclic_importing_package/__init__.py 0000600 0003721 0003721 00000001474 14166627112 035436 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("package __init__:", __name__)
from . import Child1
Nuitka-0.6.19.1/tests/programs/module_attributes/ 0000700 0003721 0003721 00000000000 14167275622 027022 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/ 0000700 0003721 0003721 00000000000 14167275622 031665 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/Nearby1.py 0000600 0003721 0003721 00000003205 14166627112 033534 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print(
"__package__: ",
__package__
if __package__ is not None or sys.version_info[:2] != (3, 2)
else ".".join(__name__.split(".")[:-1]),
)
Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/__init__.py 0000600 0003721 0003721 00000003000 14166627112 033763 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print("__package__: ", __package__)
Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/ 0000700 0003721 0003721 00000000000 14167275622 034531 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/Nearby2.py 0000600 0003721 0003721 00000003205 14166627112 036401 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print(
"__package__: ",
__package__
if __package__ is not None or sys.version_info[:2] != (3, 2)
else ".".join(__name__.split(".")[:-1]),
)
Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/package_level3/ 0000700 0003721 0003721 00000000000 14167275622 037376 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011212 L ustar 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/package_level3/Nearby3.py Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/package_level3/Nearby0000600 0003721 0003721 00000003205 14166627112 040535 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print(
"__package__: ",
__package__
if __package__ is not None or sys.version_info[:2] != (3, 2)
else ".".join(__name__.split(".")[:-1]),
)
././@LongLink 0000000 0000000 0000000 00000000152 00000000000 011213 L ustar 0000000 0000000 Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/package_level3/__init__.py Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/package_level3/__init0000600 0003721 0003721 00000003000 14166627112 040547 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print("__package__: ", __package__)
Nuitka-0.6.19.1/tests/programs/module_attributes/package_level1/package_level2/__init__.py 0000600 0003721 0003721 00000003000 14166627112 036627 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__cached__" in d:
d["__cached__"] = "<__cached__ removed>"
if "__spec__" in d:
d["__spec__"].loader = "loader removed"
d["__spec__"].origin = "origin removed"
d["__spec__"].submodule_search_locations = "submodule_search_locations removed"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
print("__name__: ", __name__)
print("__package__: ", __package__)
Nuitka-0.6.19.1/tests/programs/module_attributes/ModuleAttributesMain.py 0000600 0003721 0003721 00000002656 14166627112 033502 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that covers all module attributes. """
from __future__ import print_function
import package_level1.Nearby1
import package_level1.package_level2.Nearby2
import package_level1.package_level2.package_level3
import package_level1.package_level2.package_level3.Nearby3
def displayDict(d):
d = dict(d)
del d["displayDict"]
del d["__builtins__"]
if "__loader__" in d:
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d["__file__"] = "<__file__ removed>"
if "__compiled__" in d:
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print(displayDict(globals()))
# pylint: disable=unused-import
Nuitka-0.6.19.1/tests/programs/absolute_import/ 0000700 0003721 0003721 00000000000 14167275622 026477 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/absolute_import/foobar/ 0000700 0003721 0003721 00000000000 14167275622 027747 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/absolute_import/foobar/local.py 0000600 0003721 0003721 00000001557 14166627112 031417 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Just trace the import.
"""
from __future__ import print_function
print("This is for relative import.")
Nuitka-0.6.19.1/tests/programs/absolute_import/foobar/util.py 0000600 0003721 0003721 00000001534 14166627112 031275 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Module that provides a function for import.
"""
def someFunction():
return "hi"
Nuitka-0.6.19.1/tests/programs/absolute_import/foobar/foobar.py 0000600 0003721 0003721 00000002023 14166627112 031562 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Using absolute import, do from module imports.
"""
from __future__ import absolute_import, print_function
from foobar import util
from . import local # pylint: disable=unused-import
class Foobar(object):
def __init__(self):
print(util.someFunction())
Nuitka-0.6.19.1/tests/programs/absolute_import/foobar/__init__.py 0000600 0003721 0003721 00000001434 14166627112 032056 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .foobar import Foobar
Nuitka-0.6.19.1/tests/programs/absolute_import/AbsoluteImportMain.py 0000600 0003721 0003721 00000001477 14166627112 032634 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import foobar
if __name__ == "__main__":
foobar.Foobar()
Nuitka-0.6.19.1/tests/programs/syntax_errors/ 0000700 0003721 0003721 00000000000 14167275622 026211 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/syntax_errors/SyntaxErrorsMain.py 0000600 0003721 0003721 00000002067 14166627112 032054 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
try:
from SyntaxErroring import x
except Exception as e:
print("Importing with syntax error gave:", type(e), e)
try:
from IndentationErroring import x
except Exception as e:
print("Importing with indentation error gave:", type(e), e)
print("Finished.")
Nuitka-0.6.19.1/tests/programs/syntax_errors/SyntaxErroring.py 0000600 0003721 0003721 00000001440 14166627112 031554 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class x(metaclass=y):
pass
Nuitka-0.6.19.1/tests/programs/syntax_errors/IndentationErroring.py 0000600 0003721 0003721 00000001427 14166627112 032547 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def f():
x
y
Nuitka-0.6.19.1/tests/programs/package_prevents_submodule/ 0000700 0003721 0003721 00000000000 14167275622 030667 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_prevents_submodule/PackagePreventsSubmoduleMain.py 0000600 0003721 0003721 00000005634 14166627112 037014 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import imp
import os
import sys
ORIG = None
attemptImports = None
# Nuitka gives warnings, that even if disabled touch this.
__warningregistry__ = {}
def diff(dct):
print("globals diff", ORIG.symmetric_difference(dct))
mdiff = START.symmetric_difference(sys.modules)
# Python2 does strange thing with relative imports, that we do not.
if str is bytes:
if "some_package.os" in mdiff:
mdiff.remove("some_package.os")
print("Modules diff", mdiff)
START = set(sys.modules)
ORIG = set(globals())
def attemptImports(prefix):
print(prefix, "GO1:")
try:
import some_package
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", some_package.__name__)
diff(globals())
print(prefix, "GO2:")
try:
from some_package.some_module import Class4
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", Class4)
diff(globals())
print(prefix, "GO3:")
try:
from some_package import some_module
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", some_module.__name__)
diff(globals())
print(prefix, "GO4:")
try:
from some_package import raiseError
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", raiseError.__name__)
diff(globals())
print(prefix, "GO5:")
try:
from some_package import Class5
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", Class5)
diff(globals())
print(prefix, "GO6:")
try:
from some_package import Class3
except BaseException as e:
print("Exception occurred", e)
else:
print("Import success.", Class3)
diff(globals().keys())
os.environ["TEST_SHALL_RAISE_ERROR"] = "1"
attemptImports("With expected errors")
os.environ["TEST_SHALL_RAISE_ERROR"] = "0"
attemptImports("With error resolved")
del sys.modules["some_package"]
attemptImports("With deleted module")
Nuitka-0.6.19.1/tests/programs/package_prevents_submodule/some_package/ 0000700 0003721 0003721 00000000000 14167275622 033305 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/programs/package_prevents_submodule/some_package/some_module.py 0000600 0003721 0003721 00000001440 14166627112 036162 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class Class4(object):
pass
Nuitka-0.6.19.1/tests/programs/package_prevents_submodule/some_package/__init__.py 0000600 0003721 0003721 00000002066 14166627112 035416 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
print(
"This is",
__name__,
"code with error raise",
os.environ.get("TEST_SHALL_RAISE_ERROR"),
)
class Class3(object):
pass
def raiseError():
raise Exception("AHOJ")
if os.environ.get("TEST_SHALL_RAISE_ERROR") == "1":
raiseError()
class Class5(object):
pass
Nuitka-0.6.19.1/tests/basics/ 0000700 0003721 0003721 00000000000 14167275622 022701 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/tests/basics/HelloWorld_2.py 0000600 0003721 0003721 00000002406 14166627112 025545 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print "Hello World from module main code"
def printHelloWorld():
print "Hello World from function main code"
print printHelloWorld
printHelloWorld()
def printHelloWorld2(arg):
print arg
print printHelloWorld2
printHelloWorld2("Hello World from function positional argument")
printHelloWorld2(arg="Hello World from function keyword argument")
def printHelloWorld3(arg="Hello World from function default argument"):
print arg
print printHelloWorld3
printHelloWorld3()
Nuitka-0.6.19.1/tests/basics/ListContractions.py 0000600 0003721 0003721 00000005363 14166627112 026560 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Cover list contractions and a few special things in them.
"""
from __future__ import print_function
# Tests do bad things, pylint: disable=redefined-outer-name,possibly-unused-variable
def displayDict(d):
result = "{"
for key, value in sorted(d.items()):
result += "%s: %s" % (key, value)
result += "}"
print("List contraction on the module level:")
x = [(u if u % 2 == 0 else 0) for u in range(10)]
print(x)
print("List contraction on the function level:")
def someFunction():
x = [(u if u % 2 == 0 else 0) for u in range(10)]
print(x)
someFunction()
print("List contractions with no, 1 one 2 conditions:")
def otherFunction():
print([x for x in range(8)])
print([x for x in range(8) if x % 2 == 1])
print([x for x in range(8) if x % 2 == 1 if x > 4])
otherFunction()
print("Complex list contractions with more than one for:")
def complexContractions():
print([(x, y) for x in range(3) for y in range(5)])
seq = range(3)
res = [(i, j, k) for i in iter(seq) for j in iter(seq) for k in iter(seq)]
print(res)
complexContractions()
print("Contraction for 2 for statements and one final if referring to first for:")
def trickyContraction():
class Range:
def __init__(self, value):
self.value = value
def __iter__(self):
print("Giving range iter to", self.value)
return iter(range(self.value))
def Cond(y):
print("Checking against", y)
return y == 1
r = [(x, z, y) for x in Range(3) for z in Range(2) for y in Range(4) if Cond(y)]
print("result is", r)
trickyContraction()
def lambdaWithcontraction(x):
l = lambda x: [z for z in range(x)]
r = l(x)
print("Lambda contraction locals:", displayDict(locals()))
lambdaWithcontraction(3)
print("Contraction that gets a 'del' on the iterator variable:", end=" ")
def allowedDelOnIteratorVariable(z):
x = 2
del x
return [x * z for x in range(z)]
print(allowedDelOnIteratorVariable(3))
Nuitka-0.6.19.1/tests/basics/ExceptionRaising33.py 0000600 0003721 0003721 00000002662 14166627112 026676 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
print("Testing exception changes between generator switches:")
def yieldExceptionInteraction():
def yield_raise():
try:
raise KeyError("caught")
except KeyError:
yield from sys.exc_info()
yield from sys.exc_info()
yield from sys.exc_info()
g = yield_raise()
print("Initial yield from catch in generator", next(g))
print("Checking from outside of generator", sys.exc_info()[0])
print("Second yield from the catch reentered", next(g))
print("Checking from outside of generator", sys.exc_info()[0])
print("After leaving the catch generator yielded", next(g))
yieldExceptionInteraction()
Nuitka-0.6.19.1/tests/basics/GlobalStatement.py 0000600 0003721 0003721 00000007360 14166627112 026342 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
x = 2
def someFunction1():
x = 3
return x
def someFunction2():
global x
x = 4
return x
def someFunction3():
return x
def someNestedGlobalUser1():
z = 1
# Nested function that uses a global z doesn't affect the local variable z at all.
def setZ():
global z
z = 3
setZ()
return z
def someNestedGlobalUser2():
z = 1
# Nested function that uses a global z doesn't affect the local variable z at
# all. This doesn't change if it's done inside an exec block.
exec(
"""
def setZ():
global z
z = 3
setZ()
"""
)
return z
def someNestedGlobalUser3a():
# Nested function that uses a exec variable scope z and a global z, changes z to be
# the global one only. We verify that by looking at locals. This means that the global
# statement inside the function of exec changes the effect of the z.
exec(
"""
z = 1
def setZ():
global z
z = 3
setZ()
"""
)
return z, locals().keys() == ["setZ"]
def someNestedGlobalUser3b():
# Nested function that uses a exec variable scope z and a global z, changes
# z to be the global one only. We verify that by looking at locals.
exec(
"""
z = 1
"""
)
if sys.version_info[0] < 3:
return z, locals().keys() == ["z"]
else:
return locals().keys() == []
def someNestedGlobalUser4():
z = 1
# This one proves that the local variable z is entirely ignored, and that the global z
# has the value 2 inside setZ().
exec(
"""
z = 2
def setZ():
global z
z = 3*z
setZ()
"""
)
return z
def someNestedGlobalUser5():
z = 1
# Without a global statement, z affects the local variable z.
exec(
"""
z = 3
"""
)
return z
def someNestedGlobalUser6():
# Without a global statement, a local variable z is created.
exec(
"""
z = 7
"""
)
return z
print("Function that shadows a global variable with a local variable")
print(someFunction1())
print(
"Function that accesses and changes a global variable declared with a global statement"
)
print(someFunction2())
print("Function that uses a global variable")
print(someFunction3())
print("Functions that uses a global variable in a nested function in various ways:")
print(someNestedGlobalUser1, someNestedGlobalUser1())
del z
print(someNestedGlobalUser2, someNestedGlobalUser2())
del z
print(someNestedGlobalUser3a, someNestedGlobalUser3a())
del z
print(someNestedGlobalUser3b, someNestedGlobalUser3b())
print(someNestedGlobalUser4, (someNestedGlobalUser4(), z))
del z
print(someNestedGlobalUser5, someNestedGlobalUser5())
z = 9
print(someNestedGlobalUser6, (someNestedGlobalUser6(), z))
x = 7
def f():
x = 1
def g():
global x
def i():
def h():
return x
return h()
return i()
return g()
print(f())
global global_already
global_already = 1
Nuitka-0.6.19.1/tests/basics/TryYieldFinally.py 0000600 0003721 0003721 00000004430 14166627112 026334 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def tryContinueFinallyTest():
for x in range(10):
try:
if x % 2 == 1:
continue
finally:
yield x
yield "-"
def tryBreakFinallyTest():
for x in range(10):
try:
if x == 5:
break
finally:
yield x
yield "-"
def tryFinallyAfterYield():
try:
yield 3
finally:
print("Executing finally")
def tryReturnFinallyYield():
try:
return
finally:
yield 1
def tryReturnExceptYield():
try:
return
except StopIteration:
print("Caught StopIteration")
yield 2
except:
yield 1
else:
print("No exception")
def tryStopIterationExceptYield():
try:
raise StopIteration
except StopIteration:
print("Caught StopIteration")
yield 2
except:
yield 1
else:
print("No exception")
print("Check if finally is executed in a continue using for loop:")
print(tuple(tryContinueFinallyTest()))
print("Check if finally is executed in a break using for loop:")
print(tuple(tryBreakFinallyTest()))
print("Check what try yield finally something does:")
print(tuple(tryFinallyAfterYield()))
print("Check if yield is executed in finally after return:")
print(tuple(tryReturnFinallyYield()))
print("Check if yield is executed in except after return:")
print(tuple(tryReturnExceptYield()))
print("Check if yield is executed in except after StopIteration:")
print(tuple(tryReturnExceptYield()))
Nuitka-0.6.19.1/tests/basics/TryReturnFinally.py 0000600 0003721 0003721 00000005432 14166627112 026550 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# In this test we show that return in try/finally executes the finally part
# just fine.
from __future__ import print_function
import sys
def eight():
return 8
def nine():
return 9
def raisy1():
return 1 / 0
def raisy2():
return 1()
def raisy3(arg):
raise TypeError(arg)
def returnInTried(for_call):
try:
print("returnInTried with exception info in tried block:", sys.exc_info())
return for_call()
finally:
print("returnInTried with exception info in final block:", sys.exc_info())
def returnInFinally(for_call):
try:
print("returnInFinally with exception info in tried block:", sys.exc_info())
finally:
print("returnInFinally with exception info in final block:", sys.exc_info())
return for_call()
print("Standard try finally with return in tried block:")
print("result", returnInTried(eight))
print("*" * 80)
print("Standard try finally with return in final block:")
print("result", returnInFinally(nine))
print("*" * 80)
print("Exception raising try finally with return in tried block:")
try:
print("result", returnInTried(raisy1))
except Exception as e:
print("Gave exception", repr(e))
print("*" * 80)
print("Exception raising try finally with return in final block:")
try:
print("result", returnInFinally(raisy2))
except Exception as e:
print("Gave exception", repr(e))
print("*" * 80)
try:
raisy3("unreal 1")
except Exception as outer_e:
print("Exception raising try finally with return in tried block:")
try:
print("result", returnInTried(raisy1))
except Exception as e:
print("Gave exception", repr(e))
print("Handler exception remains:", repr(outer_e))
print("*" * 80)
try:
raisy3("unreal 2")
except Exception as outer_e:
print("Exception raising try finally with return in final block:")
try:
print("result", returnInFinally(raisy2))
except Exception as e:
print("Gave exception", repr(e))
print("Handler exception remains:", repr(outer_e))
print("*" * 80)
Nuitka-0.6.19.1/tests/basics/LateClosureAssignment.py 0000600 0003721 0003721 00000005253 14166627112 027527 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def closureTest1():
# Assign, but the value is not supposed to be used by the function, instead the later
# update is effective.
d = 1
def subby():
return d
d = 22222 * 2222
return subby()
def closureTest2():
# Using a closure variable that is not initialized at the time it is closured should
# work as well.
def subby():
return d
d = 2222 * 2222
return subby()
def closureTest3():
def subby():
return undefined_global
try:
return subby()
except NameError:
return 88
d = 1
def scopeTest4():
try:
return d
d = 1
except UnboundLocalError as e:
return repr(e)
print("Test closure where value is overwritten:", closureTest1())
print("Test closure where value is assigned only late:", closureTest2())
print("Test function where closured value is never assigned:", closureTest3())
print("Scope test where UnboundLocalError is expected:", scopeTest4())
def function():
pass
class ClosureLocalizerClass:
print("Function before assigned in a class:", function)
function = 1
print("Function after it was assigned in class:", function)
ClosureLocalizerClass()
def ClosureLocalizerFunction():
try:
function = function
print("Function didn't give unbound local error")
except UnboundLocalError as e:
print(
"Function gave unbound local error when accessing function before assignment:",
repr(e),
)
ClosureLocalizerFunction()
class X:
def __init__(self, x):
self.x = x
def changingClosure():
print("Changing a closure taken value after it was taken.")
a = 1
def closureTaker():
return X(a)
x = closureTaker()
a = 2
print("Closure value first time:", x.x)
x = closureTaker()
print("Closure value second time:", x.x)
changingClosure()
Nuitka-0.6.19.1/tests/basics/Assignments32.py 0000600 0003721 0003721 00000013315 14166627112 025712 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print("Basic assignment forms from various iterables:")
a, b = 1, 2 # simple sequence assignment
print(a, b)
a, b = ["green", "blue"] # list assignment
print(a, b)
a, b = "XY" # string assignment
print(a, b)
a, b = range(1, 5, 2) # any iterable will do
print(a, b)
print("Using braces on unpacking side:")
(a, b), c = "XY", "Z" # a = 'X', b = 'Y', c = 'Z'
print(a, b, c)
print("Too many values:")
try:
(a, b), c = "XYZ" # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
print("Too few values:")
try:
(a, b), c = "XY" # ERROR -- need more than 1 value to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
print("More complex right hand side, consisting of multiple values:")
(a, b), c, = [1, 2], "this" # a = '1', b = '2', c = 'this'
print(a, b, c)
print("More complex right hand side, too many values:")
try:
(a, b), (c,) = [1, 2], "this" # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
print("Extended sequence * unpacking:")
a, *b = 1, 2, 3, 4, 5 # a = 1, b = [2,3,4,5]
print(a, b)
*a, b = 1, 2, 3, 4, 5 # a = [1,2,3,4], b = 5
print(a, b)
a, *b, c = 1, 2, 3, 4, 5 # a = 1, b = [2,3,4], c = 5
print(a, b)
a, *b = "X" # a = 'X', b = []
print(a, b)
*a, b = "X" # a = [], b = 'X'
print(a, b)
a, *b, c = "XY" # a = 'X', b = [], c = 'Y'
print(a, b)
a, *b, c = "X...Y" # a = 'X', b = ['.','.','.'], c = 'Y'
print(a, b, c)
a, b, *c = 1, 2, 3 # a = 1, b = 2, c = [3]
print(a, b, c)
a, b, c, *d = 1, 2, 3 # a = 1, b = 2, c = 3, d = []
print(a, b, c, d)
(a, b), c = [1, 2], "this" # a = '1', b = '2', c = 'this'
print(a, b, c)
(a, b), *c = [1, 2], "this" # a = '1', b = '2', c = ['this']
print(a, b, c)
(a, b), c, *d = [1, 2], "this" # a = '1', b = '2', c = 'this', d = []
print(a, b, c, d)
(a, b), *c, d = [1, 2], "this" # a = '1', b = '2', c = [], d = 'this'
print(a, b, c, d)
(a, b), (c, *d) = [1, 2], "this" # a = '1', b = '2', c = 't', d = ['h', 'i', 's']
print(a, b, c, d)
*a, = (1, 2) # a = [1,2]
print("Extended sequence * unpacking with non-iterable:")
try:
*a, = 1 # ERROR -- 'int' object is not iterable
except Exception as e:
print(repr(e))
print(a)
print("Extended sequence * unpacking with list:")
*a, = [1] # a = [1]
print(a)
print("Extended sequence * unpacking with tuple:")
*a, = (1,) # a = [1]
print(a)
print("Extended sequence * unpacking with fixed right side:")
*a, b = [1] # a = [], b = 1
print(a, b)
*a, b = (1,) # a = [], b = 1
print(a, b)
print("Unpacking too many values:")
try:
(a, b), c = 1, 2, 3 # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
print("Unpacking with star argument changes error:")
try:
(a, b), *c = 1, 2, 3 # ERROR - 'int' object is not iterable
except Exception as e:
print(repr(e))
print(a, b, c)
print("Unpacking with star argument after tuple unpack:")
(a, b), *c = "XY", 2, 3 # a = 'X', b = 'Y', c = [2,3]
print(a, b, c)
print("Extended sequence unpacking, nested:")
try:
(a, b), c = 1, 2, 3 # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
*(a, b), c = 1, 2, 3 # a = 1, b = 2, c = 3
print(a, b, c)
*(a, b), = 1, 2 # a = 1, b = 2
print(a, b)
*(a, b), = "XY" # a = 'X', b = 'Y'
print(a, b)
try:
*(a, b), = "this" # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b)
*(a, *b), = "this" # a = 't', b = ['h', 'i', 's']
print(a, b)
*(a, *b), c = "this" # a = 't', b = ['h', 'i'], c = 's'
print(a, b, c)
*(a, *b), = 1, 2, 3, 3, 4, 5, 6, 7 # a = 1, b = [2, 3, 3, 4, 5, 6, 7]
print(a, b)
try:
*(a, *b), (*c,) = 1, 2, 3, 3, 4, 5, 6, 7 # ERROR -- 'int' object is not iterable
except Exception as e:
print(repr(e))
print("unchanged", a, b, c)
print("Unpacking with nested stars:")
*(a, *b), c = 1, 2, 3, 3, 4, 5, 6, 7 # a = 1, b = [2, 3, 3, 4, 5, 6], c = 7
print(a, b, c)
print("Unpacking with even more nested stars:")
*(a, *b), (*c,) = 1, 2, 3, 4, 5, "XY" # a = 1, b = [2, 3, 4, 5], c = ['X', 'Y']
print(a, b, c)
*(a, *b), c, d = 1, 2, 3, 3, 4, 5, 6, 7 # a = 1, b = [2, 3, 3, 4, 5], c = 6, d = 7
print("starting", a, b, c, d)
try:
*(a, *b), (c, d) = 1, 2, 3, 3, 4, 5, 6, 7 # ERROR -- 'int' object is not iterable
except Exception as e:
print(repr(e))
print("unchanged", a, b, c, d)
try:
*(a, *b), (*c, d) = 1, 2, 3, 3, 4, 5, 6, 7 # ERROR -- 'int' object is not iterable
except Exception as e:
print(repr(e))
print(a, b, c, d)
try:
*(a, b), c = "XY", 3 # ERROR -- need more than 1 value to unpack
except Exception as e:
print(repr(e))
print("unchanged", a, b, c)
*(*a, b), c = "XY", 3 # a = [], b = 'XY', c = 3
print(a, b, c)
(a, b), c = "XY", 3 # a = 'X', b = 'Y', c = 3
print(a, b, c)
*(a, b), c = "XY", 3, 4 # a = 'XY', b = 3, c = 4
print(a, b, c)
*(*a, b), c = "XY", 3, 4 # a = ['XY'], b = 3, c = 4
print(a, b, c)
try:
(a, b), c = "XY", 3, 4 # ERROR -- too many values to unpack
except Exception as e:
print(repr(e))
print(a, b, c)
Nuitka-0.6.19.1/tests/basics/Assignments.py 0000600 0003721 0003721 00000013406 14166627112 025546 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Assignment tests, cover most forms of them. """
from __future__ import print_function
import sys
# Tests are dirty on purpose.
#
# pylint: disable=broad-except,global-variable-undefined,redeclared-assigned-name
# pylint: disable=global-variable-not-assigned,invalid-name,self-assigning-variable
def someFunction():
a = 2
print("Simple assignment to variable:", a)
b = c = 3
print("Assignment to 2 variables", b, c)
z = [1, 2, 3]
z[2] = z[1] = 5
print("Assignment to list subscripts:", z)
d, e = 1, 2
print("Assignment to variable tuple:", d, e)
[f, g] = 7, 9
print("Assignment to variable list:", f, g)
j = [h, i] = (7, 9)
print("Complex Assignment from variable list:", j, type(j), h, i)
a, (b, c) = 1, (2, 3)
print("Assignment to nested tuples:", a, b, c)
v = [1, 2, 3, 4]
v[2:3] = (8, 9)
print("Assignment to list slice", v)
def varargsFunction(*args):
f1, f2, f3, f4 = args
print("Assignment from list", f1, f2, f3, f4)
def otherFunction():
class Iterable:
def __iter__(self):
return iter(range(3))
a, b, c = Iterable()
print("Assignments from iterable", a, b, c)
print("Assignments from too small iterable", end=" ")
try:
f, g = (1,)
except Exception as e:
print("gave", type(e), repr(e))
try:
print(f)
except UnboundLocalError:
print("Variable f is untouched")
try:
print(g)
except UnboundLocalError:
print("Variable g is untouched")
print("Assignments from too large iterable", end=" ")
try:
d, j = 1, 2, 3
except Exception as e:
print("gave", type(e), repr(e))
try:
print(d)
except UnboundLocalError:
print("Variable d is untouched")
try:
print(j)
except UnboundLocalError:
print("Variable j is untouched")
class BasicIterClass:
def __init__(self, n):
self.n = n
self.i = 0
def __next__(self):
res = self.i
if res >= self.n:
raise StopIteration
self.i = res + 1
return res
if sys.version_info[0] < 3:
def next(self):
return self.__next__()
class IteratingSequenceClass:
def __init__(self, n):
self.n = n
def __iter__(self):
return BasicIterClass(self.n)
print("Exception from iterating over too short class:", end=" ")
try:
a, b, c = IteratingSequenceClass(2)
except ValueError:
print("gave", sys.exc_info())
def anotherFunction():
d = {}
print("Assignment to dictionary with comma subscript:", end="")
# d["f"] = 3
d["a", "b"] = 6
d["c", "b"] = 9
print(sorted(d.items()))
def swapVariables():
print("Strange swap form:")
a = 1
b = 2
a, b, a = b, a, b
print(a, b)
def interuptedUnpack():
a = 1
b = 2
print("Assignment from a too short tuple to multiple targets:", end=" ")
try:
s = (a,)
c, d = s
except ValueError as e:
print("gives ValueError", repr(e))
try:
print(c)
except UnboundLocalError as e:
print("and then nothing is assigned:", repr(e))
else:
del d
del a, b
z = []
try:
a, z.unknown, b = 1, 2, 3
except AttributeError:
print("Interrupted unpack, leaves value assigned", a)
def multiTargetInterrupt():
a = 1
b = 2
print("Multiple, overlapping targets", end="")
d = c, d = a, b
print(d, c, end="")
del c
del d
c, d = d = a, b
print(d, c)
print("Error during multiple assignments", end="")
del c
del d
e = 9
z = []
try:
c, d = e, z.a = a, b
except AttributeError:
print("having attribute error", c, d, e)
del c
del d
e = 9
print("Error during multiple assignments", end="")
try:
c, d = z.a, e = a, b
except AttributeError:
print("having attribute error", c, d, e)
def optimizeableTargets():
a = [1, 2]
a[int(1)] = 3
print("Optimizable slice operation, results in", a)
def complexDel():
a = b = c = d = 1
del a, b, (c, d)
try:
print(c)
except UnboundLocalError as e:
print("yes, del worked", repr(e))
def sliceDel():
# Python3 ranges are not lists.
a = list(range(6))
del a[2:4]
print("Del slice operation, results in", a)
def globalErrors():
global unassigned_1, unassigned_2
try:
unassigned_1 = unassigned_1
except NameError as e:
print("Accessing unassigned global gives", repr(e))
try:
del unassigned_2
except NameError as e:
print("Del on unassigned global gives", repr(e))
someFunction()
varargsFunction(1, 2, 3, 4)
otherFunction()
anotherFunction()
swapVariables()
interuptedUnpack()
multiTargetInterrupt()
optimizeableTargets()
complexDel()
sliceDel()
globalErrors()
Nuitka-0.6.19.1/tests/basics/Classes32.py 0000600 0003721 0003721 00000006415 14166627112 025017 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
try:
from collections.abc import OrderedDict
except ImportError:
from collections import OrderedDict
print("Call order of Python3 metaclasses:")
def a():
x = 1
class A:
print("Class body a.A is evaluating closure x", x)
print("Called", a)
return A
def b():
class B:
pass
print("Called", b)
return B
def displayable(dictionary):
return sorted(dictionary.items())
def m():
class M(type):
def __new__(cls, class_name, bases, attrs, **over):
print(
"Metaclass M.__new__ cls",
cls,
"name",
class_name,
"bases",
bases,
"dict",
displayable(attrs),
"extra class defs",
displayable(over),
)
return type.__new__(cls, class_name, bases, attrs)
def __init__(self, name, bases, attrs, **over):
print(
"Metaclass M.__init__",
name,
bases,
displayable(attrs),
displayable(over),
)
super().__init__(name, bases, attrs)
def __prepare__(metacls, bases, **over): # @NoSelf
print("Metaclass M.__prepare__", metacls, bases, displayable(over))
return OrderedDict()
print("Called", m)
return M
def d():
print("Called", d)
return 1
def e():
print("Called", e)
return 2
class C1(a(), b(), other=d(), metaclass=m(), yet_other=e()):
import sys
# TODO: Enable this.
# print("C1 locals type is", type(sys._getframe().f_locals))
print("OK, class created", C1)
print("Attribute C1.__dict__ has type", type(C1.__dict__))
print("Function local classes can be made global and get proper __qualname__:")
def someFunctionWithLocalClassesMadeGlobal():
# Affects __qualname__ only in Python3.4 or higher, not in Python3.2
global C
class C:
pass
class D:
pass
try:
print("Nested class qualname is", D.__qualname__)
except AttributeError:
# Python3.2
pass
try:
print("Local class made global qualname is", C.__qualname__)
except AttributeError:
pass
someFunctionWithLocalClassesMadeGlobal()
print("Function in a class with private name")
class someClassWithPrivateArgumentNames:
def f(self, *, __kw: 1):
pass
print(someClassWithPrivateArgumentNames.f.__annotations__)
print("OK.")
Nuitka-0.6.19.1/tests/basics/PrintFuture.py 0000600 0003721 0003721 00000001537 14166627112 025544 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("hallo welt", end=", ")
print("this is the end")
Nuitka-0.6.19.1/tests/basics/GeneratorExpressions.py 0000600 0003721 0003721 00000013226 14166627112 027444 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Generator expression tests
"""
from __future__ import print_function
import inspect
print("Generator expression that demonstrates the timing:")
def iteratorCreationTiming():
def getIterable(x):
print("Getting iterable", x)
return Iterable(x)
class Iterable:
def __init__(self, x):
self.x = x # pylint: disable=invalid-name
self.values = list(range(x))
self.count = 0
def __iter__(self):
print("Giving iterator now", self.x)
return self
def __next__(self):
print("Next of", self.x, "is", self.count)
if len(self.values) > self.count:
self.count += 1
return self.values[self.count - 1]
else:
print("Raising StopIteration for", self.x)
raise StopIteration
# Python2/3 compatibility.
next = __next__
def __del__(self):
print("Deleting", self.x)
gen = ((y, z) for y in getIterable(3) for z in getIterable(2))
print("Using generator", gen)
next(gen)
res = tuple(gen)
print(res)
print("*" * 20)
try:
next(gen)
except StopIteration:
print("Usage past end gave StopIteration exception as expected.")
try:
print("Generator state then is", inspect.getgeneratorstate(gen))
except AttributeError:
pass
print("Its frame is now", gen.gi_frame)
print("Early aborting generator:")
gen2 = ((y, z) for y in getIterable(3) for z in getIterable(2))
del gen2
iteratorCreationTiming()
print("Generator expressions that demonstrate the use of conditions:")
print(tuple(x for x in range(8) if x % 2 == 1))
print(tuple(x for x in range(8) if x % 2 == 1 for z in range(8) if z == x))
print(tuple(x for (x, y) in zip(list(range(2)), list(range(4)))))
print("Directory of generator expressions:")
for_dir = (x for x in [1])
gen_dir = dir(for_dir)
print(sorted(g for g in gen_dir))
def genexprSend():
x = (x for x in range(9))
print("Sending too early:")
try:
x.send(3)
except TypeError as e:
print("Gave expected TypeError with text:", e)
try:
z = next(x)
except StopIteration as e:
print("Gave expected (3.10) StopIteration with text:", repr(e))
else:
print("Next return value (pre 3.10)", z)
try:
y = x.send(3)
except StopIteration as e:
print("Gave expected (3.10) StopIteration with text:", repr(e))
else:
print("Send return value", y)
try:
print("And then next gave", next(x))
except StopIteration as e:
print("Gave expected (3.10) StopIteration with text:", repr(e))
print("Throwing an exception to it.")
try:
x.throw(2)
assert False
except TypeError as e:
print("Gave expected TypeError:", e)
print("Throwing an exception to it.")
try:
x.throw(ValueError(2))
except ValueError as e:
print("Gave expected ValueError:", e)
try:
next(x)
print("Next worked even after thrown error")
except StopIteration as e:
print("Gave expected stop iteration after throwing exception in it:", e)
print("Throwing another exception from it.")
try:
x.throw(ValueError(5))
except ValueError as e:
print("Gave expected ValueError with text:", e)
print("Generator expressions have send too:")
genexprSend()
def genexprClose():
x = (x for x in range(9))
print("Immediate close:")
x.close()
print("Closed once")
x.close()
print("Closed again without any trouble")
genexprClose()
def genexprThrown():
def checked(z):
if z == 3:
raise ValueError
return z
x = (checked(x) for x in range(9))
try:
for count, value in enumerate(x):
print(count, value)
except ValueError:
print(count + 1, ValueError)
try:
next(x)
print(
"Allowed to do next() after raised exception from the generator expression"
)
except StopIteration:
print("Exception in generator, disallowed next() afterwards.")
genexprThrown()
def nestedExpressions():
a = [x for x in range(10)]
b = (x for x in (y for y in a))
print("nested generator expression", list(b))
nestedExpressions()
def lambdaGenerators():
a = 1
x = lambda: (yield a)
print("Simple lambda generator", x, x(), list(x()))
y = lambda: ((yield 1), (yield 2))
print("Complex lambda generator", y, y(), list(y()))
lambdaGenerators()
def functionGenerators():
# Like lambdaGenerators, to show how functions behave differently if at all.
a = 1
def x():
yield a
print("Simple function generator", x, x(), list(x()))
def y():
yield ((yield 1), (yield 2))
print("Complex function generator", y, y(), list(y()))
functionGenerators()
Nuitka-0.6.19.1/tests/basics/Slots.py 0000600 0003721 0003721 00000003136 14166627112 024356 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
class W1(object):
def __init__(self):
self.__hidden = 5
class W2(object):
__slots__ = ["__hidden"]
def __init__(self):
self.__hidden = 5
class _W1(object):
def __init__(self):
self.__hidden = 5
class _W2(object):
__slots__ = ["__hidden"]
def __init__(self):
self.__hidden = 5
class a_W1(object):
def __init__(self):
self.__hidden = 5
class a_W2(object):
__slots__ = ["__hidden"]
def __init__(self):
self.__hidden = 5
class W1_(object):
def __init__(self):
self.__hidden = 5
class W2_(object):
__slots__ = ["__hidden"]
def __init__(self):
self.__hidden = 5
for w in (W1, W2, _W1, _W2, a_W1, a_W2, W1_, W2_):
try:
print(w)
print(dir(w))
a = w()
except AttributeError:
print("bug in %s" % w)
Nuitka-0.6.19.1/tests/basics/FunctionObjects.py 0000600 0003721 0003721 00000003174 14166627112 026353 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that covers attributes if function objects.
"""
from __future__ import print_function
def func(_arg1, _arg2, _arg3, **_star):
""" Some documentation. """
print("Starting out: func, __name__:", func, func.__name__)
print("Changing its name:")
func.__name__ = "renamed"
print("With new name: func, __name__:", func, func.__name__)
print("Documentation initially:", func.__doc__)
print("Changing its doc:")
func.__doc__ = "changed doc" + chr(0) + " with 0 character"
print("Documentation updated:", repr(func.__doc__))
print("Setting its dict")
func.my_value = "attached value"
print("Reading its dict", func.my_value)
print("__code__ dir")
print(dir(func.__code__))
def func2(_arg1, arg2="default_arg2", arg3="default_arg3"):
x = arg2 + arg3
return x
print("func __defaults__", func2.__defaults__)
print("function varnames", func2.__code__.co_varnames)
Nuitka-0.6.19.1/tests/basics/TryExceptFrames.py 0000600 0003721 0003721 00000004401 14166627112 026333 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
def displayDict(d):
if "__loader__" in d:
d = dict(d)
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d = dict(d)
d["__file__"] = "<__file__ removed>"
import pprint
return pprint.pformat(d)
counter = 1
class X:
def __init__(self):
global counter
self.counter = counter
counter += 1
def __del__(self):
print("X.__del__ occurred", self.counter)
def raising(doit):
_x = X()
def nested():
if doit:
1 / 0
try:
return nested()
except ZeroDivisionError:
print("Changing closure variable value.")
# This is just to prove that closure variables get updates in frame
# locals.
doit = 5
raise
# Call it without an exception
raising(False)
def catcher():
try:
raising(True)
except ZeroDivisionError:
print("Catched.")
print("Top traceback code is '%s'." % sys.exc_info()[2].tb_frame.f_code.co_name)
print(
"Second traceback code is '%s'."
% sys.exc_info()[2].tb_next.tb_frame.f_code.co_name
)
print(
"Third traceback code is '%s'."
% sys.exc_info()[2].tb_next.tb_next.tb_frame.f_code.co_name
)
print(
"Third traceback locals (function) are",
displayDict(sys.exc_info()[2].tb_next.tb_next.tb_frame.f_locals),
)
catcher()
print("Good bye.")
Nuitka-0.6.19.1/tests/basics/ComparisonChains.py 0000600 0003721 0003721 00000010323 14166627112 026506 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Comparison chains are multiple comparisons in one expression.
"""
from __future__ import print_function
# pylint: disable=redefined-outer-name
def simple_comparisons(x, y):
if "a" <= x <= y <= "z":
print("One")
if "a" <= x <= "z":
print("Two")
if "a" <= x > "z":
print("Three")
print("Simple comparisons:")
simple_comparisons("c", "d")
def side_effect():
print("")
return 7
def side_effect_comparisons():
print("Should have side effect:")
print(1 < side_effect() < 9)
print("Should not have side effect due to short circuit:")
print(3 < 2 < side_effect() < 9)
print("Check for expected side effects only:")
side_effect_comparisons()
def function_torture_is():
a = (1, 2, 3)
for x in a:
for y in a:
for z in a:
print(x, y, z, ":", x is y is z, x is not y is not z)
function_torture_is()
print("Check if lambda can have expression chains:", end="")
def function_lambda_with_chain():
a = (1, 2, 3)
x = lambda x: x[0] < x[1] < x[2]
print("lambda result is", x(a))
function_lambda_with_chain()
print("Check if generators can have expression chains:", end="")
def generator_function_with_chain():
x = (1, 2, 3)
yield x[0] < x[1] < x[2]
print(list(generator_function_with_chain()))
print("Check if list contractions can have expression chains:", end="")
def contraction_with_chain():
return [x[0] < x[1] < x[2] for x in [(1, 2, 3)]]
print(contraction_with_chain())
print("Check if generator expressions can have expression chains:", end="")
def genexpr_with_chain():
return (x[0] < x[1] < x[2] for x in [(1, 2, 3)])
print(list(genexpr_with_chain()))
print("Check if class bodies can have expression chains:", end="")
class ClassWithComparisonChainInBody:
x = (1, 2, 3)
print(x[0] < x[1] < x[2])
x = (1, 2, 3)
print(x[0] < x[1] < x[2])
class CustomOps(int):
def __lt__(self, other):
print("enter <", self, other)
return True
def __gt__(self, other):
print("enter >", self, other)
return False
print("Custom ops, to enforce chain eval order and short circuit:", end="")
print(CustomOps(7) < CustomOps(8) > CustomOps(6))
print("Custom ops, doing short circuit:", end="")
print(CustomOps(8) > CustomOps(7) < CustomOps(6))
def inOperatorChain():
print("In operator chains:")
print(3 in [3, 4] in [[3, 4]])
print(3 in [3, 4] not in [[3, 4]])
if 3 in [3, 4] in [[3, 4]]:
print("Yes")
else:
print("No")
if 3 in [3, 4] not in [[3, 4]]:
print("Yes")
else:
print("No")
inOperatorChain()
# Make sure the values are called and order is correct:
class TracingLessThan(object):
def __init__(self, name, value):
self.name = name
self.value = value
def __repr__(self):
return "" % (self.name, self.value)
def __lt__(self, other):
print(
"less than called for:",
self,
other,
self.value,
other.value,
self.value < other.value,
)
if self.value < other.value:
print("good")
return 7
else:
print("bad")
return 0
a = TracingLessThan("a", 1)
b = TracingLessThan("b", 2)
c = TracingLessThan("c", 0)
print(a < b < c)
print("*" * 80)
a = TracingLessThan("a", 2)
b = TracingLessThan("b", 1)
c = TracingLessThan("c", 0)
print(a < b < c)
Nuitka-0.6.19.1/tests/basics/Decorators.py 0000600 0003721 0003721 00000003134 14166627112 025355 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def decorator1(f):
print("Executing decorator 1")
def deco_f():
return f() + 2
return deco_f
def decorator2(f):
print("Executing decorator 2")
def deco_f():
return f() * 2
return deco_f
# Result of function now depends on correct order of applying the decorators
@decorator1
@decorator2
def function1():
return 3
print(function1())
def deco_returner1():
print("Executing decorator returner D1")
return decorator1
def deco_returner2():
print("Executing decorator returner D2")
return decorator2
@deco_returner1()
@deco_returner2()
def function2():
return 3
print(function2())
# Same as function2, but without decorator syntax.
def function3():
return 3
function3 = deco_returner1()(deco_returner2()(function3))
print(function3())
Nuitka-0.6.19.1/tests/basics/Operators.py 0000600 0003721 0003721 00000003672 14166627112 025235 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
a = 3
b = 7
c = [7, 8]
d = 15
print("+", a + b)
print("-", a - b)
print("*", a * b)
print("/", a / b)
print("//", a // b)
print("%", b % a)
print("& (2)", a & b)
print("| (2)", a | b)
print("& (3)", a & b & d)
print("| (3)", a | b | d)
print("^ (2)", a ^ b)
print("^ (3)", a ^ b ^ d)
print("**", a ** b)
print("<<", a << b)
print(">>", b >> a)
print("in", b in c)
print("not in", b not in c)
print("<", a < b)
print(">", a > b)
print("==", a == b)
print("<=", a <= b)
print(">=", a >= b)
print("!=", a != b)
print("is", a is b)
print("is not", a is not b)
print("~", ~b)
print("-", -b)
print("+", +b)
l = {("a", "c"): "a,c", "b": 2, "c": 3, "d": 4}
l["l",] = "6"
print("Extended slicing:")
print("Should be a,c:", l["a", "c"])
print("Short form of extended slicing:")
d = {}
# d[1] = 1
d[1,] = 2
d[1, 2] = 3
d[1, 2, 3] = 4
L = list(d)
L.sort()
print(L)
s = "Some information"
ss = s[-1]
print("Constant subscript of string", ss)
print("Slicing on a list:")
l = [1, 3, 5, 7, 11, 13, 17]
print(l[None:None])
n = None
print(l[n:n])
print(l[3:n])
print(l[n:3])
value = None
try:
x = value[1]
except Exception as e:
print("Indexing None gives", repr(e))
Nuitka-0.6.19.1/tests/basics/ExceptionRaising32.py 0000600 0003721 0003721 00000001701 14166627112 026666 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def raisy():
raise ValueError() from None
try:
print("Raising exception in a function 'from None':")
raisy()
except (ValueError, TypeError) as e:
print("Caught as", repr(e))
Nuitka-0.6.19.1/tests/basics/Branching.py 0000600 0003721 0003721 00000007730 14166627112 025151 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Some random branching to cover most common cases. """
from __future__ import print_function
def branchingFunction(a, b, c):
print("branchingFunction:", a, b, c)
print("a or b", a or b)
print("a and b", a and b)
print("not a", not a)
print("not b", not b)
print("Simple branch with both branches")
if a:
l = "YES"
else:
l = "NO"
print(a, "->", l)
print("Simple not branch with both branches")
if not a:
l = "YES"
else:
l = "NO"
print(not a, "->", l)
print("Simple branch with a nested branch in else path:")
if a:
m = "yes"
else:
if True:
m = "no"
print(a, "->", m)
print("Triple 'and' chain:")
v = "NO"
if a and b and c:
v = "YES"
print(a, b, c, "->", v)
print("Triple or chain:")
k = "NO"
if a or b or c:
k = "YES"
print(a, b, c, "->", k)
print("Nested 'if not' chain:")
p = "NO"
if not a:
if not b:
p = "YES"
print("not a, not b", not a, not b, "->", p)
print("or condition in braces:")
q = "NO"
if a or b:
q = "YES"
print("(a or b) ->", q)
print("Braced if not with two 'or'")
if not (a or b or c):
q = "YES"
else:
q = "NO"
print("not (a or b or c)", q)
print("Braced if not with one 'or'")
q = "NO"
if not (b or b):
q = "YES"
print("not (b or b)", q)
print("Expression a or b", a or b)
print("Expression not(a or b)", not (a or b))
print("Expression a and (b+5)", a and (b + 5))
print("Expression (b if b else 2)", (b if b else 2))
print("Expression (a and (b if b else 2))", (a and (b if b else 2)))
print("Braced if not chain with 'and' and conditional expression:")
if not (a and (b if b else 2)):
print("oki")
print("Nested if chain with outer else:")
d = 1
if a:
if b or c:
if d:
print("inside nest")
else:
print("outer else")
print("Complex conditional expression:")
v = (3 if a + 1 else 0) or (b or (c * 2 if c else 6) if b - 1 else a and b and c)
print(v)
if True:
print("Predictable branch taken")
branchingFunction(1, 0, 3)
x = 3
def optimizationVictim():
if x:
pass
else:
pass
if x:
pass
pass
optimizationVictim()
def dontOptimizeSideEffects():
print(
"Lets see, if conditional expression in known true values are correctly handled:"
)
def returnTrue():
print("function 'returnTrue' was called as expected")
return True
def returnFalse():
print("function 'returnFalse' should not have beeen called")
return False
if (returnTrue() or returnFalse(),):
print("Taken branch as expected.")
else:
print("Bad branch taken.")
dontOptimizeSideEffects()
def dontOptimizeTruthCheck():
class A:
def __nonzero__(self):
raise ValueError
__bool__ = __nonzero__
a = A()
if a:
pass
try:
print("Check that branch conditions are not optimized way: ", end="")
dontOptimizeTruthCheck()
print("FAIL.")
except ValueError:
print("OK.")
Nuitka-0.6.19.1/tests/basics/OrderChecks.py 0000600 0003721 0003721 00000035067 14166627112 025456 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def separator():
print("*" * 80)
def dictOrderCheck():
def key1():
print("key1 called")
return 1
def key2():
print("key2 called")
return 2
def value1():
print("value1 called")
return 11
def value2():
print("value2 called")
return 22
print("Checking order of calls in dictionary creation from callables:")
print({key1(): value1(), key2(): value2()})
try:
(1 / 0)[1.0j / 0] = 1.0 / 0
except ZeroDivisionError as e:
print("Expected exception caught:", repr(e))
try:
(1 / 0)[1.0 / 0] = 1
except ZeroDivisionError as e:
print("Expected exception caught:", repr(e))
try:
(1 / 0)[1] = 1.0 / 0
except ZeroDivisionError as e:
print("Expected exception caught:", repr(e))
def listOrderCheck():
def value1():
print("value1 called")
return 11
def value2():
print("value2 called")
return 22
print([value1(), value2()])
def sliceOrderCheck():
print("Slices:")
d = list(range(10))
def lvalue():
print("lvalue", end=" ")
return d
def rvalue():
print("rvalue", end=" ")
return range(2)
def rvalue4():
print("rvalue", end=" ")
return range(4)
def low():
print("low", end=" ")
return 0
def high():
print("high", end=" ")
return 4
def step():
print("step", end=" ")
return 2
print("Complex slice lookup:", end=" ")
print(lvalue()[low() : high() : step()])
print("Complex slice assignment:", end=" ")
lvalue()[low() : high() : step()] = rvalue()
print(d)
print("Complex slice del:", end=" ")
del lvalue()[low() : high() : step()]
print(d)
print("Complex inplace slice operation", end=" ")
# TODO: This gives an error in CPython, but not in Nuitka.
# lvalue()[ low() : high() : step() ] += rvalue()
print(d)
d = list(range(10))
print("Simple slice lookup", end=" ")
print(lvalue()[low() : high()])
print("Simple slice assignment", end=" ")
lvalue()[3 + low() : 3 + high()] = rvalue()
print(d)
print("Simple slice del", end=" ")
del lvalue()[3 + low() : 3 + high()]
print(d)
print("Simple inplace slice operation", end=" ")
lvalue()[low() : high()] += rvalue4()
print(d)
def subscriptOrderCheck():
print("Subscripts:")
d = {}
def lvalue():
print("lvalue", end=" ")
return d
def rvalue():
print("rvalue", end=" ")
return 2
def subscript():
print("subscript", end=" ")
return 1
print("Assigning subscript:")
lvalue()[subscript()] = rvalue()
print(d)
print("Lookup subscript:")
print(lvalue()[subscript()])
print("Deleting subscript:")
del lvalue()[subscript()]
print(d)
def attributeOrderCheck():
def lvalue():
print("lvalue", end=" ")
return lvalue
def rvalue():
print("rvalue", end=" ")
return 2
print("Attribute assignment order:")
lvalue().xxx = rvalue()
print("Assigned was indeed:", lvalue.xxx)
print("Checking attribute assignment to unassigned value from unassigned:")
try:
undefined_global_zzz.xxx = undefined_global_yyy
except Exception as e:
print("Expected exception caught:", repr(e))
else:
assert False
try:
(1 / 0).x = 1.0 / 0
except ZeroDivisionError as e:
print("Expected exception caught:", repr(e))
def compareOrderCheck():
def lvalue():
print("lvalue", end=" ")
return 1
def rvalue():
print("rvalue", end=" ")
return 2
print("Comparisons:")
print("==", lvalue() == rvalue())
print("<=", lvalue() <= rvalue())
print(">=", lvalue() >= rvalue())
print("!=", lvalue() != rvalue())
print(">", lvalue() > rvalue())
print("<", lvalue() < rvalue())
print("Comparison used in bool context:")
print("==", "yes" if lvalue() == rvalue() else "no")
print("<=", "yes" if lvalue() <= rvalue() else "no")
print(">=", "yes" if lvalue() >= rvalue() else "no")
print("!=", "yes" if lvalue() != rvalue() else "no")
print(">", "yes" if lvalue() > rvalue() else "no")
print("<", "yes" if lvalue() < rvalue() else "no")
def operatorOrderCheck():
def left():
print("left operand", end=" ")
return 1
def middle():
print("middle operand", end=" ")
return 3
def right():
print("right operand", end=" ")
return 2
print("Operations:")
print("+", left() + middle() + right())
print("-", left() - middle() - right())
print("*", left() * middle() * right())
print("/", left() / middle() / right())
print("%", left() % middle() % right())
print("**", left() ** middle() ** right())
def generatorOrderCheck():
print("Generators:")
def default1():
print("default1", end=" ")
return 1
def default2():
print("default2", end=" ")
return 2
def default3():
print("default3", end=" ")
return 3
def value(x):
print("value", x, end=" ")
return x
def generator(a=default1(), b=default2(), c=default3()):
print("generator entry")
yield value(a)
yield value(b)
yield value(c)
print("generator exit")
result = list(generator())
print("Result", result)
def classOrderCheck():
print("Checking order of class constructions:")
class B1:
pass
class B2:
pass
def base1():
print("base1", end=" ")
return B1
def base2():
print("base2", end=" ")
return B2
def deco1(cls):
print("deco1", end=" ")
return cls
def deco2(cls):
print("deco2")
return B2
@deco2
@deco1
class X(base1(), base2()):
print("class body", end=" ")
print
def inOrderCheck():
print("Checking order of in operator:")
def container():
print("container", end=" ")
return [3]
def searched():
print("searched", end=" ")
return 3
print("in:", searched() in container())
print("not in:", searched() not in container())
def unpackOrderCheck():
class TraceRelease:
def __init__(self, value):
self.value = value
def __del__(self):
print("Deleting iteration value", self.value)
pass
print("Unpacking values:")
class Iterable:
def __init__(self):
self.consumed = 2
def __iter__(self):
return Iterable()
def __del__(self):
print("Deleted iterable with", self.consumed)
def next(self):
print("Next with state", self.consumed)
if self.consumed:
self.consumed -= 1
else:
raise StopIteration
return TraceRelease(self.consumed)
__next__ = next
iterable = Iterable()
class RejectAttributeOwnership:
def __setattr__(self, key, value):
print("Setting", key, value.value)
try:
RejectAttributeOwnership().x, RejectAttributeOwnership().y = a, b = iterable
except Exception as e:
print("Caught", repr(e))
return a, b
def superOrderCheck():
print("Built-in super:")
try:
super(zzz, xxx)
except Exception as e:
print("Expected exception caught super 2", repr(e))
def isinstanceOrderCheck():
print("Built-in isinstance:")
try:
isinstance(zzz, xxx)
except Exception as e:
print("Expected exception caught isinstance 2", repr(e))
def rangeOrderCheck():
print("Built-in range:")
try:
range(zzz, yyy, xxx)
except Exception as e:
print("Expected exception caught range 3", repr(e))
try:
range(zzz, xxx)
except Exception as e:
print("Expected exception caught range 2", repr(e))
def importOrderCheck():
print("Built-in __import__:")
def name():
print("name", end=" ")
def globals():
print("globals", end=" ")
def locals():
print("locals", end=" ")
def fromlist():
print("fromlist", end=" ")
def level():
print("level")
try:
__import__(name(), globals(), locals(), fromlist(), level())
except Exception as e:
print("Expected exception caught __import__ 5", repr(e))
def hasattrOrderCheck():
print("Built-in hasattr:")
try:
hasattr(zzz, yyy)
except Exception as e:
print("Expected exception caught hasattr", repr(e))
def getattrOrderCheck():
print("Built-in getattr:")
try:
getattr(zzz, yyy)
except Exception as e:
print("Expected exception caught getattr 2", repr(e))
try:
getattr(zzz, yyy, xxx)
except Exception as e:
print("Expected exception caught getattr 3", repr(e))
def default():
print("default used")
print("Default side effects:", end=" ")
print(getattr(1, "real", default()))
def typeOrderCheck():
print("Built-in type:")
try:
type(zzz, yyy, xxx)
except Exception as e:
print("Expected exception caught type 3", repr(e))
def iterOrderCheck():
print("Built-in iter:")
try:
iter(zzz, xxx)
except Exception as e:
print("Expected exception caught iter 2", repr(e))
def openOrderCheck():
print("Built-in open:")
try:
open(zzz, yyy, xxx)
except Exception as e:
print("Expected exception caught open 3", repr(e))
def unicodeOrderCheck():
print("Built-in unicode:")
try:
unicode(zzz, yyy, xxx)
except Exception as e:
print("Expected exception caught unicode", repr(e))
def longOrderCheck():
print("Built-in long:")
try:
long(zzz, xxx)
except Exception as e:
print("Expected exception caught long 2", repr(e))
def intOrderCheck():
print("Built-in int:")
try:
int(zzz, xxx)
except Exception as e:
print("Expected exception caught int", repr(e))
def nextOrderCheck():
print("Built-in next:")
try:
next(zzz, xxx)
except Exception as e:
print("Expected exception caught next 2", repr(e))
def callOrderCheck():
print("Checking nested call arguments:")
class A:
def __del__(self):
print("Doing del inner object")
def check(obj):
print("Outer function")
def p(obj):
print("Inner function")
check(p(A()))
def boolOrderCheck():
print("Checking order of or/and arguments:")
class A(int):
def __init__(self, value):
self.value = value
def __del__(self):
print("Doing del of %s" % self)
def __bool__(self):
print("Test of %s" % self)
return self.value != 0
__nonzero__ = __bool__
def __str__(self):
return "<%s %r>" % (self.__class__.__name__, self.value)
class B(A):
pass
class C(A):
pass
print("Two arguments, A or B:")
for a in range(2):
for b in range(2):
print("Case %d or %d" % (a, b))
r = A(a) or B(b)
print(r)
del r
# TODO: The order of deletion does not exactly match, which we accept for
# now.
if True:
print("Three arguments, A or B or C:")
for a in range(2):
for b in range(2):
for c in range(2):
print("Case %d or %d or %d" % (a, b, c))
r = A(a) or B(b) or C(c)
print(r)
del r
print("Two arguments, A and B:")
for a in range(2):
for b in range(2):
print("Case %d and %d" % (a, b))
r = A(a) and B(b)
print(r)
del r
# See above
if True:
print("Three arguments, A and B and C:")
for a in range(2):
for b in range(2):
for c in range(2):
print("Case %d and %d and %d" % (a, b, c))
r = A(a) and B(b) and C(c)
print(r)
del r
def comparisonChainOrderCheck():
print("Checking order of comparison chains:")
class A(int):
def __init__(self, value):
self.value = value
def __del__(self):
print("Doing del of %s" % self)
def __le__(self, other):
print("Test of %s <= %s" % (self, other))
return self.value <= other.value
def __str__(self):
return "<%s %r>" % (self.__class__.__name__, self.value)
class B(A):
pass
class C(A):
pass
# See above, not really doing it right.
if False:
print("Three arguments, A <= B <= C:")
for a in range(3):
for b in range(3):
for c in range(3):
print("Case %d <= %d <= %d" % (a, b, c))
r = A(a) <= B(b) <= C(c)
print(r)
del r
dictOrderCheck()
separator()
listOrderCheck()
separator()
subscriptOrderCheck()
separator()
attributeOrderCheck()
separator()
operatorOrderCheck()
separator()
compareOrderCheck()
separator()
sliceOrderCheck()
separator()
generatorOrderCheck()
separator()
classOrderCheck()
separator()
inOrderCheck()
separator()
unpackOrderCheck()
separator()
superOrderCheck()
separator()
isinstanceOrderCheck()
separator()
rangeOrderCheck()
separator()
importOrderCheck()
separator()
hasattrOrderCheck()
separator()
getattrOrderCheck()
separator()
typeOrderCheck()
separator()
iterOrderCheck()
separator()
openOrderCheck()
separator()
unicodeOrderCheck()
separator()
nextOrderCheck()
separator()
longOrderCheck()
separator()
intOrderCheck()
separator()
callOrderCheck()
separator()
boolOrderCheck()
separator()
comparisonChainOrderCheck()
Nuitka-0.6.19.1/tests/basics/BuiltinsTest.py 0000600 0003721 0003721 00000040620 14166627112 025702 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test that should cover sporadic usages of built-ins that we implemented.
"""
# pylint: disable=broad-except,global-variable-not-assigned,redefined-outer-name
# pylint: disable=comparison-with-itself,use-dict-literal,use-list-literal
# pylint: disable=consider-using-with,invalid-bytes-returned,unspecified-encoding
# pylint: disable=invalid-str-returned,no-self-use,unnecessary-comprehension
from __future__ import print_function
# Patch away "__file__" path in a hard to detect way. This will make sure,
# repeated calls to locals really get the same dictionary.
import os
from math import copysign
def someFunctionWritingLocals():
x = 1
r = locals()
# This is without effect on r. It doesn't mention y at all
y = 2
# This adds z to the locals, but only that.
r["z"] = 3
del x
try:
z
except Exception as e:
print("Accessing z writing to locals gives Exception", e)
return r, y
def someFunctionWritingLocalsContainingExec():
_x = 1
r = locals()
# This is without effect on r. It doesn't mention y at all
y = 2
# This adds z to the locals, but only that.
r["z"] = 3
try:
z
except Exception as e:
print("Accessing z writing to locals in exec function gives Exception", e)
return r, y
# Note: This exec is dead code, and still changes the behaviour of
# CPython, because it detects exec during parse already.
# pylint: disable=exec-used,unreachable
exec("")
print("Testing locals():")
print(someFunctionWritingLocals())
print(someFunctionWritingLocalsContainingExec())
def displayDict(d):
if "__loader__" in d:
d = dict(d)
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d = dict(d)
d["__file__"] = "<__file__ removed>"
if "__compiled__" in d:
d = dict(d)
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print("Vars on module level", displayDict(vars()))
module_locals = locals()
module_locals["__file__"] = os.path.basename(module_locals["__file__"])
del module_locals
print("Use of locals on the module level", displayDict(locals()))
def someFunctionUsingGlobals():
g = globals()
g["hallo"] = "du"
global hallo
print("hallo", hallo) # false alarm, pylint: disable=undefined-variable
print("Testing globals():")
someFunctionUsingGlobals()
print("Testing dir():")
print("Module dir", end=" ")
def someFunctionUsingDir():
q = someFunctionUsingGlobals()
print("Function dir", dir())
return q
someFunctionUsingDir()
print("Making a new type, with type() and 3 args:", end=" ")
NewClass = type("Name", (object,), {})
print(NewClass, NewClass())
print("None has type", type(None))
print(
"Constant ranges",
range(2),
range(1, 6),
range(3, 0, -1),
range(3, 8, 2),
range(5, -5, -3),
)
print("Border cases", range(0), range(-1), range(-1, 1))
print("Corner case large negative value", range(-(2 ** 100)))
print(
"Corner case with large start/end values in small range",
range(2 ** 100, 2 ** 100 + 2),
)
try:
print("Range with 0 step gives:", end=" ")
print(range(3, 8, 0))
except ValueError as e:
print(repr(e))
try:
print("Range with float:", end=" ")
print(range(1.0))
except TypeError as e:
print("Gives exception:", repr(e))
try:
print("Empty range call", end=" ")
print(range())
except TypeError as e:
print("Gives exception:", e)
print("List from iterable", list("abc"), list())
try:
print("List from sequence", end=" ")
print(list(sequence=(0, 1, 2)))
except TypeError as e:
print("Gives exception:", e)
print("Tuple from iterable", tuple("cda"), tuple())
try:
print("Tuple from sequence", end=" ")
print(tuple(sequence=(0, 1, 2)))
except TypeError as e:
print("Gives exception:", e)
print(
"Dictionary from iterable and keywords", displayDict(dict(("ab", (1, 2)), f=1, g=1))
)
print("More constant dictionaries", {"two": 2, "one": 1}, {}, dict())
g = {"two": 2, "one": 1}
print("Variable dictionary", dict(g))
print(
"Found during optimization",
dict(dict({"le": 2, "la": 1}), fu=3),
dict(named=dict({"le": 2, "la": 1})),
)
print("Floats from constants", float("3.0"), float())
try:
print("Float keyword arg", end=" ")
except TypeError as e:
print(float(x=9.0))
print("Found during optimization", float(float("3.2")), float(float(11.0)))
print(
"Complex from constants",
complex("3.0j"),
complex(real=9.0),
complex(imag=9.0),
complex(1, 2),
complex(),
)
print(
"Found during optimization",
complex(float("3.2")),
complex(real=float(11.0)),
complex(imag=float(11.0)),
)
print("Strs from constants", str("3.3"), str(object=9.1), str())
print("Found during optimization", str(float("3.3")), str(object=float(12.0)))
print("Bools from constants", bool("3.3"), bool(0), bool())
print("Found during optimization", bool(float("3.3")), bool(range(0)))
print("Ints from constants", int("3"), int("f", 16), int("0101", base=2), int(0), int())
try:
print("Int keyword arg1", end=" ")
print(int(x="9"))
print(int(x="e", base=16))
except TypeError as e:
print("Gives exception:", e)
print("Found ints during optimization", int(int("3")), int(int(0.0)))
try:
print(
"Longs from constants",
long("3"),
long(x="9"),
long("f", 16),
long(x="e", base=16),
long("0101", base=2),
long(0),
long(),
)
print("Found longs during optimization", long(long("3")), long(x=long(0.0)))
except NameError:
print("Python3 has no long type.")
try:
print("Int with only base", int(base=2), end=" ")
except Exception as e:
print("Caused", repr(e))
else:
print("Worked")
try:
print("Int with large base", int(2, 37), end=" ")
except Exception as e:
print("Caused", repr(e))
else:
print("Worked")
try:
print("Long with only base", int(base=2), end=" ")
except Exception as e:
print("Caused", repr(e))
else:
print("Worked")
print("Oct from constants", oct(467), oct(0))
print("Found during optimization", oct(int("3")))
print("Hex from constants", hex(467), hex(0))
print("Found during optimization", hex(int("3")))
print("Bin from constants", bin(467), bin(0))
print("Found during optimization", bin(int("3")))
try:
int(1, 2, 3)
except Exception as e:
print("Too many args gave", repr(e))
try:
int(y=1)
except Exception as e:
print("Wrong arg", repr(e))
f = 3
print("Unoptimized call of int", int("0" * f, base=16))
try:
d = {"x": "12", "base": 8}
print("Dict star argument call of int", end=" ")
print(int(**d))
except TypeError as e:
print("Gives exception:", e)
base = 16
try:
value = unicode("20")
except NameError:
print("Python3: Has unicode by default.")
value = "20"
print("Unoptimized calls of int with unicode args", int(value, base), int(value))
base = 37
try:
print("Int with large base", int(2, base), end=" ")
except Exception as e:
print("Caused", repr(e))
else:
print("Worked")
try:
print(chr())
except Exception as e:
print("Disallowed without args", repr(e))
try:
print(ord())
except Exception as e:
print("Disallowed without args", repr(e))
try:
print(ord(s=1))
except Exception as e:
print("Disallowed keyword args", repr(e))
try:
print(ord(1, 2))
except Exception as e:
print("Too many plain args", repr(e))
try:
print(ord(1, s=2))
except Exception as e:
print("Too many args, some keywords", repr(e))
try:
print(sum())
except Exception as e:
print("Disallowed without args", repr(e))
x = range(17)
print("Sum of range(17) is", sum(x))
print("Sum of range(17) starting with 5 is", sum(x, 5))
try:
print(str("1", offer=2))
except Exception as e:
print("Too many args, some keywords", repr(e))
# TODO: This is calls, not really builtins.
a = 2
print("Can optimize the star list argness away", int(*(a,)), end=" ")
print("Can optimize the empty star list arg away", int(*tuple()), end=" ")
print("Can optimize the empty star dict arg away", int(**dict()))
print("Dict building with keyword arguments", dict(), dict(a=f))
print(
"Dictionary entirely from constant args",
displayDict(dict(q="Guido", w="van", e="Rossum", r="invented", t="Python", y="")),
)
a = 5
print("Instance check recognises", isinstance(a, int))
try:
print("Instance check with too many arguments", isinstance(a, float, int))
except Exception as e:
print("Too many args", repr(e))
try:
print("Instance check with too many arguments", isinstance(a))
except Exception as e:
print("Too few args", repr(e))
def usingIterToCheckIterable(a):
try:
iter(a)
except TypeError:
print("not iterable")
else:
print("ok")
usingIterToCheckIterable(1)
print(
"Nested constant, dict inside a list, referencing a built-in compile time constant",
end=" ",
)
print([dict(type=int)])
print("nan and -nan sign checks:")
print("nan:", float("nan"), copysign(1.0, float("nan")))
print("-nan:", float("-nan"), copysign(1.0, float("-nan")))
print("Using != to detect nan floats:")
a = float("nan")
if a != a:
print("is nan")
else:
print("isn't nan")
print("inf and -inf sign checks:")
print("inf:", float("inf"), copysign(1.0, float("inf")))
print("-inf:", float("-inf"), copysign(1.0, float("-inf")))
class CustomStr(str):
pass
class CustomBytes(bytes):
pass
class CustomByteArray(bytearray):
pass
values = [
b"100",
b"",
bytearray(b"100"),
CustomStr("100"),
CustomBytes(b"100"),
CustomByteArray(b"100"),
]
for x in values:
try:
print("int", repr(x), int(x), int(x, 2))
except (TypeError, ValueError) as e:
print("caught", repr(e))
try:
print("long", repr(x), long(x), long(x, 2))
except (TypeError, ValueError) as e:
print("caught", repr(e))
except NameError:
print("Python3 has no long")
z = range(5)
try:
next(z)
except TypeError as e:
print("caught", repr(e))
try:
open()
except TypeError as e:
print("Open without arguments gives", repr(e))
print("Type of id values:", type(id(id)))
class OtherBytesSubclass(bytes):
pass
class BytesOverload:
def __bytes__(self):
return OtherBytesSubclass()
b = BytesOverload()
v = bytes(b)
if type(v) is bytes:
print("Bytes overload ineffective (expected for Python2)")
elif isinstance(v, bytes):
print("Bytes overload successful.")
else:
print("Oops, must not happen.")
class OtherFloatSubclass(float):
pass
class FloatOverload:
def __float__(self):
return OtherFloatSubclass()
b = FloatOverload()
v = float(b)
if type(v) is float:
print("Float overload ineffective (must not happen)")
elif isinstance(v, float):
print("Float overload successful.")
else:
print("Oops, must not happen.")
class OtherStrSubclass(str):
pass
class StrOverload:
def __str__(self):
return OtherStrSubclass()
b = StrOverload()
v = str(b)
if type(v) is str:
print("Str overload ineffective (must not happen)")
elif isinstance(v, str):
print("Str overload successful.")
else:
print("Oops, must not happen.")
if str is bytes:
# makes sense with Python2 only.
class OtherUnicodeSubclass(unicode): # pylint: disable=undefined-variable
pass
class UnicodeOverload:
def __unicode__(self):
return OtherUnicodeSubclass()
b = UnicodeOverload()
v = unicode(b) # pylint: disable=undefined-variable
if type(v) is unicode: # pylint: disable=undefined-variable
print("Unicode overload ineffective (must not happen)")
elif isinstance(v, unicode): # pylint: disable=undefined-variable
print("Unicode overload successful.")
else:
print("Oops, must not happen.")
class OtherIntSubclass(int):
pass
class IntOverload:
def __int__(self):
return OtherIntSubclass()
b = IntOverload()
v = int(b)
if type(v) is int:
print("Int overload ineffective (must not happen)")
elif isinstance(v, int):
print("Int overload successful.")
else:
print("Oops, must not happen.")
if str is bytes:
# Makes sense with Python2 only, no long for Python3.
class OtherLongSubclass(long): # pylint: disable=undefined-variable
pass
class LongOverload:
def __long__(self):
return OtherLongSubclass()
b = LongOverload()
v = long(b) # pylint: disable=undefined-variable
if type(v) is long: # pylint: disable=undefined-variable
print("Long overload ineffective (must not happen)")
elif isinstance(v, long): # pylint: disable=undefined-variable
print("Long overload successful.")
else:
print("Oops, must not happen.")
class OtherComplexSubclass(complex):
pass
class ComplexOverload:
def __complex__(self):
return OtherComplexSubclass()
b = ComplexOverload()
v = complex(b)
if type(v) is complex:
print("Complex overload ineffective (must happen)")
elif isinstance(v, complex):
print("Oops, must not happen.")
else:
print("Oops, must not happen.")
print("Tests for abs():")
print(abs(-(1000000 ** 10)))
print(abs(len([1, 2, 3])))
print(abs(-100))
print(abs(float("nan")))
print("abs() with list:")
try:
print(abs([1, 2]))
except Exception as e:
print("caught ", repr(e))
# Making a condition >42 incrementally True
def S1():
print("Yielding 40")
yield 40
print("Yielding 60")
yield 60
print("Yielding 30")
yield 30
# Making a condition >42 incrementally False
def S2():
print("Yielding 60")
yield 60
print("Yielding 40")
yield 40
print("Yielding 30")
yield 30
# Test for "all" built-in
print(all(x > 42 for x in S1()))
print(all(x > 42 for x in S2()))
print("Disallowed all() without args:")
try:
print(all())
except Exception as e:
print("caught ", repr(e))
print("all() with float not iterable:")
try:
print(all(1.0))
except Exception as e:
print("caught ", repr(e))
print("all() with float type not iterable:")
try:
print(any(float))
except Exception as e:
print("caught ", repr(e))
print("all with compile time lists:")
print(all([None, None, None]))
print(all([None, 4, None]))
print(all([]))
print(all([0] * 20000))
print(all([0] * 255))
print("all with compile time ranges:")
print(all(range(1, 10000)))
print(all(range(10000)))
print(all(range(2, 999, 4)))
print("all with compile time strings and bytes:")
print(all("Nuitka rocks!"))
print(all("string"))
print(all(u"unicode"))
print(all(b"bytes"))
print(all(b"bytes\0"))
print(any(x > 42 for x in S1()))
print(any(x > 42 for x in S2()))
print("Disallowed any() without args:")
try:
print(any())
except Exception as e:
print("caught ", repr(e))
print("any() with float not iterable:")
try:
print(any(1.0))
except Exception as e:
print("caught ", repr(e))
print("any() with float type not iterable:")
try:
print(any(float))
except Exception as e:
print("caught ", repr(e))
print("any() with sets:")
print(any(set([0, 1, 2, 3, 3])))
print(any({1: "One", 2: "Two"}))
print("any with compile time lists:")
print(any([None, None, None]))
print(any([None, 4, None]))
print(any([]))
print(any([0] * 20000))
print(any([0] * 255))
print("any with compile time ranges:")
print(any(range(1, 10000)))
print(any(range(10000)))
print(any(range(2, 999, 4)))
print("any with compile time strings and bytes:")
print(any("Nuitka rocks!"))
print(any("string"))
print(any(u"unicode"))
print(any(b"bytes"))
print(any(b"bytes\0"))
print("Tests for zip():")
print(zip("abc", "cdd"))
print(zip([1, 2, 3], [2, 3, 4]))
print(zip([1, 2, 3], "String"))
try:
zip(1, "String")
except TypeError as e:
print("Occured", repr(e))
print(zip())
x = [(u, v) for (u, v) in zip(range(8), reversed(range(8)))]
print(x)
for v in zip([1, 2, 3], "String"):
print(v)
Nuitka-0.6.19.1/tests/basics/ParameterErrors32.py 0000600 0003721 0003721 00000003553 14166627112 026537 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def kwfunc(a, *, k):
pass
print("Call function with mixed arguments with too wrong keyword argument.")
try:
kwfunc(k=3, b=5)
except TypeError as e:
print(repr(e))
print("Call function with mixed arguments with too little positional arguments.")
try:
kwfunc(k=3)
except TypeError as e:
print(repr(e))
print("Call function with mixed arguments with too little positional arguments.")
try:
kwfunc(3)
except TypeError as e:
print(repr(e))
print("Call function with mixed arguments with too many positional arguments.")
try:
kwfunc(1, 2, k=3)
except TypeError as e:
print(repr(e))
def kwfuncdefaulted(a, b=None, *, c=None):
pass
print(
"Call function with mixed arguments and defaults but too many positional arguments."
)
try:
kwfuncdefaulted(1, 2, 3)
except TypeError as e:
print(repr(e))
def kwfunc2(a, *, k, l, m):
pass
print(
"Call function with mixed arguments with too little positional and keyword-only arguments."
)
try:
kwfunc2(1, l=2)
except TypeError as e:
print(repr(e))
try:
kwfunc2(1)
except TypeError as e:
print(repr(e))
Nuitka-0.6.19.1/tests/basics/OrderChecks27.py 0000600 0003721 0003721 00000003443 14166627112 025620 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def setOrderCheck():
print("Checking order of set literals:")
def one():
print("one")
return "one"
def two():
print("two")
return "two"
return {one(), two()}
def raiseOrderCheck():
print("Checking order of raises:")
def exception_type():
print("exception_type", end="")
return ValueError
def exception_value():
print("exception_value", end="")
return 1
def exception_tb():
print("exception_value", end="")
return None
print("3 args", end="")
try:
raise exception_type(), exception_value(), exception_tb()
except Exception as e:
print("caught", repr(e))
print("2 args", end="")
try:
raise exception_type(), exception_value()
except Exception as e:
print("caught", repr(e))
print("1 args", end="")
try:
raise exception_type()
except Exception as e:
print("caught", repr(e))
setOrderCheck()
raiseOrderCheck()
Nuitka-0.6.19.1/tests/basics/TryExceptFinally.py 0000600 0003721 0003721 00000004343 14166627112 026521 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"Some doc"
from __future__ import print_function
def one():
return 1
def tryScope1(x):
try:
try:
x += one()
finally:
print("Finally is executed")
try:
_z = one()
finally:
print("Deep Nested finally is executed")
except:
print("Exception occurred")
else:
print("No exception occurred")
tryScope1(1)
print("*" * 20)
tryScope1([1])
def tryScope2(x, someExceptionClass):
try:
x += 1
except someExceptionClass as e:
print("Exception class from argument occurred:", someExceptionClass, repr(e))
else:
print("No exception occurred")
def tryScope3(x):
if x:
try:
x += 1
except TypeError:
print("TypeError occurred")
else:
print("Not taken")
print("*" * 20)
tryScope2(1, TypeError)
tryScope2([1], TypeError)
print("*" * 20)
tryScope3(1)
tryScope3([1])
tryScope3([])
print("*" * 20)
def tryScope4(x):
try:
x += 1
except:
print("exception occurred")
else:
print("no exception occurred")
finally:
print("finally obeyed")
tryScope4(1)
tryScope4([1])
def tryScope5():
import sys
print("Exception info is initially", sys.exc_info())
try:
try:
undefined_global += 1
finally:
print("Exception info in 'finally' clause is", sys.exc_info())
except:
pass
tryScope5()
Nuitka-0.6.19.1/tests/basics/Inspection.py 0000600 0003721 0003721 00000010614 14166627112 025364 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Tests uncompiled functions and compiled functions responses to inspect and isistance. """
from __future__ import print_function
import inspect
import pprint
import sys
import types
def displayDict(d, remove_keys=()):
if "__loader__" in d:
d = dict(d)
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d = dict(d)
d["__file__"] = "<__file__ removed>"
if "__compiled__" in d:
d = dict(d)
del d["__compiled__"]
for remove_key in remove_keys:
if remove_key in d:
d = dict(d)
del d[remove_key]
return pprint.pformat(d)
def compiledFunction(a, b):
pass
print("Function inspect.isfunction:", inspect.isfunction(compiledFunction))
print(
"Function isinstance types.FunctionType:",
isinstance(compiledFunction, types.FunctionType),
)
print(
"Function isinstance tuple containing types.FunctionType:",
isinstance(compiledFunction, (int, types.FunctionType)),
)
print("Compiled spec:", inspect.getargspec(compiledFunction))
print("Compiled args:", inspect.formatargspec(*inspect.getargspec(compiledFunction)))
# Even this works.
assert type(compiledFunction) == types.FunctionType
class CompiledClass:
def __init__(self):
pass
def compiledMethod(self):
pass
assert inspect.isfunction(CompiledClass) is False
assert isinstance(CompiledClass, types.FunctionType) is False
assert inspect.ismethod(compiledFunction) is False
assert inspect.ismethod(CompiledClass) is False
assert inspect.ismethod(CompiledClass.compiledMethod) == (sys.version_info < (3,))
assert inspect.ismethod(CompiledClass().compiledMethod) is True
assert bool(type(CompiledClass.compiledMethod) == types.MethodType) == (
sys.version_info < (3,)
)
print("Compiled method:", inspect.getargspec(CompiledClass().compiledMethod))
print(
"Compiled class:",
inspect.formatargspec(*inspect.getargspec(CompiledClass().compiledMethod)),
)
def compiledGenerator():
yield 1
assert inspect.isfunction(compiledGenerator) is True
assert inspect.isgeneratorfunction(compiledGenerator) is True
assert isinstance(compiledGenerator(), types.GeneratorType) is True
assert type(compiledGenerator()) == types.GeneratorType
assert isinstance(compiledGenerator, types.GeneratorType) is False
assert inspect.ismethod(compiledGenerator()) is False
assert inspect.isfunction(compiledGenerator()) is False
assert inspect.isgenerator(compiledFunction) is False
assert inspect.isgenerator(compiledGenerator) is False
assert inspect.isgenerator(compiledGenerator()) is True
def someFunction(a):
assert inspect.isframe(sys._getframe())
# print("Running frame getframeinfo()", inspect.getframeinfo(sys._getframe()))
# TODO: The locals of the frame are not updated.
# print("Running frame arg values", inspect.getargvalues(sys._getframe()))
someFunction(2)
class C:
print(
"Class locals",
displayDict(
sys._getframe().f_locals, remove_keys=("__qualname__", "__locals__")
),
)
print("Class flags", sys._getframe().f_code.co_flags)
def f():
print("Func locals", sys._getframe().f_locals)
print("Func flags", sys._getframe().f_code.co_flags)
f()
def g():
yield ("Generator object locals", sys._getframe().f_locals)
yield ("Generator object flags", sys._getframe().f_code.co_flags)
for line in g():
print(*line)
print("Generator function flags", g.__code__.co_flags)
print("Module frame locals", displayDict(sys._getframe().f_locals))
print("Module flags", sys._getframe().f_code.co_flags)
print("Module code name", sys._getframe().f_code.co_name)
print("Module frame dir", dir(sys._getframe()))
Nuitka-0.6.19.1/tests/basics/Referencing.py 0000600 0003721 0003721 00000056445 14166627112 025514 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
"""
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
from nuitka.tools.testing.Common import executeReferenceChecked
# isort:start
# Tests do all bad things:
# pylint: disable=misplaced-bare-raise,raising-bad-type,reimported,undefined-variable
# pylint: disable=broad-except,eval-used,redefined-outer-name,unused-argument,unused-variable
# pylint: disable=attribute-defined-outside-init,bare-except,lost-exception,pointless-statement
# pylint: disable=exec-used,global-statement,invalid-name,not-callable,super-init-not-called
x = 17
# Just a function return a constant. Functions don't become any smaller. Let's
# get that right.
def simpleFunction1():
return 1
# Do a bit of math with a local variable, assigning to its value and then doing
# an overwrite of that, trying that math again. This should cover local access
# a bit.
def simpleFunction2():
y = 3 * x
y = 3
return x * 2 * y
# A local function is being returned. This covers creation of local functions
# and their release. No closure variables involved yet.
def simpleFunction3():
def contained():
return x
return contained
# Again, local function being return, but this time with local variable taken
# as a closure. We use value from defaulted argument, so it cannot be replaced.
def simpleFunction4(a=1):
y = a
def contained():
return y
return contained
# Default argument and building a list as local variables. Also return them,
# so they are not optimized away.
def simpleFunction5(a=2):
c = 1
f = [a, a + c]
return c, f
def simpleFunction6():
for _b in range(6):
pass
for _c in (1, 2, 3, 4, 5, 6):
pass
def simpleFunction7(b=1):
for _b in range(6):
pass
def simpleFunction8():
c = []
c.append(x)
def simpleFunction9(a=1 * 2):
if a == a:
pass
u = None
def simpleFunction10(a=1 * 2):
x = [u for u in range(8)]
def simpleFunction11():
f = 1
while f < 8:
f += 1
v = None
def simpleFunction12():
a = [(u, v) for (u, v) in zip(range(8), range(8))]
return a
def cond():
return 1
def simpleFunction13(a=1 * 2):
pass
def simpleFunction14p(x):
try:
simpleFunction14p(1, 1) # pylint: disable=too-many-function-args
except TypeError as _e:
pass
try:
simpleFunction14p(1, 1) # pylint: disable=too-many-function-args
except TypeError:
pass
def simpleFunction14():
simpleFunction14p(3)
def simpleFunction15p(x):
try:
try:
x += 1
finally:
try:
x *= 1
finally:
_z = 1
except:
pass
def simpleFunction15():
simpleFunction15p([1])
def simpleFunction16():
class EmptyClass:
pass
return EmptyClass
def simpleFunction17():
class EmptyObjectClass:
pass
return EmptyObjectClass()
def simpleFunction18():
closured = 1
class NonEmptyClass:
def __init__(self, a, b):
self.a = a
self.b = b
inside = closured
return NonEmptyClass(133, 135)
def simpleFunction19():
lam = lambda l: l + 1
return lam(9), lam
def simpleFunction20():
try:
a = []
a[1]
except IndexError as _e:
pass
def simpleFunction21():
class EmptyBaseClass:
def base(self):
return 3
class EmptyObjectClass(EmptyBaseClass):
pass
result = EmptyObjectClass()
c = result.base()
return result, c
def simpleFunction22():
return True is False and False is not None
def simpleFunction23():
not 2
def simpleFunction24p(x):
pass
def simpleFunction24():
simpleFunction24p(x=3)
def simpleFunction25():
class X:
f = 1
def inplace_adder(b):
X.f += b
return inplace_adder(6 ** 8)
def simpleFunction26():
class X:
f = [5]
def inplace_adder(b):
X.f += b
return inplace_adder([1, 2])
def simpleFunction27():
a = {"g": 8}
def inplace_adder(b):
a["g"] += b
return inplace_adder(3)
def simpleFunction28():
a = {"g": [8], "h": 2}
def inplace_adder(b):
a["g"] += b
return inplace_adder([3, 5])
def simpleFunction29():
return "3" in "7"
def simpleFunction30():
def generatorFunction():
yield 1
yield 2
yield 3
def simpleFunction31():
def generatorFunction():
yield 1
yield 2
yield 3
a = []
for y in generatorFunction():
a.append(y)
for z in generatorFunction():
a.append(z)
def simpleFunction32():
def generatorFunction():
yield 1
gen = generatorFunction()
next(gen)
def simpleFunction33():
def generatorFunction():
a = 1
yield a
a = []
for y in generatorFunction():
a.append(y)
def simpleFunction34():
try:
raise ValueError
except:
pass
def simpleFunction35():
try:
raise ValueError(1, 2, 3)
except:
pass
def simpleFunction36():
try:
raise (TypeError, (3, x, x, x))
except TypeError:
pass
def simpleFunction37():
l = [1, 2, 3]
try:
_a, _b = l
except ValueError:
pass
def simpleFunction38():
class Base:
pass
class Parent(Base):
pass
def simpleFunction39():
class Parent(object):
pass
def simpleFunction40():
def myGenerator():
yield 1
myGenerator()
def simpleFunction41():
a = b = 2
return a, b
def simpleFunction42():
a = b = 2 * x
return a, b
def simpleFunction43():
class D:
pass
a = D()
a.b = 1
def simpleFunction47():
def reraisy():
def raisingFunction():
raise ValueError(3)
def reraiser():
raise
try:
raisingFunction()
except:
reraiser()
try:
reraisy()
except:
pass
def simpleFunction48():
class BlockExceptions:
def __enter__(self):
pass
def __exit__(self, exc, val, tb):
return True
with BlockExceptions():
raise ValueError()
template = "lala %s lala"
def simpleFunction49():
c = 3
d = 4
a = x, y = b, e = (c, d)
return a, y, b, e
b = range(10)
def simpleFunction50():
def getF():
def f():
for i in b:
yield i
return f
f = getF()
for x in range(2):
_r = list(f())
def simpleFunction51():
g = (x for x in range(9))
try:
g.throw(ValueError, 9)
except ValueError as _e:
pass
def simpleFunction52():
g = (x for x in range(9))
try:
g.throw(ValueError(9))
except ValueError as _e:
pass
def simpleFunction53():
g = (x for x in range(9))
try:
g.send(9)
except TypeError as _e:
pass
def simpleFunction54():
g = (x for x in range(9))
next(g)
try:
g.send(9)
except TypeError as _e:
pass
def simpleFunction55():
g = (x for x in range(9))
try:
g.close()
except ValueError as _e:
pass
def simpleFunction56():
"""Throw into finished generator."""
g = (x for x in range(9))
list(g)
try:
g.throw(ValueError(9))
except ValueError as _e:
pass
def simpleFunction60():
x = 1
y = 2
def f(a=x, b=y):
return a, b
f()
f(2)
f(3, 4)
def simpleFunction61():
a = 3
b = 5
try:
a = a * 2
return a
finally:
a / b
def simpleFunction62():
a = 3
b = 5
try:
a = a * 2
return a
finally:
return a / b
class X:
def __del__(self):
# Super used to reference leak.
x = super()
raise ValueError(1)
def simpleFunction63():
def superUser():
X()
try:
superUser()
except Exception:
pass
def simpleFunction64():
x = 2
y = 3
z = eval("x * y")
return z
def simpleFunction65():
import array
a = array.array("b", b"")
assert a == eval(repr(a), {"array": array.array})
d = {"x": 2, "y": 3}
z = eval(repr(d), d)
return z
def simpleFunction66():
import types
return type(simpleFunction65) == types.FunctionType
def simpleFunction67():
length = 100000
pattern = "1234567890\00\01\02\03\04\05\06"
q, r = divmod(length, len(pattern))
teststring = pattern * q + pattern[:r]
return teststring
def simpleFunction68():
from random import randrange
x = randrange(18)
def simpleFunction69():
pools = [tuple()]
g = ((len(pool) == 0,) for pool in pools)
next(g)
def simpleFunction70():
def gen():
try:
undefined_yyy
except Exception:
pass
yield sys.exc_info()
try:
undefined_xxx
except Exception:
return list(gen())
def simpleFunction71():
try:
undefined_global
except Exception:
try:
try:
raise
finally:
undefined_global
except Exception:
pass
def simpleFunction72():
try:
for _i in range(10):
try:
undefined_global
finally:
break
except Exception:
pass
def simpleFunction73():
for _i in range(10):
try:
undefined_global
finally:
return 7
def simpleFunction74():
import os # @Reimport
return os
def simpleFunction75():
def raising_gen():
try:
raise TypeError
except TypeError:
yield
g = raising_gen()
next(g)
try:
g.throw(RuntimeError())
except RuntimeError:
pass
def simpleFunction76():
class MyException(Exception):
def __init__(self, obj):
self.obj = obj
class MyObj:
pass
def inner_raising_func():
raise MyException(MyObj())
try:
inner_raising_func()
except MyException:
try:
try:
raise
finally:
raise
except MyException:
pass
class weirdstr(str):
def __getitem__(self, index):
return weirdstr(str.__getitem__(self, index))
def simpleFunction77():
return filter(lambda x: x >= "33", weirdstr("1234"))
def simpleFunction78():
a = "x = 2"
exec(a)
def simpleFunction79():
"some doc"
simpleFunction79.__doc__ = simpleFunction79.__doc__.replace("doc", "dok")
simpleFunction79.__doc__ += " and more" + simpleFunction79.__name__
def simpleFunction80():
"some doc"
del simpleFunction80.__doc__
def simpleFunction81():
def f():
yield 1
j
j = 1
x = list(f())
def simpleFunction82():
def f():
yield 1
j
j = 1
x = f.__doc__
def simpleFunction83():
x = list(range(7))
x[2] = 5
j = 3
x += [h * 2 for h in range(j)]
def simpleFunction84():
x = tuple(range(7))
j = 3
x += tuple([h * 2 for h in range(j)])
def simpleFunction85():
x = list(range(7))
x[2] = 3
x *= 2
def simpleFunction86():
x = "something"
x += ""
def simpleFunction87():
x = 7
x += 2000
class C:
def f(self):
pass
def __iadd__(self, other):
return self
def method_function(*args, **kwargs):
# Make sure to mutate the list argument value
if "x" in kwargs:
x = kwargs["x"]
if type(x) is list:
x.append(1)
for x in args:
if type(x) is list:
x.append(1)
return args, kwargs
exec(
"""
def method_uncompiled_function(*args, **kwargs):
# Make sure to mutate the list argument value
if "x" in kwargs:
x = kwargs["x"]
if type(x) is list:
x.append(1)
for x in args:
if type(x) is list:
x.append(1)
return args, kwargs
"""
)
def method_function_with_defaults(self, a, b, c, d=1, e=2, f=3):
return True
def simpleFunction88():
x = C()
x += C()
def simpleFunction89():
x = [1, 2]
x += [3, 4]
def anyArgs(*args, **kw):
return kw.keys(), kw.values()
def simpleFunction90():
some_tuple = (simpleFunction89, simpleFunction89, simpleFunction89)
anyArgs(*some_tuple)
def simpleFunction91():
some_dict = {"a": simpleFunction90}
anyArgs(**some_dict)
def simpleFunction92():
some_tuple = (simpleFunction89,)
some_dict = {"a": simpleFunction90}
anyArgs(*some_tuple, **some_dict)
def simpleFunction93():
some_tuple = (simpleFunction89,)
some_dict = {"a": simpleFunction90}
anyArgs(some_tuple, *some_tuple, **some_dict)
def simpleFunction94():
some_tuple = (simpleFunction89,)
some_dict = {"a": simpleFunction90}
anyArgs(*some_tuple, b=some_dict, **some_dict)
def simpleFunction95():
some_tuple = (simpleFunction89,)
some_dict = {"a": simpleFunction90}
anyArgs(some_tuple, *some_tuple, b=some_dict, **some_dict)
def simpleFunction96():
some_tuple = (simpleFunction89,)
anyArgs(some_tuple, *some_tuple)
# Complex call with dictionary and key arguments only.
def simpleFunction97():
some_dict = {"a": simpleFunction90, "d": simpleFunction91}
anyArgs(b=some_dict, c=1, **some_dict)
def simpleFunction98():
some_tuple = (simpleFunction89,)
anyArgs(*some_tuple, b=some_tuple)
def simpleFunction99():
some_dict = {"a": simpleFunction90}
anyArgs(some_dict, **some_dict)
def simpleFunction100():
def h(f):
def g():
return f
return g
def f():
pass
h(f)
def simpleFunction101():
def orMaking(a, b):
x = "axa"
x += a or b
orMaking("x", "")
####################################
class SomeClassWithAttributeAccess(object):
READING = 1
def use(self):
return self.READING
def simpleFunction102():
SomeClassWithAttributeAccess().use()
SomeClassWithAttributeAccess().use()
####################################
def getInt():
return 3
def simpleFunction103():
try:
raise getInt()
except TypeError:
pass
####################################
class ClassWithGeneratorMethod:
def generator_method(self):
yield self
def simpleFunction104():
return list(ClassWithGeneratorMethod().generator_method())
def simpleFunction105():
"""Delete a started generator, not properly closing it before releasing."""
def generator():
yield 1
yield 2
g = generator()
next(g)
del g
def simpleFunction106():
# Call a PyCFunction with a single argument.
return sys.getsizeof(type)
def simpleFunction107():
# Call a PyCFunction with a single argument.
return sum(i for i in range(x))
def simpleFunction108():
# Call a PyCFunction with a single argument.
return sum((i for i in range(x)), 17)
def simpleFunction109():
# Call a PyCFunction that looks like a method call.
sys.exc_info()
def simpleFunction110():
def my_open(*args, **kwargs):
return (args, kwargs)
orig_open = __builtins__.open
__builtins__.open = my_open
open("me", buffering=True)
__builtins__.open = orig_open
####################################
u = u"__name__"
def simpleFunction111():
return getattr(simpleFunction111, u)
####################################
def simpleFunction112():
TESTFN = "tmp.txt"
import codecs
try:
with open(TESTFN, "wb") as out_file:
out_file.write(b"\xa1")
f = codecs.open(TESTFN, encoding="cp949")
f.read(2)
except UnicodeDecodeError:
pass
finally:
try:
f.close()
except Exception:
pass
try:
os.unlink(TESTFN)
except Exception:
pass
####################################
def simpleFunction113():
class A(object):
pass
a = A()
a.a = a
return a
l = []
def simpleFunction114():
global l
l += ["something"]
# Erase it to avoid reference change.
del l[:]
i = 2 ** 16 + 1
def simpleFunction115():
global i
i += 1
t = tuple(range(259))
def simpleFunction116():
global t
t += (2, 3)
t = tuple(range(259))
def simpleFunction117():
# Operation tuple+object, error case.
try:
return tuple(t) + i
except TypeError:
pass
def simpleFunction118():
# Operation tuple+object, error case.
try:
return i + tuple(t)
except TypeError:
pass
t2 = tuple(range(9))
def simpleFunction119():
# Operation tuple+object no error case.
return tuple(t) + t2
def simpleFunction120():
# Operation object+tuple no error case.
return t2 + tuple(t)
def simpleFunction121():
# Operation tuple+tuple
return tuple(t2) + tuple(t)
def simpleFunction122():
# Operation list+object, error case.
try:
return list(t) + i
except TypeError:
pass
def simpleFunction123():
# Operation list+object, error case.
try:
return i + list(t)
except TypeError:
pass
l2 = list(range(9))
def simpleFunction124():
# Operation list+object no error case.
return list(t) + l2
def simpleFunction125():
# Operation object+list no error case.
return l2 + list(t)
def simpleFunction126():
# Operation tuple+tuple
return list(l2) + list(t)
class TupleWithSlots(tuple):
def __add__(self, other):
return 42
def __radd__(self, other):
return 42
def simpleFunction127():
# Operation tuple+object with add slot.
return tuple(t) + TupleWithSlots()
def simpleFunction128():
# Operation object+tuple with add slot.
return TupleWithSlots() + tuple(t)
class ListWithSlots(list):
def __add__(self, other):
return 42
def __radd__(self, other):
return 42
def simpleFunction129():
# Operation list+object with add slot.
return list(t) + ListWithSlots()
def simpleFunction130():
# Operation list+object with add slot.
return ListWithSlots() + list(t)
def simpleFunction131():
try:
C().f.__reduce__()
except Exception as e:
assert sys.version_info < (3, 4)
def simpleFunction132():
C().f.__reduce_ex__(5)
x = 5
def local_function(*args, **kwargs):
# Make sure to mutate the list argument value
if "x" in kwargs:
x = kwargs["x"]
if type(x) is list:
x.append(1)
for x in args:
if type(x) is list:
x.append(1)
return args, kwargs
exec(
"""
def local_uncompiled_function(*args, **kwargs):
# Make sure to mutate the list argument value
if "x" in kwargs:
x = kwargs["x"]
if type(x) is list:
x.append(1)
for x in args:
if type(x) is list:
x.append(1)
return args, kwargs
"""
)
def simpleFunction133():
local_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
local_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
local_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
local_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=[])
local_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
local_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
local_function(1, 2, 3, 4, 5, 6, 7, [], 9, 10, 11, x=[])
local_function(x=1)
local_function(x=x)
local_function(x=[])
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=[])
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
local_uncompiled_function(1, 2, 3, 4, 5, 6, 7, [], 9, 10, 11, x=[])
local_uncompiled_function(x=1)
local_uncompiled_function(x=x)
local_uncompiled_function(x=[])
c = C()
C().method_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
C.method_function(c, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
C().method_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
C().method_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=[1])
C.method_function(c, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
C().method_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
C.method_function(c, 1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
C().method_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
C.method_function(c, 1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
C().method_function(1, 2, 3, 4, 5, 6, 7, [1], 9, 10, 11, x=[1])
C.method_function(c, 1, 2, 3, 4, 5, 6, 7, [1], 9, 10, 11, x=[1])
C().method_function(x=1)
C().method_function(x=x)
C().method_function(x=[1])
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
C.method_uncompiled_function(c, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=1)
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=[1])
C.method_uncompiled_function(c, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, x=x)
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
C.method_uncompiled_function(c, 1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=1)
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
C.method_uncompiled_function(c, 1, 2, 3, 4, 5, 6, 7, x, 9, 10, 11, x=x)
C().method_uncompiled_function(1, 2, 3, 4, 5, 6, 7, [1], 9, 10, 11, x=[1])
C.method_uncompiled_function(c, 1, 2, 3, 4, 5, 6, 7, [1], 9, 10, 11, x=[1])
C().method_uncompiled_function(x=1)
C().method_uncompiled_function(x=x)
C().method_uncompiled_function(x=[1])
C().method_function_with_defaults(1, 2, 3, d=1)
C().method_function_with_defaults(1, x, 3, d=x)
C().method_function_with_defaults(1, x, 3, d=[1])
####################################
# These need stderr to be wrapped.
tests_stderr = (63,)
# Disabled tests
tests_skipped = {}
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/Constants27.py 0000600 0003721 0003721 00000001743 14166627112 025401 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("Clash in constants reveals order:")
x = {True, 1}
print(x)
print("Complex constant using sets with clashes at run time:")
y = True
x = ({1}, {1, True}, {1, 1.0}, {1, y})
print(x)
Nuitka-0.6.19.1/tests/basics/run_all.py 0000700 0003721 0003721 00000007337 14166627112 024716 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Runner for basic tests of Nuitka.
Basic tests are those that cover our back quickly, but need not necessarily,
be complete.
"""
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import (
compareWithCPython,
createSearchMode,
decideNeeds2to3,
hasDebugPython,
scanDirectoryForTestCases,
setup,
)
def main():
setup(suite="basics", needs_io_encoding=True)
search_mode = createSearchMode()
# Now run all the tests in this directory.
for filename in scanDirectoryForTestCases("."):
extra_flags = [
# No error exits normally, unless we break tests, and that we would
# like to know.
"expect_success",
# Keep no temporary files.
"remove_output",
# Do not follow imports.
"--nofollow-imports",
# Use the original __file__ value, at least one case warns about things
# with filename included.
"--file-reference-choice=original",
# Cache the CPython results for re-use, they will normally not change.
"cpython_cache",
# To understand what is slow.
"timing",
# We annotate some tests, use that to lower warnings.
"plugin_enable:pylint-warnings",
]
# This test should be run with the debug Python, and makes outputs to
# standard error that might be ignored.
if filename.startswith("Referencing"):
if hasDebugPython():
extra_flags.append("python_debug")
# This tests warns about __import__() used.
if filename == "OrderChecks.py":
extra_flags.append("ignore_warnings")
# This tests warns about an package relative import despite
# being in no package.
if filename == "Importing.py":
extra_flags.append("ignore_warnings")
# TODO: Nuitka does not give output for ignored exception in dtor, this is
# not fully compatible and potentially an error.
if filename == "YieldFrom33.py":
extra_flags.append("ignore_stderr")
# For Python2 there is a "builtins" package that gives warnings. TODO: We
# ought to NOT import that package and detect statically that __builtins__
# import won't raise ImportError.
if filename == "BuiltinOverload.py":
extra_flags.append("ignore_warnings")
active = search_mode.consider(dirname=None, filename=filename)
if active:
compareWithCPython(
dirname=None,
filename=filename,
extra_flags=extra_flags,
search_mode=search_mode,
needs_2to3=decideNeeds2to3(filename),
)
search_mode.finish()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/basics/ExecEval.py 0000600 0003721 0003721 00000015131 14166627112 024744 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import os
import sys
import tempfile
print "eval 3+3=", eval("3+3")
print "eval 4+4=", eval(" 4+4")
def functionEval1():
return eval(" 5+5")
print "eval in a function with nothing provided", functionEval1()
def functionEval2():
a = [2]
g = {}
r = eval("1+3", g)
return r, g.keys(), a
print "eval in a function with globals provided", functionEval2()
def functionEval3():
result = []
for x in eval("(1,2)"):
result.append(x)
return result
print "eval in a for loop as iterator giver", functionEval3()
print "exec on a global level",
exec ("d=2+2")
print "2+2=", d
def functionExec1():
a = 1
code = "a=2"
exec (code)
return a
def functionExec2():
a = 1
code = "a=2"
exec code in globals(), locals()
return a
print "exec in function without and with locals() provided:", functionExec1(), functionExec2()
tmp_filename = tempfile.gettempdir() + "/execfile.py"
f = open(tmp_filename, "w")
f.write("e=7\nf=8\n")
f.close()
execfile(tmp_filename)
print "execfile with defaults f,g=", e, f
global_vars = {"e": "0", "f": 0}
local_vars = dict(global_vars)
execfile(tmp_filename, global_vars)
print "execfile with globals dict:", global_vars.keys()
execfile(tmp_filename, global_vars, local_vars)
print "execfile with globals and locals dict:", local_vars
def functionExecfile():
e = 0
f = 0
global_vars = {"e": "0", "f": 0}
local_vars = dict(global_vars)
print "execfile with globals and locals dict in a function:",
x = execfile(tmp_filename, global_vars, local_vars)
print x,
print global_vars.keys(), local_vars, e, f
functionExecfile()
class classExecfile:
e = 0
f = 0
print "execfile in a class:",
# TODO: Won't work yet, Issue#5
# print execfile( tmp_filename ),
execfile(tmp_filename)
print "execfile changed local values:", e, f
f = 7
def functionExecNonesTuple():
f = 0
exec ("f=1", None, None)
print "Exec with None as optimizable tuple args did update locals:", f
def functionExecNonesSyntax():
f = 0
exec "f=2" in None, None
print "Exec with None as optimizable normal args did update locals:", f
functionExecNonesTuple()
functionExecNonesSyntax()
print "Global value is untouched", f
def functionEvalNones2():
f = 11
code = "f"
g = None
l = None
f1 = eval(code, l, g)
print "Eval with None arguments from variables did access locals:", f1
functionEvalNones2()
def functionExecNonesTuple2():
f = 0
code = "f=1"
g = None
l = None
exec (code, l, g)
print "Exec with None as tuple args from variable did update locals:", f
def functionExecNonesSyntax2():
f = 0
code = "f=2"
g = None
l = None
exec code in l, g
print "Exec with None as normal args did update locals:", f
functionExecNonesTuple2()
functionExecNonesSyntax2()
print "Exec with a future division definition and one without:"
exec """
from __future__ import division
from __future__ import print_function
print( "3/2 is with future division", 3/2 )
"""
exec """
from __future__ import print_function
print( "3/2 is without future division", 3/2 )
"""
x = 1
y = 1
def functionGlobalsExecShadow():
global x
print "Global x outside is", x
y = 0
print "Local y is initially", y
print "Locals initially", locals()
exec """
from __future__ import print_function
x = 2
print( "Exec local x is", x )
"""
print "Function global x referenced as local x in exec is", x
exec """
from __future__ import print_function
print( "Re-exec local x", x )
"""
print "Locals after exec assigning to local x", locals()
exec """
from __future__ import print_function
global x
x = 3
print( "Exec global x is inside exec", x )
"""
print "Global x referenced as global x in exec is", x
exec """
from __future__ import print_function
def change_y():
global y
y = 4
print( "Exec function global y is", y )
y = 7
change_y()
# TODO: The below will not work
print( "Exec local y is", y )
"""
# print "Local y is afterwards", y
def print_global_y():
global y
# TODO: The below will not work
print "Global y outside", y
print_global_y()
print "Outside y", y
functionGlobalsExecShadow()
def functionWithClosureProvidedByExec():
code = "ValueError = TypeError"
exec code in None, None
def func():
print "Closure from exec not used", ValueError
func()
functionWithClosureProvidedByExec()
x = 2
def functionWithExecAffectingClosure():
x = 4
code = "d=3;x=5"
space = locals()
exec code in space
def closureMaker():
return x
return d, closureMaker()
print "Closure in a function with exec to not none", functionWithExecAffectingClosure()
def generatorFunctionWithExec():
yield 1
code = "y = 2"
exec code
yield y
print "Exec in a generator function", tuple(generatorFunctionWithExec())
def evalInContractions():
r1 = list(eval(str(s)) for s in range(3))
r2 = [eval(str(s)) for s in range(4)]
return r1, r2
print "Eval in a list contraction or generator expression", evalInContractions()
def execDefinesFunctionToLocalsExplicity():
exec """\
def makeAddPair(a, b):
def addPair(c, d):
return (a + c, b + d)
return addPair
""" in locals()
if sys.version_info < (3,):
assert makeAddPair
return "yes"
print "Exec adds functions declares in explicit locals() given.", execDefinesFunctionToLocalsExplicity()
os.unlink(tmp_filename)
def execWithShortTuple():
try:
exec ("print hey",)
except Exception as e:
return "gives exception: " + repr(e)
print "Exec with too short tuple argument:", execWithShortTuple()
if str is not bytes:
def evalMemoryView(value):
return eval(memoryview(value))
print "Eval with memory view:", evalMemoryView(b"27")
Nuitka-0.6.19.1/tests/basics/Functions.py 0000600 0003721 0003721 00000030065 14166627112 025223 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Various kinds of functions with small specialties.
"""
from __future__ import print_function
import inspect
import sys
# pylint: disable=redefined-outer-name
var_on_module_level = 1
def closureTest1(some_arg): # pylint: disable=unused-argument
x = 3
def enclosed(_f="default_value"):
return x
return enclosed
print("Call closured function returning function:", closureTest1(some_arg="ignored")())
def closureTest2(some_arg): # pylint: disable=unused-argument
def enclosed(_f="default_value"):
return x
x = 4
return enclosed
print("Call closured function returning function:", closureTest2(some_arg="ignored")())
def defaultValueTest1(_no_default, some_default_constant=1):
return some_default_constant
print(
"Call function with 2 parameters, one defaulted, and check that the default value is used:",
defaultValueTest1("ignored"),
)
def defaultValueTest1a(
_no_default, some_default_constant_1=1, some_default_constant_2=2
):
return some_default_constant_2 - some_default_constant_1
print(
"Call function with 3 parameters, 2 defaulted, check they are used correctly:",
defaultValueTest1a("ignored"),
)
def defaultValueTest2(_no_default, some_default_variable=var_on_module_level * 2):
return some_default_variable
print(
"Call function with 2 parameters, 1 defaulted with an expression, check its result",
defaultValueTest2("ignored"),
)
var_on_module_level = 2
print(
"Call function with 2 parameters, 1 defaulted with an expression, values have changed since, check its result",
defaultValueTest2("ignored"),
)
def contractionTest():
j = 2
return [j + i for i in range(8)]
print("Call function that returns a list contraction:", contractionTest())
def defaultValueTest3a(
_no_default, funced_defaulted=defaultValueTest2(var_on_module_level)
):
return [i + funced_defaulted for i in range(8)]
print(
"Call function that has a default value coming from a function call:",
defaultValueTest3a("ignored"),
)
def defaultValueTest3b(
_no_default, funced_defaulted=defaultValueTest2(var_on_module_level)
):
local_var = [funced_defaulted + i for i in range(8)]
return local_var
print(
"Call function that returns a list contraction result via a local variable:",
defaultValueTest3b("ignored"),
)
def defaultValueTest3c(
_no_default, funced_defaulted=defaultValueTest2(var_on_module_level)
):
local_var = [[j + funced_defaulted + 1 for j in range(i)] for i in range(8)]
return local_var
print(
"Call function that returns a nested list contraction with input from default parameter",
defaultValueTest3c("ignored"),
)
def defaultValueTest4(_no_default, funced_defaulted=lambda x: x ** 2):
return funced_defaulted(4)
print(
"Call function that returns value calculated by a lambda function as default parameter",
defaultValueTest4("ignored"),
)
def defaultValueTest4a(_no_default, funced_defaulted=lambda x: x ** 2):
c = 1
d = funced_defaulted(1)
r = (i + j + c + d for i, j in zip(range(8), range(9)))
l = []
for x in r:
l.append(x)
return l
print(
"Call function that has a lambda calculated default parameter and a generator expression",
defaultValueTest4a("ignored"),
)
def defaultValueTest4b(_no_default, funced_defaulted=lambda x: x ** 3):
d = funced_defaulted(1)
# Nested generators
l = []
for x in ((d + j for j in range(4)) for i in range(8)):
for y in x:
l.append(y)
return l
print(
"Call function that has a lambda calculated default parameter and a nested generator expression",
defaultValueTest4b("ignored"),
)
def defaultValueTest5(_no_default, tuple_defaulted=(1, 2, 3)):
return tuple_defaulted
print("Call function with default value that is a tuple", defaultValueTest5("ignored"))
def defaultValueTest6(
_no_default, list_defaulted=[1, 2, 3]
): # pylint: disable=dangerous-default-value
return list_defaulted
print("Call function with default value that is a list", defaultValueTest6("ignored"))
x = len("hey")
# TODO: Doesn't belong here.
def in_test(a):
# if 7 in a:
# print "hey"
# pylint: disable=pointless-statement
8 in a # @NoEffect
9 not in a # @NoEffect
in_test([8])
try:
in_test(9)
except TypeError:
pass
def my_deco(function):
def new_function(c, d):
return function(d, c)
return new_function
@my_deco
def decoriert(a, b): # pylint: disable=unused-argument
def subby(a):
return 2 + a
return 1 + subby(b)
print("Function with decoration", decoriert(3, 9))
def functionWithGlobalReturnValue():
global a # pylint: disable=global-statement
return a
a = "oh common"
some_constant_tuple = (2, 5, 7)
some_semiconstant_tuple = (2, 5, a)
f = a * 2
print(defaultValueTest1("ignored"))
# The change of the default variable doesn't influence the default
# parameter of defaultValueTest2, that means it's also calculated
# at the time the function is defined.
module_level = 7
print(defaultValueTest2("also ignored"))
def starArgTest(a, b, c):
return a, b, c
print("Function called with star arg from tuple:")
star_list_arg = (11, 44, 77)
print(starArgTest(*star_list_arg))
print("Function called with star arg from list:")
star_list_arg = [7, 8, 9]
print(starArgTest(*star_list_arg))
star_dict_arg = {"a": 9, "b": 3, "c": 8}
print("Function called with star arg from dict")
print(starArgTest(**star_dict_arg))
lambda_func = lambda a, b: a < b
lambda_args = (8, 9)
print("Lambda function called with star args from tuple:")
print(lambda_func(*lambda_args))
print("Lambda function called with star args from list:")
lambda_args = [8, 7]
print(lambda_func(*lambda_args))
print("Generator function without context:")
def generator_without_context_function():
gen = (x for x in range(9))
return tuple(gen)
print(generator_without_context_function())
print("Generator function with 2 iterateds:")
def generator_with_2_fors():
return tuple((x, y) for x in range(2) for y in range(3))
print(generator_with_2_fors())
def someYielder():
yield 1
yield 2
def someYieldFunctionUser():
print("someYielder", someYielder())
result = []
for a in someYielder():
result.append(a)
return result
print("Function that uses some yielding function coroutine:")
print(someYieldFunctionUser())
def someLoopYielder():
for i in (0, 1, 2):
yield i
def someLoopYieldFunctionUser():
result = []
for a in someLoopYielder():
result.append(a)
return result
print("Function that uses some yielding function coroutine that loops:")
print(someLoopYieldFunctionUser())
def someGeneratorClosureUser():
def someGenerator():
def userOfGeneratorLocalVar():
return x + 1
x = 2
yield userOfGeneratorLocalVar()
yield 6
gen = someGenerator()
return [next(gen), next(gen)]
print(
"Function generator that uses a local function accessing its local variables to yield:"
)
print(someGeneratorClosureUser())
def someClosureUsingGeneratorUser():
offered = 7
def someGenerator():
yield offered
return next(someGenerator())
print("Function generator that yield from its closure:")
print(someClosureUsingGeneratorUser())
print("Function call with both star args and named args:")
def someFunction(a, b, c, d):
print(a, b, c, d)
someFunction(a=1, b=2, **{"c": 3, "d": 4})
print("Order of evaluation of function and args:")
def getFunction():
print("getFunction", end="")
def x(y, u, a, k):
return y, u, k, a
return x
def getPlainArg1():
print("getPlainArg1", end="")
return 9
def getPlainArg2():
print("getPlainArg2", end="")
return 13
def getKeywordArg1():
print("getKeywordArg1", end="")
return "a"
def getKeywordArg2():
print("getKeywordArg2", end="")
return "b"
getFunction()(getPlainArg1(), getPlainArg2(), k=getKeywordArg1(), a=getKeywordArg2())
print()
def getListStarArg():
print("getListStarArg", end="")
return [1]
def getDictStarArg():
print("getDictStarArg", end="")
return {"k": 9}
print("Same with star args:")
getFunction()(getPlainArg1(), a=getKeywordArg1(), *getListStarArg(), **getDictStarArg())
print()
print("Dictionary creation order:")
d = {getKeywordArg1(): getPlainArg1(), getKeywordArg2(): getPlainArg2()}
print()
print("Throwing an exception to a generator function:")
def someGeneratorFunction():
try:
yield 1
yield 2
except Exception: # pylint: disable=broad-except
yield 3
yield 4
gen1 = someGeneratorFunction()
print("Fresh Generator Function throwing gives", end="")
try:
print(gen1.throw(ValueError)),
except ValueError:
print("exception indeed")
gen2 = someGeneratorFunction()
print("Used Generator Function throwing gives", end="")
next(gen2)
print(gen2.throw(ValueError), "indeed")
gen3 = someGeneratorFunction()
print("Fresh Generator Function close gives", end="")
print(gen3.close())
gen4 = someGeneratorFunction()
print("Used Generator Function that mis-catches close gives", end="")
next(gen4)
try:
print(gen4.close(), end="")
except RuntimeError:
print("runtime exception indeed")
gen5 = someGeneratorFunction()
print("Used Generator Function close gives", end="")
next(gen5)
next(gen5)
next(gen5)
print(gen5.close(), end="")
def receivingGenerator():
while True:
a = yield 4
yield a
print("Generator function that receives", end="")
gen6 = receivingGenerator()
print(next(gen6), end="")
print(gen6.send(5), end="")
print(gen6.send(6), end="")
print(gen6.send(7), end="")
print(gen6.send(8))
print("Generator function whose generator is copied", end="")
def generatorFunction():
yield 1
yield 2
gen7 = generatorFunction()
next(gen7)
gen8 = iter(gen7)
print(next(gen8))
def doubleStarArgs(*a, **d):
return a, d
try:
from UserDict import UserDict
except ImportError:
print("Using Python3, making own non-dict dict:")
class UserDict(dict):
pass
print("Function that has keyword argument matching the list star arg name", end="")
print(doubleStarArgs(1, **UserDict(a=2)))
def generatorFunctionUnusedArg(_a):
yield 1
generatorFunctionUnusedArg(3)
def closureHavingGenerator(arg):
def gen(_x=1):
yield arg
return gen()
print("Function generator that has a closure and default argument", end="")
print(list(closureHavingGenerator(3)))
def functionWithDualStarArgsAndKeywordsOnly(a1, a2, a3, a4, b):
return a1, a2, a3, a4, b
l = [1, 2, 3]
d = {"b": 8}
print(
"Dual star args, but not positional call",
functionWithDualStarArgsAndKeywordsOnly(a4=1, *l, **d),
)
def posDoubleStarArgsFunction(a, b, c, *l, **d):
return a, b, c, l, d
l = [2]
d = {"other": 7, "c": 3}
print("Dual star args consuming function", posDoubleStarArgsFunction(1, *l, **d))
for value in sorted(dir()):
main_value = getattr(sys.modules["__main__"], value)
if inspect.isfunction(main_value):
print(
main_value,
main_value.__code__.co_varnames[: main_value.__code__.co_argcount],
inspect.getargs(main_value.__code__),
) #
# TODO: Make this work as well, currently disabled, because of nested arguments not
# being compatible yet.
# print inspect.getargspec( main_value )
Nuitka-0.6.19.1/tests/basics/Printing_2.py 0000600 0003721 0003721 00000002605 14166627112 025265 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# All of these should be identical with correct software behavior.
print "Output with newline."
print "Output", "with", "newline."
print "Output trailing spaces ", "with ", "newline."
print "Output ",
print "with ",
print "newline."
print "Output\twith tab"
print "Output\t",
print "with tab"
# These ones gave errors with previous literal bugs:
print "changed 2"
print "foo%sbar%sfred%sbob?????"
a = "partial print"
# b doesn't exist
try:
print a, undefined_global
except Exception, e:
print "then occurred", repr(e)
print "No newline at the end",
x = 1
print """
New line is no soft space, is it
""", x
Nuitka-0.6.19.1/tests/basics/Referencing27.py 0000600 0003721 0003721 00000004034 14166627112 025650 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests for Python2 specific features.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
"""
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import executeReferenceChecked
x = 17
# Python2.7 or higher syntax things are here.
def simpleFunction1():
return {i: x for i in range(x)}
def simpleFunction2():
try:
return {y: i for i in range(x)}
except NameError:
pass
def simpleFunction3():
return {i for i in range(x)}
def simpleFunction4():
try:
return {y for i in range(x)}
except NameError:
pass
# These need stderr to be wrapped.
tests_stderr = ()
# Disabled tests
tests_skipped = {}
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/BuiltinSuper.py 0000600 0003721 0003721 00000007210 14166627112 025674 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
# Python2 will fallback to this variable, which Python3 will ignore.
__class__ = "Using module level __class__ variable, would be wrong for Python3"
class ClassWithUnderClassClosure:
def g(self):
def h():
print("Variable __class__ in ClassWithUnderClassClosure is", __class__)
h()
try:
print(
"ClassWithUnderClassClosure: Super in ClassWithUnderClassClosure is",
super(),
)
except Exception as e:
print("ClassWithUnderClassClosure: Occurred during super call", repr(e))
print("Class with a method that has a local function accessing __class__:")
ClassWithUnderClassClosure().g()
class ClassWithoutUnderClassClosure:
def g(self):
__class__ = "Providing __class__ ourselves, then it must be used"
print(__class__)
try:
print("ClassWithoutUnderClassClosure: Super", super())
except Exception as e:
print("ClassWithoutUnderClassClosure: Occurred during super call", repr(e))
ClassWithoutUnderClassClosure().g()
# For Python2 only.
__class__ = "Global __class__"
def deco(C):
print("Decorating", repr(C))
class D(C):
pass
return D
@deco
class X:
__class__ = "some string"
def f1(self):
print("f1", locals())
try:
print("f1", __class__)
except Exception as e:
print("Accessing __class__ in f1 gave", repr(e))
def f2(self):
print("f2", locals())
def f4(self):
print("f4", self)
self = X()
print("f4", self)
try:
print("f4", super())
print("f4", super().__self__)
except TypeError:
import sys
assert sys.version_info < (3,)
f5 = lambda x: __class__
def f6(self_by_another_name): # @NoSelf
try:
print("f6", super())
except TypeError:
import sys
assert sys.version_info < (3,)
def f7(self):
try:
yield super()
except TypeError:
import sys
assert sys.version_info < (3,)
print("Early pre-class calls begin")
print("Set in class __class__", __class__)
# f1(1)
f2(2)
print("Early pre-class calls end")
del __class__
x = X()
x.f1()
x.f2()
x.f4()
print("f5", x.f5())
x.f6()
print("f7", list(x.f7()))
def makeSuperCall(arg1, arg2):
print("Calling super with args", arg1, arg2, end=": ")
try:
super(arg1, arg2)
except Exception as e:
print("Exception", e)
else:
print("Ok.")
# Due to inconsistent backporting to Python2.6 and Python2.7, 3.5 on various OSes,
# this one gives varying results, ignore that
if sys.version_info >= (3, 6):
makeSuperCall(None, None)
makeSuperCall(1, None)
makeSuperCall(type, None)
makeSuperCall(type, 1)
Nuitka-0.6.19.1/tests/basics/Unicode.py 0000600 0003721 0003721 00000002110 14166627112 024627 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
print(u"gfcrk")
print(repr(u"g\xfcrk"))
print(r"""\x00""")
print("\ttest\n")
print(
"""
something
with
new
lines"""
)
print(u"favicon.ico (32\xd732)")
# TODO: Python3 has a problem here, hard to find, disabled for now.
if False:
encoding = "utf-16-be"
print("[\uDC80]".encode(encoding))
print("[\\udc80]")
Nuitka-0.6.19.1/tests/basics/ParameterErrors.py 0000600 0003721 0003721 00000013335 14166627112 026371 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def functionNoParameters():
pass
print("Call a function with no parameters with a plain argument:")
try:
functionNoParameters(1)
except TypeError as e:
print(repr(e))
print("Call a function with no parameters with a keyword argument:")
try:
functionNoParameters(z=1)
except TypeError as e:
print(repr(e))
def functionOneParameter(a):
print(a)
print("Call a function with one parameter with two plain arguments:")
try:
functionOneParameter(1, 1)
except TypeError as e:
print(repr(e))
print("Call a function with one parameter too many, and duplicate arguments:")
try:
functionOneParameter(6, a=4, *(1, 2, 3))
except TypeError as e:
print(repr(e))
print("Call a function with two parameters with three plain arguments:")
def functionTwoParameters(a, b):
print(a, b)
try:
functionTwoParameters(1, 2, 3)
except TypeError as e:
print(repr(e))
print("Call a function with two parameters with one plain argument:")
try:
functionTwoParameters(1)
except TypeError as e:
print(repr(e))
print("Call a function with two parameters with three plain arguments:")
try:
functionTwoParameters(1, 2, 3)
except TypeError as e:
print(repr(e))
print("Call a function with two parameters with one keyword argument:")
try:
functionTwoParameters(a=1)
except TypeError as e:
print(repr(e))
print("Call a function with two parameters with three keyword arguments:")
try:
functionTwoParameters(a=1, b=2, c=3)
except TypeError as e:
print(repr(e))
class MethodContainer:
def methodNoParameters(self):
pass
def methodOneParameter(self, a):
print(a)
def methodTwoParameters(self, a, b):
print(a, b)
obj = MethodContainer()
print("Call a method with no parameters with a plain argument:")
try:
obj.methodNoParameters(1)
except TypeError as e:
print(repr(e))
print("Call a method with no parameters with a keyword argument:")
try:
obj.methodNoParameters(z=1)
except TypeError as e:
print(repr(e))
print("Call a method with one parameter with two plain arguments:")
try:
obj.methodOneParameter(1, 1)
except TypeError as e:
print(repr(e))
print("Call a method with two parameters with three plain arguments:")
try:
obj.methodTwoParameters(1, 2, 3)
except TypeError as e:
print(repr(e))
print("Call a method with two parameters with one plain argument:")
try:
obj.methodTwoParameters(1)
except TypeError as e:
print(repr(e))
print("Call a method with two parameters with one keyword argument:")
try:
obj.methodTwoParameters(a=1)
except TypeError as e:
print(repr(e))
print("Call a method with two parameters with three keyword arguments:")
try:
obj.methodTwoParameters(a=1, b=2, c=3)
except TypeError as e:
print(repr(e))
def functionPosBothStarArgs(a, b, c, *l, **d):
print(a, b, c, l, d)
l = [2]
d = {"other": 7}
print("Call a function with both star arguments and too little arguments:")
try:
functionPosBothStarArgs(1, *l, **d)
except TypeError as e:
print(repr(e))
print("Call a function with defaults with too little arguments:")
def functionWithDefaults(a, b, c, d=3):
print(a, b, c, d)
try:
functionWithDefaults(1)
except TypeError as e:
print(repr(e))
print("Call a function with defaults with too many arguments:")
try:
functionWithDefaults(1)
except TypeError as e:
print(repr(e))
print("Complex calls with both invalid star list and star arguments:")
try:
a = 1
b = 2.0
functionWithDefaults(1, c=3, *a, **b)
except TypeError as e:
# Workaround Python 3.9 shortcoming
print(repr(e).replace("Value", "__main__.functionWithDefaults() argument"))
try:
a = 1
b = 2.0
functionWithDefaults(1, *a, **b)
except TypeError as e:
# Workaround Python 3.9 shortcoming
print(repr(e).replace("Value", "__main__.functionWithDefaults() argument"))
try:
a = 1
b = 2.0
functionWithDefaults(c=1, *a, **b)
except TypeError as e:
print(repr(e))
try:
a = 1
b = 2.0
functionWithDefaults(*a, **b)
except TypeError as e:
print(repr(e))
print("Complex call with both invalid star list argument:")
try:
a = 1
functionWithDefaults(*a)
except TypeError as e:
print(repr(e))
try:
a = 1
MethodContainer(*a)
except TypeError as e:
print(repr(e))
try:
a = 1
MethodContainer()(*a)
except TypeError as e:
print(repr(e))
try:
a = 1
MethodContainer.methodTwoParameters(*a)
except TypeError as e:
print(repr(e))
try:
a = 1
None(*a)
except TypeError as e:
print(repr(e))
try:
a = 1
None(**a)
except TypeError as e:
print(repr(e))
print("Call object with name as both keyword and in star dict argument:")
try:
a = {"a": 3}
None(a=2, **a)
except TypeError as e:
print(repr(e))
print("Call function with only defaulted value given as keyword argument:")
def functionwithTwoArgsOneDefaulted(a, b=5):
pass
try:
functionwithTwoArgsOneDefaulted(b=12)
except TypeError as e:
print(repr(e))
Nuitka-0.6.19.1/tests/basics/DefaultParameters.py 0000600 0003721 0003721 00000004351 14166627112 026662 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Tests to cover default parameter behaviours.
"""
from __future__ import print_function
# pylint: disable=dangerous-default-value,unused-argument
module_level = 1
def defaultValueTest1(no_default, some_default_constant=1):
return some_default_constant
def defaultValueTest2(no_default, some_default_computed=module_level * 2):
local_var = no_default
return local_var, some_default_computed
def defaultValueTest3(no_default, func_defaulted=defaultValueTest1(module_level)):
return [func_defaulted for _i in range(8)]
def defaultValueTest4(no_default, funced_defaulted=lambda x: x ** 2):
c = 1
d = 1
return (i + c + d for i in range(8))
def defaultValueTest5(no_default, tuple_defaulted=(1, 2, 3)):
return tuple_defaulted
def defaultValueTest6(no_default, list_defaulted=[1, 2, 3]):
list_defaulted.append(5)
return list_defaulted
print(defaultValueTest1("ignored"))
# The change of the default variable doesn't influence the default
# parameter of defaultValueTest2, that means it's also calculated
# at the time the function is defined.
module_level = 7
print(defaultValueTest2("also ignored"))
print(defaultValueTest3("nono not again"))
print(list(defaultValueTest4("unused")))
print(defaultValueTest5("unused"))
print(defaultValueTest6("unused"), end="")
print(defaultValueTest6("unused"))
print(defaultValueTest6.__defaults__)
defaultValueTest6.func_defaults = ([1, 2, 3],)
print(defaultValueTest6.__defaults__)
print(defaultValueTest6(1))
Nuitka-0.6.19.1/tests/basics/Referencing36.py 0000600 0003721 0003721 00000011744 14166627112 025656 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests for Python3.6 or higher.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
These are Python3.6 specific constructs, that will give a SyntaxError or
not be relevant on older versions.
"""
import os
import sys
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
import asyncio
import types
from nuitka.tools.testing.Common import (
async_iterate,
executeReferenceChecked,
run_async,
)
class AwaitException(Exception):
pass
def run_until_complete(coro):
exc = False
while True:
try:
if exc:
exc = False
fut = coro.throw(AwaitException)
else:
fut = coro.send(None)
except StopIteration as ex:
return ex.args[0]
if fut == ("throw",):
exc = True
def simpleFunction1():
async def gen1():
try:
yield
except: # pylint: disable=bare-except
pass
async def run():
g = gen1()
await g.asend(None)
await g.asend(None)
try:
run_async(run())
except StopAsyncIteration:
pass
def simpleFunction2():
async def async_gen():
try:
yield 1
yield 1.1
1 / 0 # pylint: disable=pointless-statement
finally:
yield 2
yield 3
yield 100
async_iterate(async_gen())
@types.coroutine
def awaitable(*, throw=False):
if throw:
yield ("throw",)
else:
yield ("result",)
async def gen2():
await awaitable()
a = yield 123
assert a is None
await awaitable()
yield 456
await awaitable()
yield 789
def simpleFunction3():
def to_list(gen):
async def iterate():
res = []
async for i in gen:
res.append(i)
return res
return run_until_complete(iterate())
async def run2():
return to_list(gen2())
run_async(run2())
def simpleFunction4():
g = gen2()
ai = g.__aiter__()
an = ai.__anext__()
an.__next__()
try:
ai.__anext__().__next__()
except StopIteration as _ex:
pass
except RuntimeError:
# Python 3.8 doesn't like this anymore
assert sys.version_info >= (3, 8)
try:
ai.__anext__().__next__()
except RuntimeError:
# Python 3.8 doesn't like this anymore
assert sys.version_info >= (3, 8)
def simpleFunction5():
t = 2
class C: # pylint: disable=invalid-name
exec("u=2") # pylint: disable=exec-used
x: int = 2
y: float = 2.0
z = x + y + t * u # pylint: disable=undefined-variable
rawdata = b"The quick brown fox jumps over the lazy dog.\r\n"
# Be slow so we don't depend on other modules
rawdata += bytes(range(256))
return C()
# This refleaks big time, but the construct is rare enough to not bother
# as this proves hard to find.
def disabled_simpleFunction6():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(None)
async def waiter(timeout):
await asyncio.sleep(timeout)
yield 1
async def wait():
async for _ in waiter(1):
pass
t1 = loop.create_task(wait())
t2 = loop.create_task(wait())
loop.run_until_complete(asyncio.sleep(0.01))
t1.cancel()
t2.cancel()
try:
loop.run_until_complete(t1)
except asyncio.CancelledError:
pass
try:
loop.run_until_complete(t2)
except asyncio.CancelledError:
pass
loop.run_until_complete(loop.shutdown_asyncgens())
loop.close()
# These need stderr to be wrapped.
tests_stderr = ()
# Disabled tests
tests_skipped = {}
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/OverflowFunctions_2.py 0000600 0003721 0003721 00000002654 14166627112 027173 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def starImporterFunction():
from sys import *
print "Version", version.split()[0].split(".")[:-1]
starImporterFunction()
def deepExec():
for_closure = 3
def deeper():
for_closure_as_well = 4
def execFunction():
code = "f=2"
# Can fool it to nest
exec code in None, None
print "Locals now", locals()
print "Closure one level up was taken", for_closure_as_well
print "Closure two levels up was taken", for_closure
print "Globals still work", starImporterFunction
print "Added local from code", f
execFunction()
deeper()
deepExec()
Nuitka-0.6.19.1/tests/basics/Importing.py 0000600 0003721 0003721 00000004641 14166627112 025224 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def localImporter1():
import os
return os
def localImporter1a():
import os as my_os_name
return my_os_name
def localImporter2():
from os import path
return path
def localImporter2a():
from os import path as renamed
return renamed
print("Direct module import", localImporter1())
print("Direct module import using rename", localImporter1a())
print("From module import", localImporter2())
print("From module import using rename", localImporter2a())
from os import * # isort:skip
print("Star import gave us", path)
import os.path as myname # isort:skip
print("As import gave", myname)
def localImportFailure():
try:
from os import path, lala, listdir
except Exception as e:
print("gives", type(e), repr(e))
try:
print(listdir)
except UnboundLocalError:
print("and listdir was not imported", end=" ")
print("but path was", path)
print("From import that fails in the middle", end=" ")
localImportFailure()
def nonPackageImportFailure():
try:
# Not allowed without being a package, should raise ValueError
from . import whatever
except Exception as e:
print(type(e), repr(e))
print("Package import fails in non-package:", end=" ")
nonPackageImportFailure()
def importBuiltinTupleFailure():
try:
value = ("something",)
# Not allowed to not be constant string, optimization might be fooled
# though.
__import__(value)
except Exception as e:
print(type(e), repr(e))
print("The __import__ built-in optimization can handle tuples:", end=" ")
importBuiltinTupleFailure()
Nuitka-0.6.19.1/tests/basics/TrickAssignments32.py 0000600 0003721 0003721 00000054667 14166627112 026726 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def someFunctionThatReturnsDeletedValueViaAttributeLookup():
class C:
def __getattr__(self, attr_name):
nonlocal a
del a
c = C()
a = 1
c.something
return a
try:
someFunctionThatReturnsDeletedValueViaAttributeLookup()
except UnboundLocalError:
print("OK, object attribute look-up correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaAttributeSetting():
class C:
def __setattr__(self, attr_name, value):
nonlocal a
del a
c = C()
a = 1
c.something = 1
return a
try:
someFunctionThatReturnsDeletedValueViaAttributeSetting()
except UnboundLocalError:
print("OK, object attribute setting correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaAttributeDel():
class C:
def __delattr__(self, attr_name):
nonlocal a
del a
return True
c = C()
a = 1
del c.something
return a
try:
someFunctionThatReturnsDeletedValueViaAttributeDel()
except UnboundLocalError:
print("OK, object attribute del correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaItemLookup():
class C:
def __getitem__(self, attr_name):
nonlocal a
del a
c = C()
a = 1
c[2]
return a
try:
someFunctionThatReturnsDeletedValueViaItemLookup()
except UnboundLocalError:
print("OK, object subscript look-up correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaItemSetting():
class C:
def __setitem__(self, attr_name, value):
nonlocal a
del a
c = C()
a = 1
c[2] = 3
return a
try:
someFunctionThatReturnsDeletedValueViaItemSetting()
except UnboundLocalError:
print("OK, object subscript setting correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaItemDel():
class C:
def __delitem__(self, attr_name):
nonlocal a
del a
c = C()
a = 1
del c[2]
return a
try:
someFunctionThatReturnsDeletedValueViaItemDel()
except UnboundLocalError:
print("OK, object subscript del correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaCall():
class C:
def __call__(self):
nonlocal a
del a
c = C()
a = 1
c()
return a
try:
someFunctionThatReturnsDeletedValueViaCall()
except UnboundLocalError:
print("OK, object call correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaAdd():
class C:
def __add__(self, other):
nonlocal a
del a
c = C()
a = 1
c + 1
return a
try:
someFunctionThatReturnsDeletedValueViaAdd()
except UnboundLocalError:
print("OK, object add correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaSub():
class C:
def __sub__(self, other):
nonlocal a
del a
c = C()
a = 1
c - 1
return a
try:
someFunctionThatReturnsDeletedValueViaSub()
except UnboundLocalError:
print("OK, object sub correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaMul():
class C:
def __mul__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c * 1
return a
try:
someFunctionThatReturnsDeletedValueViaMul()
except UnboundLocalError:
print("OK, object mul correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaRemainder():
class C:
def __mod__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c % 1
return a
try:
someFunctionThatReturnsDeletedValueViaRemainder()
except UnboundLocalError:
print("OK, object remainder correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaDivmod():
class C:
def __divmod__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
divmod(c, 1)
return a
try:
someFunctionThatReturnsDeletedValueViaDivmod()
except UnboundLocalError:
print("OK, object divmod correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaPower():
class C:
def __pow__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c ** 1
return a
try:
someFunctionThatReturnsDeletedValueViaPower()
except UnboundLocalError:
print("OK, object power correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaUnaryMinus():
class C:
def __neg__(self):
nonlocal a
del a
return 7
c = C()
a = 1
-c
return a
try:
someFunctionThatReturnsDeletedValueViaUnaryMinus()
except UnboundLocalError:
print("OK, object unary minus correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaUnaryPlus():
class C:
def __pos__(self):
nonlocal a
del a
return 7
c = C()
a = 1
+c
return a
try:
someFunctionThatReturnsDeletedValueViaUnaryPlus()
except UnboundLocalError:
print("OK, object unary plus correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaNot():
class C:
def __bool__(self):
nonlocal a
del a
return False
c = C()
a = 1
not c
return a
try:
someFunctionThatReturnsDeletedValueViaNot()
except UnboundLocalError:
print("OK, object bool correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInvert():
class C:
def __invert__(self):
nonlocal a
del a
return False
c = C()
a = 1
~c
return a
try:
someFunctionThatReturnsDeletedValueViaInvert()
except UnboundLocalError:
print("OK, object invert correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaLshift():
class C:
def __lshift__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c << 1
return a
try:
someFunctionThatReturnsDeletedValueViaLshift()
except UnboundLocalError:
print("OK, object lshift correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaRshift():
class C:
def __rshift__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c >> 1
return a
try:
someFunctionThatReturnsDeletedValueViaRshift()
except UnboundLocalError:
print("OK, object rshift correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaBitwiseAnd():
class C:
def __and__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c & 1
return a
try:
someFunctionThatReturnsDeletedValueViaBitwiseAnd()
except UnboundLocalError:
print("OK, object bitwise and correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaBitwiseOr():
class C:
def __or__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c | 1
return a
try:
someFunctionThatReturnsDeletedValueViaBitwiseOr()
except UnboundLocalError:
print("OK, object bitwise or correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaBitwiseXor():
class C:
def __xor__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c ^ 1
return a
try:
someFunctionThatReturnsDeletedValueViaBitwiseXor()
except UnboundLocalError:
print("OK, object bitwise xor correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInt():
class C:
def __int__(self):
nonlocal a
del a
return False
c = C()
a = 1
int(c)
return a
try:
someFunctionThatReturnsDeletedValueViaInt()
except UnboundLocalError:
print("OK, object int correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaFloat():
class C:
def __float__(self):
nonlocal a
del a
return 0.0
c = C()
a = 1
float(c)
return a
try:
someFunctionThatReturnsDeletedValueViaFloat()
except UnboundLocalError:
print("OK, object float correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaComplex():
class C:
def __complex__(self):
nonlocal a
del a
return 0j
c = C()
a = 1
complex(c)
return a
try:
someFunctionThatReturnsDeletedValueViaComplex()
except UnboundLocalError:
print("OK, object complex correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceAdd():
class C:
def __iadd__(self, other):
nonlocal a
del a
c = C()
a = 1
c += 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceAdd()
except UnboundLocalError:
print("OK, object inplace add correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceSub():
class C:
def __isub__(self, other):
nonlocal a
del a
c = C()
a = 1
c -= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceSub()
except UnboundLocalError:
print("OK, object inplace sub correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceMul():
class C:
def __imul__(self, other):
nonlocal a
del a
c = C()
a = 1
c *= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceMul()
except UnboundLocalError:
print("OK, object inplace mul correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceRemainder():
class C:
def __imod__(self, other):
nonlocal a
del a
c = C()
a = 1
c %= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceRemainder()
except UnboundLocalError:
print("OK, object inplace remainder correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplacePower():
class C:
def __ipow__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c **= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplacePower()
except UnboundLocalError:
print("OK, object inplace power correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceAnd():
class C:
def __iand__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c &= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceAnd()
except UnboundLocalError:
print("OK, object inplace and correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceFloordiv():
class C:
def __ifloordiv__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c //= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceFloordiv()
except UnboundLocalError:
print("OK, object inplace floordiv correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceLshift():
class C:
def __ilshift__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c <<= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceLshift()
except UnboundLocalError:
print("OK, object inplace lshift correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceRshift():
class C:
def __irshift__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c >>= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceRshift()
except UnboundLocalError:
print("OK, object inplace rshift correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceOr():
class C:
def __ior__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c |= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceOr()
except UnboundLocalError:
print("OK, object inplace or correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceTrueDiv():
class C:
def __itruediv__(self, other):
nonlocal a
del a
return 7
c = C()
a = 1
c /= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceTrueDiv()
except UnboundLocalError:
print("OK, object inplace truediv correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceXor():
class C:
def __ixor__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c ^= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceXor()
except UnboundLocalError:
print("OK, object inplace xor correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaIndex():
class C:
def __index__(self):
nonlocal a
del a
return 0
c = C()
a = 1
[1][c]
return a
try:
someFunctionThatReturnsDeletedValueViaIndex()
except UnboundLocalError:
print("OK, object index correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaLen():
class C:
def __len__(self):
nonlocal a
del a
return 0
c = C()
a = 1
len(c)
return a
try:
someFunctionThatReturnsDeletedValueViaLen()
except UnboundLocalError:
print("OK, object len correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaRepr():
class C:
def __repr__(self):
nonlocal a
del a
return ""
c = C()
a = 1
repr(c)
return a
try:
someFunctionThatReturnsDeletedValueViaRepr()
except UnboundLocalError:
print("OK, object repr correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaStr():
class C:
def __str__(self):
nonlocal a
del a
return ""
c = C()
a = 1
str(c)
return a
try:
someFunctionThatReturnsDeletedValueViaStr()
except UnboundLocalError:
print("OK, object str correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaCompare():
class C:
def __lt__(self, other):
nonlocal a
del a
return ""
c = C()
a = 1
c < None
return a
try:
someFunctionThatReturnsDeletedValueViaCompare()
except UnboundLocalError:
print("OK, object compare correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaDel():
class C:
def __del__(self):
nonlocal a
del a
return ""
c = C()
a = 1
del c
return a
try:
someFunctionThatReturnsDeletedValueViaDel()
except UnboundLocalError:
print("OK, object del correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaHash():
class C:
def __hash__(self):
nonlocal a
del a
return 42
c = C()
a = 1
{}[c] = 1
return a
try:
someFunctionThatReturnsDeletedValueViaHash()
except UnboundLocalError:
print("OK, object hash correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaIter():
class C:
def __iter__(self):
nonlocal a
del a
return iter(range(2))
c = C()
a = 1
x, y = c
return a, x, y
try:
someFunctionThatReturnsDeletedValueViaIter()
except UnboundLocalError:
print("OK, object iter correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaBytes():
class C:
def __bytes__(self):
nonlocal a
del a
return bytes(range(2))
c = C()
a = 1
bytes(c)
return a, x, y
try:
someFunctionThatReturnsDeletedValueViaBytes()
except UnboundLocalError:
print("OK, object bytes correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaEq():
class C:
def __eq__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c == 1
return a
try:
someFunctionThatReturnsDeletedValueViaEq()
except UnboundLocalError:
print("OK, object eq correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaLe():
class C:
def __le__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c <= 1
return a
try:
someFunctionThatReturnsDeletedValueViaEq()
except UnboundLocalError:
print("OK, object le correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaGt():
class C:
def __gt__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c > 1
return a
try:
someFunctionThatReturnsDeletedValueViaEq()
except UnboundLocalError:
print("OK, object gt correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaGe():
class C:
def __ge__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c >= 1
return a
try:
someFunctionThatReturnsDeletedValueViaEq()
except UnboundLocalError:
print("OK, object ge correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaNe():
class C:
def __ne__(self, other):
nonlocal a
del a
return False
c = C()
a = 1
c != 1
return a
try:
someFunctionThatReturnsDeletedValueViaEq()
except UnboundLocalError:
print("OK, object ne correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaContains():
class C:
def __contains__(self, item):
nonlocal a
del a
return False
c = C()
a = 1
1 in c
return a
try:
someFunctionThatReturnsDeletedValueViaContains()
except UnboundLocalError:
print("OK, object contains correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInit():
class C:
def __init__(self):
nonlocal a
del a
a = 1
c = C()
return a
try:
someFunctionThatReturnsDeletedValueViaInit()
except UnboundLocalError:
print("OK, object init correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaNew():
class C:
def __new__(self):
nonlocal a
del a
a = 1
c = C()
return a
try:
someFunctionThatReturnsDeletedValueViaNew()
except UnboundLocalError:
print("OK, object new correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaDir():
class C:
def __dir__(self):
nonlocal a
del a
return []
c = C()
a = 1
dir(c)
return a
try:
someFunctionThatReturnsDeletedValueViaDir()
except UnboundLocalError:
print("OK, object dir correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaReversed():
class C:
def __reversed__(self):
nonlocal a
del a
return None
a = 1
c = C()
reversed(c)
return a
try:
someFunctionThatReturnsDeletedValueViaReversed()
except UnboundLocalError:
print("OK, object reversed correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaFormat():
class C:
def __format__(self, string):
nonlocal a
del a
return "formated string"
c = C()
a = 1
format(c, "some string")
return a
try:
someFunctionThatReturnsDeletedValueViaFormat()
except UnboundLocalError:
print("OK, object format correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaAbs():
class C:
def __abs__(self):
nonlocal a
del a
return abs(10)
a = 1
c = C()
abs(c)
return a
try:
someFunctionThatReturnsDeletedValueViaAbs()
except UnboundLocalError:
print("OK, object abs correctly deleted an item.")
else:
print("Ouch.!")
# TODO: There must be way more than these.
Nuitka-0.6.19.1/tests/basics/MainPrograms.py 0000600 0003721 0003721 00000002766 14166627112 025661 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
print("Module name is", __name__)
class SomeClass:
pass
print("Class inside main module names its module as", repr(SomeClass.__module__))
if __name__ == "__main__":
print("Executed as __main__:")
import sys, os
# The sys.argv[0] might contain ".exe", ".py" or no suffix at all.
# Remove it, so the "diff" output is more acceptable.
args = sys.argv[:]
args[0] = (
os.path.basename(args[0])
.replace(".exe", ".py")
.replace(".bin", ".py")
.replace(".py", "")
)
print("Arguments were (stripped argv[0] suffix):", repr(args))
# Output the flags, so we can test if we are compatible with these too.
print("The sys.flags are:", sys.flags)
Nuitka-0.6.19.1/tests/basics/YieldFrom33.py 0000600 0003721 0003721 00000006000 14166627112 025303 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def g():
for a in range(3):
yield a
return 7
def h():
yield 4
yield 5
def f():
print("Yielded from returner", (yield g()))
print("Yielded from non-return value", (yield h()))
print("Result", list(f()))
print("Yielder with return value", list(g()))
# This will raise when looking up any attribute.
class Broken:
def __iter__(self):
return self
def __next__(self):
return 1
def __getattr__(self, attr):
1 / 0
def test_broken_getattr_handling():
def g():
yield from Broken()
print("Next with send: ", end="")
try:
gi = g()
next(gi)
gi.send(1)
except Exception as e:
print("Caught", repr(e))
print("Next with throw: ", end="")
try:
gi = g()
next(gi)
gi.throw(AttributeError)
except Exception as e:
print("Caught", repr(e))
print("Next with close: ", end="")
try:
gi = g()
next(gi)
gi.close()
print("All good")
except Exception as e:
print("Caught", repr(e))
test_broken_getattr_handling()
def test_throw_catched_subgenerator_handling():
def g1():
try:
print("Starting g1")
yield "g1 ham"
yield from g2()
yield "g1 eggs"
finally:
print("Finishing g1")
def g2():
try:
print("Starting g2")
yield "g2 spam"
yield "g2 more spam"
except LunchError:
print("Caught LunchError in g2")
yield "g2 lunch saved"
yield "g2 yet more spam"
class LunchError(Exception):
pass
g = g1()
for i in range(2):
x = next(g)
print("Yielded %s" % (x,))
e = LunchError("tomato ejected")
print("Throw returned", g.throw(e))
print("Sub thrown")
for x in g:
print("Yielded %s" % (x,))
test_throw_catched_subgenerator_handling()
def give_cpython_generator():
# TODO: This relies on eval not being inlined, which will become untrue.
return eval("(x for x in range(3))")
def gen_compiled():
yield from give_cpython_generator()
yield ...
yield from range(7)
print("Mixing uncompiled and compiled yield from:")
print(list(gen_compiled()))
Nuitka-0.6.19.1/tests/basics/Constants.py 0000600 0003721 0003721 00000010414 14166627112 025223 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Playing around with constants only. """
# pylint: disable=invalid-name,redefined-outer-name
from __future__ import print_function
try:
long
except NameError:
long = int
def displayDict(d):
result = "{"
for key, value in sorted(d.items()):
result += "%s: %s" % (key, value)
result += "}"
print("A bunch of constants and their representation:")
for value in (0, 3, -4, 17, "hey", (0,), 0.0, -0.0):
print(value, ":", repr(value))
print("Comparing constants, optimizable:")
print(1 == 0)
print("Representation of long constants:")
a = long(0)
print(repr(long(0)), repr(a) == "0L")
print("Identity of empty dictionary constants:")
print({} is {})
a = ({}, [])
a[0][1] = 2
a[1].append(3)
print("Mutable list and dict inside an immutable tuple:")
print(a)
print("Empty list and dict are hopefully unchanged:")
print(({}, []))
def argChanger(a):
a[0][1] = 2
a[1].append(3)
return a
print("Mutable list and dict inside an immutable tuple as arguments:")
print(argChanger(({}, [])))
print("Empty list and dict are hopefully still unchanged:")
print(({}, []))
print("Set constants:")
print(set(["foo"]))
def mutableConstantChanger():
a = ([1, 2], [3])
print("Start out with value:")
print(a)
a[1].append(5)
print("Changed to value:")
print(a)
d = {"l": [], "m": []}
print("Start out with value:")
print(d)
d["l"].append(7)
print("Changed to value:")
print(d)
spec = dict(qual=[], storage=set(), type=[], function=set(), q=1)
spec["type"].insert(0, 2)
spec["storage"].add(3)
print("Dictionary created from dict built-in.")
print(sorted(spec))
mutableConstantChanger()
print("Redo constant changes, to catch corruptions:")
mutableConstantChanger()
def defaultKeepsIdentity(arg="str_value"):
print("Default constant values are still shared if immutable:", arg is "str_value")
defaultKeepsIdentity()
# Dictionary creation from call arguments.
def dd(**d):
return d
def f():
def one():
print("one")
def two():
print("two")
a = dd(qual=one(), storage=two(), type=[], function=[])
print("f mutable", displayDict(a))
a = dd(qual=1, storage=2, type=3, function=4)
print("f immutable", displayDict(a))
x = {"p": 7}
a = dd(qual=[], storage=[], type=[], function=[], **x)
print("f ext mutable", displayDict(a))
x = {"p": 8}
a = dd(qual=1, storage=2, type=3, function=4, **x)
print("f ext immutable", displayDict(a))
f()
# Dictionary creation one after another
x = {}
x["function"] = []
x["type"] = []
x["storage"] = []
x["qual"] = []
print("Manual built dictionary:", x)
x = {}
x["function"] = 1
x["type"] = 2
x["storage"] = 3
x["qual"] = 4
print("Manual built dictionary:", x)
# Constants in the code must be created differently.
d = {"qual": [], "storage": [], "type2": [], "function": []}
print("Mutable values dictionary constant:", displayDict(d))
d = {"qual": 1, "storage": 2, "type2": 3, "function": 4}
print("Immutable values dictionary constant:", displayDict(d))
# Constants that might be difficult
min_signed_int = int(-(2 ** (8 * 8 - 1) - 1) - 1)
print("Small int:", min_signed_int, type(min_signed_int))
min_signed_int = int(-(2 ** (8 * 4 - 1) - 1) - 1)
print("Small int", min_signed_int, type(min_signed_int))
# Constants that might be difficult
min_signed_long = long(-(2 ** (8 * 8 - 1) - 1) - 1)
print("Small long", min_signed_long, type(min_signed_long))
min_signed_long = long(-(2 ** (8 * 4 - 1) - 1) - 1)
print("Small long", min_signed_long, type(min_signed_long))
Nuitka-0.6.19.1/tests/basics/Inspection_35.py 0000600 0003721 0003721 00000002740 14166627112 025674 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Tests uncompiled functions and compiled functions responses to inspect and isistance. """
import inspect
import types
# nuitka-project: --python-flag=no_warnings
async def compiledCoroutine():
async with _x:
pass
print(type(compiledCoroutine()))
assert inspect.isfunction(compiledCoroutine) is True
assert inspect.isgeneratorfunction(compiledCoroutine) is False
assert inspect.iscoroutinefunction(compiledCoroutine) is True
assert isinstance(compiledCoroutine(), types.GeneratorType) is False
assert isinstance(compiledCoroutine(), types.CoroutineType) is True
assert type(compiledCoroutine()) == types.CoroutineType, type(compiledCoroutine())
assert isinstance(compiledCoroutine, types.CoroutineType) is False
Nuitka-0.6.19.1/tests/basics/ClassMinimal.py 0000600 0003721 0003721 00000001542 14166627112 025625 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Very minimal class example, to be used for debugging.
a = 1
class B:
b = a
print(B.b)
Nuitka-0.6.19.1/tests/basics/ModuleAttributes.py 0000600 0003721 0003721 00000003456 14166627112 026553 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Some module documentation.
With newline and stuff."""
from __future__ import print_function
import os
import sys
print("doc:", __doc__)
print("filename:", os.path.basename(__file__))
print("builtins:", __builtins__)
print("debug", __debug__)
print("debug in builtins", __builtins__.__debug__)
print("__initializing__", end=" ")
try:
print(__initializing__)
except NameError:
print("not found")
def checkFromFunction():
frame = sys._getframe(1) # pylint: disable=protected-access
def displayDict(d):
if "__loader__" in d:
d = dict(d)
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d = dict(d)
d["__file__"] = "<__file__ removed>"
if "__compiled__" in d:
d = dict(d)
del d["__compiled__"]
import pprint
return pprint.pformat(d)
print("Globals", displayDict(frame.f_globals))
print("Locals", displayDict(frame.f_locals))
print("Is identical", frame.f_locals is frame.f_globals)
checkFromFunction()
Nuitka-0.6.19.1/tests/basics/TryExceptContinue.py 0000600 0003721 0003721 00000004244 14166627112 026707 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def tryWhileExceptContinueTest():
print("Check if continue is executed in a except handler using for loop:")
global undefined
x = 0
while x < 10:
x += 1
try:
if x % 2 == 1:
undefined
except:
print(x, end=" ")
continue
print("-", end=" ")
print()
def tryForExceptContinueTest():
print("Check if continue is executed in a except handler using for loop:")
for x in range(10):
try:
if x % 2 == 1:
undefined
except:
print(x, end=" ")
continue
print("-", end=" ")
print()
def tryWhileExceptBreakTest():
print("Check if break is executed in a except handler using while loop:")
x = 0
while x < 10:
x += 1
try:
if x == 5:
undefined
except:
print(x, end=" ")
break
print("-", end=" ")
print()
def tryForExceptBreakTest():
print("Check if break is executed in a except handler using for loop:")
for x in range(10):
try:
if x == 5:
undefined
except:
print(x, end=" ")
break
print("-", end=" ")
print()
tryWhileExceptContinueTest()
tryWhileExceptBreakTest()
tryForExceptContinueTest()
tryForExceptBreakTest()
Nuitka-0.6.19.1/tests/basics/InplaceOperations.py 0000600 0003721 0003721 00000002420 14166627112 026664 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
x = 1
x += 2
print("Plain in-place:", x)
z = [1, 2, 3]
z[1] += 5
print("List in-place:", z[1])
h = {"a": 3}
h["a"] += 2
print("Dictionary in-place:", h["a"])
class B:
a = 1
B.a += 2
print("Class attribute in-place:", B.a)
h = [1, 2, 3, 4]
h[1:2] += (2, 3)
print("List 'sclice' in-place [x:y]", h)
h[:1] += (9, 9)
print("List 'sclice' in-place [:y]", h)
h[2:] += (6, 6)
print("List 'sclice' in-place [y:]", h)
h[:] += (5, 5, 5)
print("List 'sclice' in-place [:]", h)
Nuitka-0.6.19.1/tests/basics/Varargs.py 0000600 0003721 0003721 00000004057 14166627112 024662 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def plain_list_dict_args_function(plain, *arg_list, **arg_dict):
print("plain", plain, "arg_list", arg_list, "arg_dict", arg_dict)
def plain_list_args_function(plain, *arg_list):
print(plain, arg_list)
def plain_dict_args_function(plain, **arg_dict):
print(plain, arg_dict)
print("Function with plain arg and varargs dict:")
plain_dict_args_function(1, a=2, b=3, c=4)
plain_dict_args_function(1)
print("Function with plain arg and varargs list:")
plain_list_args_function(1, 2, 3, 4)
plain_list_args_function(1)
print("Function with plain arg, varargs list and varargs dict:")
plain_list_dict_args_function(1, 2, z=3)
plain_list_dict_args_function(1, 2, 3)
plain_list_dict_args_function(1, a=2, b=3, c=4)
def list_dict_args_function(*arg_list, **arg_dict):
print(arg_list, arg_dict)
def list_args_function(*arg_list):
print(arg_list)
def dict_args_function(**arg_dict):
print(arg_dict)
print("Function with plain arg and varargs dict:")
dict_args_function(a=2, b=3, c=4)
dict_args_function()
print("Function with plain arg and varargs list:")
list_args_function(2, 3, 4)
list_args_function()
print("Function with plain arg, varargs list and varargs dict:")
list_dict_args_function(2, z=3)
list_dict_args_function(2, 3)
list_dict_args_function(a=2, b=3, c=4)
Nuitka-0.6.19.1/tests/basics/TrickAssignments35.py 0000600 0003721 0003721 00000003005 14166627112 026705 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def someFunctionThatReturnsDeletedValueViaMaxtrixMult():
class C:
def __matmul__(self, other):
nonlocal a
del a
c = C()
a = 1
c @ 1
return a
try:
someFunctionThatReturnsDeletedValueViaMaxtrixMult()
except UnboundLocalError:
print("OK, object matrix mult correctly deleted an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaInplaceMaxtrixMult():
class C:
def __imatmul__(self, other):
nonlocal a
del a
c = C()
a = 1
c @= 1
return a
try:
someFunctionThatReturnsDeletedValueViaInplaceMaxtrixMult()
except UnboundLocalError:
print("OK, object inplace matrix mult correctly deleted an item.")
else:
print("Ouch.!")
Nuitka-0.6.19.1/tests/basics/Referencing35.py 0000600 0003721 0003721 00000011452 14166627112 025651 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests for features of Python3.5 or higher.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
These are Python3.5 specific constructs, that will give a SyntaxError or
not be relevant on older versions.
"""
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
# Tests do all bad things:
# pylint: disable=not-an-iterable
import asyncio
import types
from nuitka.PythonVersions import python_version
from nuitka.tools.testing.Common import executeReferenceChecked, run_async
# Tests do bad stuff, pylint: disable=redefined-outer-name
def raisy():
raise TypeError
def simpleFunction1():
async def someCoroutine():
return
run_async(someCoroutine())
####################################
def simpleFunction2():
async def someCoroutine():
return 7
run_async(someCoroutine())
####################################
class AsyncIteratorWrapper:
def __init__(self, obj):
self._it = iter(obj)
def __aiter__(self):
return self
async def __anext__(self):
try:
value = next(self._it)
except StopIteration:
raise StopAsyncIteration
return value
def simpleFunction3():
async def f():
result = []
# Python 3.5 before 3.2 won't allow this.
try:
async for letter in AsyncIteratorWrapper("abcdefg"):
result.append(letter)
except TypeError:
assert sys.version_info < (3, 5, 2)
return result
run_async(f())
####################################
def simpleFunction4():
async def someCoroutine():
raise StopIteration
try:
run_async(someCoroutine())
except RuntimeError:
pass
####################################
class ClassWithAsyncMethod:
async def async_method(self):
return self
def simpleFunction5():
run_async(ClassWithAsyncMethod().async_method())
####################################
class BadAsyncIter:
def __init__(self):
self.weight = 1
async def __aiter__(self):
return self
def __anext__(self):
return ()
def simpleFunction7():
async def someCoroutine():
async for _i in BadAsyncIter():
print("never going to happen")
try:
run_async(someCoroutine())
except TypeError:
pass
def simpleFunction8():
async def someCoroutine():
return ("some", "thing")
@types.coroutine
def someDecoratorCoroutine():
yield from someCoroutine()
run_async(someDecoratorCoroutine())
def simpleFunction9():
a = {"a": 1, "b": 2}
b = {"c": 3, **a}
return b
async def rmtree(path):
return await asyncio.get_event_loop().run_in_executor(None, sync_rmtree, path)
def sync_rmtree(path):
raise FileNotFoundError
async def execute():
try:
await rmtree("/tmp/test1234.txt")
except FileNotFoundError:
pass
return 10 ** 10
async def run():
await execute()
def simpleFunction10():
asyncio.get_event_loop().run_until_complete(run())
def nosimpleFunction11():
async def someCoroutine():
return 10
coro = someCoroutine()
def someGenerator():
yield from coro
try:
list(someGenerator())
except TypeError:
pass
coro.close()
# These need stderr to be wrapped.
tests_stderr = ()
# Disabled tests
tests_skipped = {}
if python_version < 0x380:
tests_skipped[10] = "Incompatible refcount bugs of asyncio with python prior 3.8"
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/Functions_2.py 0000600 0003721 0003721 00000005105 14166627112 025441 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Various kinds of functions definitions with Python2 only features.
Esp. nested arguments are no longer allowed in Python3 and covered here
to make sure they are not forgotten.
"""
from __future__ import print_function
# pylint: disable=redefined-outer-name
def local_function(a, z=9):
b = ` a * a + 1 `
c = (a, b, a ** 32, a + a)
d = long("0")
e = int("77")
d = long(b)
e = long(1 + 1)
return a, b, c, d, e, z
print(
"Call function with many variables calculated and returned", local_function(1, z=5)
)
print("Function with nested args:")
def nested_args_function((a, b), c):
return a, b, c
print(nested_args_function((1, 2), 3))
try:
nested_args_function((1, 2, 3), 3)
except ValueError, e:
print("Calling nested with too long tuple gave:", e)
try:
nested_args_function((1,), 3)
except ValueError, e:
print("Calling nested with too short tuple gave:", e)
def deeply_nested_function(((a,), b, c, (d, (e, f)))):
return a, b, c, d, e, f
print("Deeply nested function", deeply_nested_function(((1,), 2, 3, (4, (5, 6)))))
print("Function with nested args that have defaults:")
def default_giver():
class SomeClass: # pylint: disable=old-style-class
def __iter__(self):
print("Giving iter")
return iter(range(2))
return SomeClass()
def nested_args_function_with_defaults((a, b)=default_giver(), c=5):
return a, b, c
print("Calling it.")
print(nested_args_function_with_defaults())
def comp_args1((a, b)):
return a, b
def comp_args2((a, b)=(3, 4)):
return a, b
def comp_args3(a, (b, c)):
return a, b, c
def comp_args4(a=2, (b, c)=(3, 4)):
return a, b, c
print(
"Complex args functions",
comp_args1((2, 1)),
comp_args2(),
comp_args2((7, 9)),
comp_args3(7, (8, 9)),
comp_args4(),
)
Nuitka-0.6.19.1/tests/basics/TryContinueFinally.py 0000600 0003721 0003721 00000004046 14166627112 027055 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def tryWhileContinueFinallyTest():
print("Check if finally is executed in a continue using for loop:")
x = 0
while x < 10:
x += 1
try:
if x % 2 == 1:
continue
finally:
print(x, end=" ")
print("-", end=" ")
print()
def tryForContinueFinallyTest():
print("Check if finally is executed in a continue using for loop:")
for x in range(10):
try:
if x % 2 == 1:
continue
finally:
print(x, end=" ")
print("-", end=" ")
print()
def tryWhileBreakFinallyTest():
print("Check if finally is executed in a break using while loop:")
x = 0
while x < 10:
x += 1
try:
if x == 5:
break
finally:
print(x, end=" ")
print("-", end=" ")
print()
def tryForBreakFinallyTest():
print("Check if finally is executed in a break using for loop:")
for x in range(10):
try:
if x == 5:
break
finally:
print(x, end=" ")
print("-", end=" ")
print()
tryWhileContinueFinallyTest()
tryWhileBreakFinallyTest()
tryForContinueFinallyTest()
tryForBreakFinallyTest()
Nuitka-0.6.19.1/tests/basics/ThreadedGenerators.py 0000600 0003721 0003721 00000002207 14166627112 027022 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# From Issue#146, this has crashed in the past.
import threading
def some_generator():
yield 1
def run():
for i in range(10000):
for j in some_generator():
pass
def main():
workers = [threading.Thread(target=run) for i in range(5)]
for t in workers:
t.start()
for t in workers:
t.join()
if __name__ == "__main__":
main()
Nuitka-0.6.19.1/tests/basics/Lamdas.py 0000600 0003721 0003721 00000003207 14166627112 024452 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def lamdaContainer(x):
f = lambda c: c
g = lambda c: c if x else c * c
# h = lambda c: 'a' <= c <= 'z'
y = f(x)
z = g(4)
print("Lambda with conditional expression gives", z)
if "a" <= x <= y <= "z":
print("Four")
if "a" <= x <= "z":
print("Yes")
if "a" <= x > "z":
print("Yes1")
if "a" <= ("1" if x else "2") > "z":
print("Yes2")
if "a" <= ("1" if x else "2") > "z" > undefined_global:
print("Yes3")
z = lambda huhu=y: huhu
print("Lambda defaulted gives", z())
lamdaContainer("b")
def lambdaGenerator():
x = lambda: (yield 3)
gen = x()
print("Lambda generator gives", next(gen))
lambdaGenerator()
def lambdaDirectCall():
args = range(7)
x = (lambda *args: args)(*args)
print("Lambda direct call gave", x)
lambdaDirectCall()
Nuitka-0.6.19.1/tests/basics/Unpacking35.py 0000600 0003721 0003721 00000003525 14166627112 025343 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def tupleUnpacking():
return (*a, b, *c)
def listUnpacking():
return [*a, b, *c]
def setUnpacking():
return {*a, b, *c}
def dictUnpacking():
return {"a": 1, **d}
a = range(3)
b = 5
c = range(8, 10)
d = {"a": 2}
print("Tuple unpacked", tupleUnpacking())
print("List unpacked", listUnpacking())
print("Set unpacked", setUnpacking())
print("Dict unpacked", dictUnpacking())
non_iterable = 2.0
def tupleUnpackingError():
try:
return (*a, *non_iterable, *c)
except Exception as e:
return e
def listUnpackingError():
try:
return [*a, *non_iterable, *c]
except Exception as e:
return e
def setUnpackingError():
try:
return {*a, *non_iterable, *c}
except Exception as e:
return e
def dictUnpackingError():
try:
return {"a": 1, **non_iterable}
except Exception as e:
return e
print("Tuple unpacked error:", tupleUnpackingError())
print("List unpacked error:", listUnpackingError())
print("Set unpacked error:", setUnpackingError())
print("Dict unpacked error:", dictUnpackingError())
Nuitka-0.6.19.1/tests/basics/BuiltinOverload.py 0000600 0003721 0003721 00000002120 14166627112 026344 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
try:
from __builtin__ import len as _len
except ImportError:
from builtins import len as _len
# This kind of built-in overload will have to work.
def len(x):
print("Private built-in called with argument", repr(x))
return _len(x)
print("Calling built-in len", len(range(9)))
Nuitka-0.6.19.1/tests/basics/DoubleDeletions.py 0000600 0003721 0003721 00000002101 14166627112 026322 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
a = 3
del a
try:
del a
except NameError as e:
print("Raised expected exception:", repr(e))
def someFunction(b, c):
b = 1
del b
try:
del b
except UnboundLocalError as e:
print("Raised expected exception:", repr(e))
someFunction(3, 4)
Nuitka-0.6.19.1/tests/basics/Looping.py 0000600 0003721 0003721 00000006401 14166627112 024657 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Looping in various forms.
"""
from __future__ import print_function
# pylint: disable=superfluous-parens,useless-else-on-loop,using-constant-test
def cond():
return False
def loopingFunction(a=1 * 2):
c = []
f = [c, a]
for a in range(6 or 8):
for b in range(8):
if a == b:
c.append((a, b, True))
elif a < b:
c.append((b, a, False))
else:
c.append((a, b, False))
if a != b:
z = 1
else:
z = 0
if z == 0:
continue
if z == 1 and b == 6:
break
if a == b:
z = 0
print(c)
print(f)
f = 1
while f < (10 or 8):
m = 1
f += 1
print("m=", m)
x = [u for u in range(8)]
print(x)
x = [(u, v) for (u, v) in zip(range(8), reversed(range(8)))]
print(x)
x = [(u if u % 2 == 0 else 0) for u in range(10)]
print(x)
x = [(u if u % 2 == 0 else 0) for u in (a if cond() else range(9))]
print(x)
y = [[3 + (l if l else -1) for l in [m, m + 1]] for m in [f for f in range(2)]]
print("f=", f)
print("y=", y)
if x:
l = "YES"
else:
l = "NO"
if x:
l = "yes"
else:
if True:
l = "no"
print("Triple and chain")
if m and l and f:
print("OK")
print("Triple or chain")
if m or l or f:
print("Okey")
print("Nested if not chain")
if not m:
if not l:
print("ok")
print("Braced if not chain with 'or'")
if not (m or l):
print("oki")
print("Braced if not chain with 'and'")
if not (m and l):
print("oki")
d = 1
print("Nested if chain with outer else")
if a:
if b or c:
if d:
print("inside nest")
else:
print("outer else")
print(x)
while False:
pass
else:
print("Executed else branch for False condition while loop")
while True:
break
else:
print("Executed else branch for True condition while loop")
for x in range(7):
pass
else:
print("Executed else branch for no break for loop")
for x in range(7):
break
else:
print("Executed else branch despite break in for loop")
x = iter(range(5))
while next(x):
pass
else:
print("Executed else branch of while loop without break")
loopingFunction()
Nuitka-0.6.19.1/tests/basics/Future32.py 0000600 0003721 0003721 00000001572 14166627112 024673 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import barry_as_FLUFL
print(eval("1 <> 2"))
print(eval('"a"<>"b"'))
print(eval("range(7) <> range(7)"))
Nuitka-0.6.19.1/tests/basics/ExceptionRaising.py 0000600 0003721 0003721 00000034067 14166627112 026534 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
print("Raising an exception type in a function:")
def raiseExceptionClass():
raise ValueError
try:
raiseExceptionClass()
except Exception as e:
print("Caught exception type", e, repr(e), type(e))
print("Inside handler, sys.exc_info is this", sys.exc_info())
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Raising an exception instance in a function:")
def raiseExceptionInstance():
raise ValueError("hallo")
try:
raiseExceptionInstance()
except Exception as f:
print("Caught exception instance", f, repr(f), type(f))
print("Inside handler, sys.exc_info is this", sys.exc_info())
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Raising an exception, then catch it to re-raise it:")
def raiseExceptionAndReraise(arg):
try:
return arg / arg
except:
raise
try:
raiseExceptionAndReraise(0)
except:
print("Catched reraised", sys.exc_info())
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Access an undefined global variable in a function:")
def raiseNonGlobalError():
return undefined_value
try:
raiseNonGlobalError()
except:
print("NameError caught", sys.exc_info())
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Raise a new style class as an exception, should be rejected:")
def raiseIllegalError():
class X(object):
pass
raise X()
try:
raiseIllegalError()
except TypeError as E:
print("New style class exception correctly rejected:", E)
except:
print(sys.exc_info())
assert False, "Error, new style class exception was not rejected"
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Raise an old-style class, version dependent outcome:")
class ClassicClassException:
pass
def raiseCustomError():
raise ClassicClassException()
try:
try:
raiseCustomError()
except ClassicClassException:
print("Caught classic class exception")
except:
print("Default catch", sys.exc_info())
assert False, "Error, old style class exception was not caught"
except TypeError as e:
print("Python3 hates to even try and catch classic classes", e)
else:
print("Classic exception catching was considered fine.")
print("After catching, sys.exc_info is this", sys.exc_info())
print("*" * 20)
print("Check lazy exception creation:")
def checkExceptionConversion():
try:
raise Exception("some string")
except Exception as err:
print("Catched raised object", err, type(err))
try:
raise Exception, "some string"
except Exception as err:
print("Catched raised type, value pair", err, type(err))
checkExceptionConversion()
print("*" * 20)
print("Check exc_info scope:")
def checkExcInfoScope():
try:
raise ValueError
except:
assert sys.exc_info()[0] is not None
assert sys.exc_info()[1] is not None
assert sys.exc_info()[2] is not None
if sys.version_info[0] < 3:
print("Exc_info remains visible after exception handler for Python2")
assert sys.exc_info()[0] is not None
assert sys.exc_info()[1] is not None
assert sys.exc_info()[2] is not None
else:
print("Exc_info is clear after exception handler for Python3")
assert sys.exc_info()[0] is None
assert sys.exc_info()[1] is None
assert sys.exc_info()[2] is None
def subFunction():
print("Entering with exception info", sys.exc_info())
assert sys.exc_info()[0] is not None
assert sys.exc_info()[1] is not None
assert sys.exc_info()[2] is not None
try:
print("Trying")
except:
pass
print(
"After trying something and didn't have an exception, info is",
sys.exc_info(),
)
print("Call a function inside the exception handler and check there too.")
try:
raise KeyError
except:
assert sys.exc_info()[0] is not None
assert sys.exc_info()[1] is not None
assert sys.exc_info()[2] is not None
subFunction()
print("Call it twice and see.")
try:
raise "me"
except:
assert sys.exc_info()[0] is not None
assert sys.exc_info()[1] is not None
assert sys.exc_info()[2] is not None
subFunction()
subFunction()
if sys.version_info[0] < 3:
sys.exc_clear()
checkExcInfoScope()
print("*" * 20)
# Check that the sys.exc_info is cleared again, after being set inside the
# function checkExcInfoScope, it should now be clear again.
assert sys.exc_info()[0] is None, sys.exc_info()[0]
assert sys.exc_info()[1] is None
assert sys.exc_info()[2] is None
print("Check catching subclasses")
def checkDerivedCatch():
class A(BaseException):
pass
class B(A):
def __init__(self):
pass
a = A()
b = B()
try:
raise A, b
except B, v:
print("Caught B", v)
except A, v:
print("Didn't catch as B, but as A, Python3 does that", v)
else:
print("Not caught A class, not allowed to happen.")
try:
raise B, a
except TypeError, e:
print("TypeError with pair form for class not taking args:", e)
checkDerivedCatch()
print("*" * 20)
def checkNonCatch1():
print("Testing if the else branch is executed in the optimizable case:")
try:
0
except TypeError:
print("Should not catch")
else:
print("Executed else branch correctly")
checkNonCatch1()
print("*" * 20)
def checkNonCatch2():
try:
print("Testing if the else branch is executed in the non-optimizable case:")
except TypeError:
print("Should not catch")
else:
print("Executed else branch correctly")
checkNonCatch2()
print("*" * 20)
print("Checking raise that with exception arguments that raise error themselves.")
def checkRaisingRaise():
def geterror():
return 1 / 0
try:
geterror()
except Exception as e:
print("Had exception", e)
try:
raise TypeError, geterror()
except Exception as e:
print("Had exception", e)
try:
raise TypeError, 7, geterror()
except Exception as e:
print("Had exception", e)
checkRaisingRaise()
print("*" * 20)
print("Checking a re-raise that isn't one:")
def checkMisRaise():
raise
try:
checkMisRaise()
except Exception as e:
print("Without existing exception, re-raise gives:", e)
print("*" * 20)
print("Raising an exception in an exception handler gives:")
def nestedExceptions(a, b):
try:
a / b
except ZeroDivisionError:
a / b
try:
nestedExceptions(1, 0)
except Exception as e:
print("Nested exception gives", e)
print("*" * 20)
print("Checking unpacking from an exception as a sequence:")
def unpackingCatcher():
try:
raise ValueError(1, 2)
except ValueError as (a, b):
print("Unpacking caught exception and unpacked", a, b)
unpackingCatcher()
print("Afterwards, exception info is", sys.exc_info())
print("*" * 20)
print("Testing exception that escapes __del__ and therefore cannot be raised")
def devide(a, b):
return a / b
def unraisableExceptionInDel():
class C:
def __del__(self):
c = devide(1, 0)
print(c)
def f():
C()
f()
unraisableExceptionInDel()
print("*" * 20)
print("Testing exception changes between generator switches:")
def yieldExceptionInteraction():
def yield_raise():
print("Yield finds at generator entry", sys.exc_info()[0])
try:
raise KeyError("caught")
except KeyError:
yield sys.exc_info()[0]
yield sys.exc_info()[0]
yield sys.exc_info()[0]
g = yield_raise()
print("Initial yield from catch in generator", next(g))
print("Checking from outside of generator", sys.exc_info()[0])
print("Second yield from the catch reentered", next(g))
print("Checking from outside of generator", sys.exc_info()[0])
print("After leaving the catch generator yielded", next(g))
yieldExceptionInteraction()
print("*" * 20)
print(
"Testing exception change between generator switches while handling an own exception"
)
def yieldExceptionInteraction2():
def yield_raise():
print("Yield finds at generator entry", sys.exc_info()[0])
try:
raise ValueError("caught")
except ValueError:
yield sys.exc_info()[0]
yield sys.exc_info()[0]
yield sys.exc_info()[0]
try:
undefined_global
except Exception:
print("Checking from outside of generator with", sys.exc_info()[0])
g = yield_raise()
v = next(g)
print("Initial yield from catch in generator:", v)
print("Checking from outside the generator:", sys.exc_info()[0])
print("Second yield from the catch reentered:", next(g))
print("Checking from outside the generation again:", sys.exc_info()[0])
print("After leaving the catch generator yielded:", next(g))
print("After exiting the trying branch:", sys.exc_info()[0])
yieldExceptionInteraction2()
print("After function exit, no exception", sys.exc_info())
print("*" * 20)
print("Check what happens if a function attempts to clear the exception in a handler")
def clearingException():
def clearit():
try:
if sys.version_info[0] < 3:
sys.exc_clear()
except KeyError:
pass
try:
raise KeyError
except:
print("Before clearing, it's", sys.exc_info())
clearit()
print("After clearing, it's", sys.exc_info())
clearingException()
print("*" * 20)
print("Check that multiple exceptions can be caught in a handler through a variable:")
def multiCatchViaTupleVariable():
some_exceptions = (KeyError, ValueError)
try:
raise KeyError
except some_exceptions:
print("Yes, indeed.")
multiCatchViaTupleVariable()
def raiseValueWithValue():
try:
raise ValueError(1, 2, 3), (ValueError(1, 2, 3))
except Exception as e:
print("Gives", e)
print("Check exception given when value is raised with value", raiseValueWithValue())
# Make sure the "repr" of exceptions is fine
a = IOError
print("IOError is represented correctly:", repr(a))
def raising():
raise ValueError
def not_raising():
pass
def raiseWithFinallyNotCorruptingLineNumber():
try:
try:
raising()
finally:
not_raising()
except ValueError:
print("Traceback is in tried block line", sys.exc_info()[2].tb_lineno)
raiseWithFinallyNotCorruptingLineNumber()
def wideCatchMustPublishException():
print("At entry, no exception", sys.exc_info())
try:
undefined_global
except:
print("Inside handler:", sys.exc_info())
pass
print("Outside handler:", sys.exc_info())
print("Check that a unqualified catch properly preserves exception")
wideCatchMustPublishException()
print("Check if a nested exception handler does overwrite re-raised")
def checkReraiseAfterNestedTryExcept():
def reraise():
try:
raise TypeError("outer")
except Exception:
try:
raise KeyError("nested")
except KeyError:
print("Current exception inside nested handler", sys.exc_info())
pass
print("Current exception after nested handler exited", sys.exc_info())
# Which one does this pick
raise
try:
reraise()
except Exception as e:
print("Catched", repr(e))
checkReraiseAfterNestedTryExcept()
def checkReraiseByFunction():
def reraise():
raise
try:
try:
raise TypeError("outer")
except Exception:
reraise()
except Exception as e:
import traceback
print("Exception traceback of re-raise:")
print("-" * 40)
traceback.print_exc()
print("-" * 40)
print("OK.")
# TODO: Enable this, once the actual traceback of a function
# re-raise isn't wrong (contains itself) anymore.
if False:
checkReraiseByFunction()
def checkNoRaiseExceptionDictBuilding(arg):
a = {(): arg}
b = {None: arg}
c = {Ellipsis: arg}
d = {1.0j: arg}
e = {1.0: arg}
f = {long(0): arg}
g = {0: arg}
h = {type: arg}
return a, b, c, d, e, f, g, h
checkNoRaiseExceptionDictBuilding(1)
def checkRaiseExceptionDictBuildingRange(arg):
try:
i = {range(10): arg}
except Exception as e:
print("Raised", repr(e))
else:
print("No exception, OK for Python2")
return i
print("Check if range as dict key raises:")
checkRaiseExceptionDictBuildingRange(2)
def checkRaiseExceptionDictBuildingTuple(arg):
try:
i = {(2, []): arg}
except Exception as e:
print("Raised", repr(e))
else:
return i
print("Check if mutable tuple as dict key raises:")
checkRaiseExceptionDictBuildingTuple(3)
def checkRaiseExceptionDictBuildingList(arg):
try:
i = {[2, ()]: arg}
except Exception as e:
print("Raised", repr(e))
else:
return i
print("Check if list as dict key raises:")
checkRaiseExceptionDictBuildingList(4)
Nuitka-0.6.19.1/tests/basics/Inspection_36.py 0000600 0003721 0003721 00000003122 14166627112 025670 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Tests uncompiled functions and compiled functions responses to inspect and isistance. """
import inspect
import types
# nuitka-project: --python-flag=no_warnings
async def compiledAsyncgen():
yield 1
print(type(compiledAsyncgen()))
assert inspect.isfunction(compiledAsyncgen) is True
assert inspect.isgeneratorfunction(compiledAsyncgen) is False
assert inspect.iscoroutinefunction(compiledAsyncgen) is False
assert inspect.isasyncgenfunction(compiledAsyncgen) is True
assert isinstance(compiledAsyncgen(), types.GeneratorType) is False
assert isinstance(compiledAsyncgen(), types.CoroutineType) is False
assert isinstance(compiledAsyncgen(), types.AsyncGeneratorType) is True
assert type(compiledAsyncgen()) == types.AsyncGeneratorType, type(compiledAsyncgen())
assert isinstance(compiledAsyncgen, types.AsyncGeneratorType) is False
Nuitka-0.6.19.1/tests/basics/Classes34.py 0000600 0003721 0003721 00000002422 14166627112 025013 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from enum import Enum
print("Enum class with duplicate enumeration values:")
try:
class Color(Enum):
red = 1
green = 2
blue = 3
red = 4
print("not allowed to get here")
except Exception as e:
print("Occurred", e)
print("Class variable that conflicts with closure variable:")
def testClassNamespaceOverridesClosure():
# See #17853.
x = 42
class X:
locals()["x"] = 43
y = x
print("should be 43:", X.y)
testClassNamespaceOverridesClosure()
Nuitka-0.6.19.1/tests/basics/Asserts.py 0000600 0003721 0003721 00000003222 14166627112 024672 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
def testAssert1():
assert False
return 1
def testAssert2():
assert True
return 1
def testAssert3():
assert False, "argument"
return 1
try:
print("Function that will assert.")
testAssert1()
print("No exception.")
except Exception as e:
print("Raised", type(e), e)
try:
print("Function that will not assert.")
testAssert2()
print("No exception.")
except Exception as e:
print("Raised", type(e), e)
try:
print("Function that will assert with argument.")
testAssert3()
print("No exception.")
except Exception as e:
print("Raised", type(e), e)
try:
print("Assertion with tuple argument.", end="")
assert False, (3,)
except AssertionError as e:
print(str(e))
try:
print("Assertion with plain argument.", end="")
assert False, 3
except AssertionError as e:
print(str(e))
Nuitka-0.6.19.1/tests/basics/GeneratorExpressions_37.py 0000600 0003721 0003721 00000002021 14166627112 027744 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Test case with generator expression form only allow until Python 3.7
"""
def strangeLambdaGeneratorExpression():
x = ((yield) for i in (1, 2) if (yield))
print("Strange lambda generator expression:")
print(list(x))
strangeLambdaGeneratorExpression()
Nuitka-0.6.19.1/tests/basics/ExtremeClosure.py 0000600 0003721 0003721 00000002613 14166627112 026217 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" These tests contain all forms of closure absuse.
"""
from __future__ import print_function
a = 1
b = 1
def someFunction():
a = a # pylint: disable=redefined-outer-name,unused-variable
class SomeClass:
b = b
SomeClass()
try:
someFunction()
except UnboundLocalError as e:
print("Expected unbound local error occurred:", repr(e))
try:
class AnotherClass:
b = undefined_global
except NameError as e:
print("Expected name error occurred:", repr(e))
try:
class YetAnotherClass:
b = 1
del b
print(b)
except NameError as e:
print("Expected name error occurred:", repr(e))
Nuitka-0.6.19.1/tests/basics/Empty.py 0000600 0003721 0003721 00000001401 14166627112 024341 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Nuitka-0.6.19.1/tests/basics/WithStatements.py 0000600 0003721 0003721 00000011417 14166627112 026236 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import sys
x = 0
# This is used to trace the exact interaction with the context manager to
# uncover and decide ordering and correctness of calls.
class MyContextManager(object):
def __getattribute__(self, attribute_name):
print("Asking context manager attribute", attribute_name)
return object.__getattribute__(self, attribute_name)
def __enter__(self):
global x
x += 1
print("Entered context manager with counter value", x)
return x
def __exit__(self, exc_type, exc_value, traceback):
print("Context manager exit sees", exc_type, exc_value, traceback)
print("Published to context manager exit is", sys.exc_info())
return False
print("Use context manager and raise no exception in the body:")
with MyContextManager() as x:
print("x has become", x)
print("Use context manager and raise an exception in the body:")
try:
with MyContextManager() as x:
print("x has become", x)
raise Exception("Lalala")
print(x)
except Exception as e:
print("Caught raised exception", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
# Python3 ranges are not lists
l = list(range(3))
print("Use context manager and assign to subscription target:")
with MyContextManager() as l[0]:
print("Complex assignment target works", l[0])
try:
with MyContextManager():
sys.exit(9)
except BaseException as e:
print("Caught base exception", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
print("Use context manager and fail to assign to attribute:")
try:
with MyContextManager() as l.wontwork:
sys.exit(9)
except BaseException as e:
print("Caught base exception", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
print("Use context manager to do nothing inside:")
with MyContextManager() as x:
pass
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
# Use context manager and fail to assign.
def returnFromContextBlock():
# Use context manager to do nothing.
with MyContextManager() as x:
return 7
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
print("Use context manager to return value:")
r = returnFromContextBlock()
print("Return value", r)
class NonContextManager1:
def __enter__(self):
return self
class NonContextManager2:
def __exit__(self):
return self
print("Use incomplete context managers:")
try:
with NonContextManager1() as x:
print(x)
except Exception as e:
print("Caught for context manager without __exit__", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
try:
with NonContextManager2() as x:
print(x)
except Exception as e:
print("Caught for context manager without __enter__", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
class NotAtAllContextManager:
pass
try:
with NotAtAllContextManager() as x:
print(x)
except Exception as e:
print("Caught for context manager without any special methods", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
class MeanContextManager:
def __enter__(self):
raise ValueError("Nah, I won't play")
def __exit__(self):
print("Called exit, yes")
print("Use mean context manager:")
try:
with MeanContextManager() as x:
print(x)
except Exception as e:
print("Caught from mean manager", repr(e))
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
class CatchingContextManager(object):
def __enter__(self):
pass
def __exit__(self, exc_type, exc_value, traceback):
return True
print("Suppressing exception from context manager body:")
with CatchingContextManager():
raise ZeroDivisionError
if sys.version_info >= (3,):
assert sys.exc_info() == (None, None, None)
print("OK")
Nuitka-0.6.19.1/tests/basics/Functions32.py 0000600 0003721 0003721 00000006634 14166627112 025375 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def displayDict(d):
result = "{"
for key, value in sorted(d.items()):
result += "%s: %s" % (key, value)
result += "}"
def kwonlysimple(*, a):
return a
print("Keyword only function case: ", kwonlysimple(a=3))
def kwonlysimpledefaulted(*, a=5):
return a
print("Keyword only function, using default value: ", kwonlysimpledefaulted())
def default1():
print("Called", default1)
return 1
def default2():
print("Called", default2)
return 2
def default3():
print("Called", default3)
return 3
def default4():
print("Called", default4)
return 4
def annotation1():
print("Called", annotation1)
return "a1"
def annotation2():
print("Called", annotation2)
return "a2"
def annotation3():
print("Called", annotation3)
return "a3"
def annotation4():
print("Called", annotation4)
return "a4"
def annotation5():
print("Called", annotation5)
return "a5"
def annotation6():
print("Called", annotation6)
return "a6"
def annotation7():
print("Called", annotation7)
return "a7"
def annotation8():
print("Called", annotation8)
return "a8"
def annotation9():
print("Called", annotation9)
return "a9"
print("Defining function with annotations, and defaults as functions for everything:")
def kwonlyfunc(
x: annotation1(),
y: annotation2() = default1(),
z: annotation3() = default2(),
*,
a: annotation4(),
b: annotation5() = default3(),
c: annotation6() = default4(),
d: annotation7(),
**kw: annotation8()
) -> annotation9():
print(x, y, z, a, b, c, d)
print("__kwdefaults__", displayDict(kwonlyfunc.__kwdefaults__))
print("Keyword only function called:")
kwonlyfunc(7, a=8, d=12)
print("OK.")
print("Annotations come out as", sorted(kwonlyfunc.__annotations__))
kwonlyfunc.__annotations__ = {}
print("After updating to None it is", kwonlyfunc.__annotations__)
kwonlyfunc.__annotations__ = {"k": 9}
print("After updating to None it is", kwonlyfunc.__annotations__)
def kwonlystarfunc(*, a, b, **d):
return a, b, d
print("kwonlystarfunc", kwonlystarfunc(a=8, b=12, k=9, j=7))
def deeplyNestedNonLocalWrite():
x = 0
y = 0
def f():
def g():
nonlocal x
x = 3
return x
return g()
return f(), x
print("Deeply nested non local writing function", deeplyNestedNonLocalWrite())
def deletingClosureVariable():
try:
x = 1
def g():
nonlocal x
del x
g()
g()
except Exception as e:
return repr(e)
print("Using deleted non-local variable:", deletingClosureVariable())
Nuitka-0.6.19.1/tests/basics/Referencing_2.py 0000600 0003721 0003721 00000005523 14166627112 025724 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
These are for Python2 only constructs, which will give SyntaxError on
other versions.
"""
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
from nuitka.tools.testing.Common import executeReferenceChecked
x = 17
# Python2 only syntax things are here.
def simpleFunction1():
try:
raise TypeError, (3, x, x, x)
except TypeError:
pass
def simpleFunction2():
try:
raise ValueError(1, 2, 3), ValueError(1, 2, 3)
except Exception:
pass
def simpleFunction3():
try:
raise ValueError, 2, None
except Exception:
pass
def simpleFunction4():
try:
raise ValueError, 2, 3
except Exception:
pass
def simpleFunction5():
def nested_args_function((a, b), c):
return a, b, c
nested_args_function((1, 2), 3)
def simpleFunction6():
def nested_args_function((a, b), c):
return a, b, c
try:
nested_args_function((1,), 3)
except ValueError:
pass
def simpleFunction7():
def nested_args_function((a, b), c):
return a, b, c
try:
nested_args_function((1, 2, 3), 3)
except ValueError:
pass
def simpleFunction8():
from decimal import *
d1 = Decimal("5")
d2 = Decimal("2")
(p, q) = divmod(d1, d2)
(p, q) = divmod(d1, 4)
(p, q) = divmod(7, d1)
return q, p
# These need stderr to be wrapped.
tests_stderr = ()
# Disabled tests
tests_skipped = {}
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/run_xml.py 0000700 0003721 0003721 00000004331 14166627112 024735 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 #!/usr/bin/env python
# Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import print_function
import os, sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
import shutil
import subprocess
from nuitka.tools.testing.Common import check_output
# Go its own directory, to have it easy with path knowledge.
nuitka1 = sys.argv[1]
nuitka2 = sys.argv[2]
search_mode = len(sys.argv) > 3 and sys.argv[3] == "search"
start_at = sys.argv[4] if len(sys.argv) > 4 else None
if start_at:
active = False
else:
active = True
my_dir = os.path.dirname(os.path.abspath(__file__))
for filename in sorted(os.listdir(my_dir)):
if not filename.endswith(".py") or filename.startswith("run_"):
continue
path = os.path.relpath(os.path.join(my_dir, filename))
if not active and start_at in (filename, path):
active = True
if active:
command = "%s %s '%s' '%s' %s" % (
sys.executable,
os.path.join(my_dir, "..", "..", "bin", "compare_with_xml"),
nuitka1,
nuitka2,
path,
)
result = subprocess.call(command, shell=True)
if result == 2:
sys.stderr.write("Interrupted, with CTRL-C\n")
sys.exit(2)
if result != 0 and search_mode:
print("Error exit!", result)
sys.exit(result)
else:
print("Skipping", filename)
Nuitka-0.6.19.1/tests/basics/Classes.py 0000600 0003721 0003721 00000011247 14166627112 024651 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def displayDict(d):
if "__loader__" in d:
d = dict(d)
d["__loader__"] = "<__loader__ removed>"
if "__file__" in d:
d = dict(d)
d["__file__"] = "<__file__ removed>"
# Avoid recursion that we don't offer for classes.
if "__locals__" in d:
d = dict(d)
del d["__locals__"]
import pprint
return pprint.pformat(d)
class SimpleClass:
" The class documentation." # Leading space on purpose.
# TODO: Doesn't work with Python3, because we don't yet make our own dict
# visible. print locals()
print "Class locals, while building", displayDict(locals())
class_var = 1
def __init__(self, init_parameter):
self.x = init_parameter
def normal_method(self, arg1, arg2):
self.arg1 = arg1
self.arg2 = arg2
return self.arg1, self.arg2, self.x, self
@staticmethod
def static_method():
return "something"
print "Simple class:", SimpleClass
print "Lives in", SimpleClass.__module__
print "Documentation", SimpleClass.__doc__
print "Instantiate simple class:", SimpleClass(14)
print "Call simple class normal method:", SimpleClass(11).normal_method(1, 2)
print "Call simple class static method:", SimpleClass(11).static_method()
class MetaClass(type):
def __init__(cls, name, bases, dictionary):
print "MetaClass is called."
cls.addedin = 5
print MetaClass
class ComplexClass:
__metaclass__ = MetaClass
print ComplexClass, dir(ComplexClass)
print ComplexClass, hasattr(ComplexClass, "addedin") and ComplexClass.addedin
def function():
x = 1
class DynamicClass:
y = x
x = 2
return DynamicClass
print function(), function().y
def strangeClassBehaviour():
class StrangeClass(object):
count = 0
def __new__(cls):
print "__new__"
cls.count += 1
return object.__new__(cls)
def __del__(self):
print "__del__"
cls = self.__class__
cls.count -= 1
assert cls.count >= 0
x = StrangeClass()
return x.count
print "Strange class with __new__ and __del__ overloads", strangeClassBehaviour()
class ClosureLocalizer:
function = function
# Using what looks like a method as a decorator.
def deco(f): # @NoSelf
f.decorated = True
return f
@deco
def x(self):
pass
print "Class with a name from module level renamed to local", ClosureLocalizer.function
print "Class method decorated", ClosureLocalizer().x.decorated
print "Class with decorator and meta class:"
def classdecorator(cls):
print "cls decorator", cls.addedin
return cls
@classdecorator
class MyClass:
__metaclass__ = MetaClass
print "Class that updates its locals:",
class DictUpdating:
a = 1
locals().update({"b": 2})
for f in range(6):
locals()["test_%s" % f] = f
print "Changed values", DictUpdating.b, DictUpdating.test_4
def functionThatOffersClosureToPassThroughClass(x):
class Foo:
global x
x = 1
def __call__(self, y):
return x + y
return Foo()
print functionThatOffersClosureToPassThroughClass(6)(2),
print x
class NameCollisionClosure:
def x(self):
return x
print NameCollisionClosure, NameCollisionClosure().x()
class ClassesWithNestedClass:
class NestedClass(object):
def getDict(self):
return {"a": 2}
print "Classes:"
print ClassesWithNestedClass,
print ClassesWithNestedClass().NestedClass,
print ClassesWithNestedClass().NestedClass().getDict()
secondary = "global closure wins"
class ClassWithModuleVariableCollisionMain:
secondary = None
def __init__(self):
self.secondary = self.Child()
self.value = self.secondary.attr
class Child:
def __init__(self):
self.attr = secondary
print ClassWithModuleVariableCollisionMain, ClassWithModuleVariableCollisionMain().value
Nuitka-0.6.19.1/tests/basics/Referencing33.py 0000600 0003721 0003721 00000016754 14166627112 025661 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
""" Reference counting tests for features of Python3.3 or higher.
These contain functions that do specific things, where we have a suspect
that references may be lost or corrupted. Executing them repeatedly and
checking the reference count is how they are used.
These are Python3 specific constructs, that will give a SyntaxError or
not be relevant on Python2.
"""
# While we use that for comparison code, no need to compile that.
# nuitka-project: --nofollow-import-to=nuitka
import os
import sys
# Find nuitka package relative to us.
sys.path.insert(
0,
os.path.normpath(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..")
),
)
# isort:start
import types
from nuitka.tools.testing.Common import (
executeReferenceChecked,
someGenerator,
someGeneratorRaising,
)
def simpleFunction1():
def abc(*, _exc=IOError):
pass
for _ in range(100):
abc()
def simpleFunction2():
def abc(*, exc=IOError):
raise ValueError from None
try:
abc()
except (ValueError, TypeError):
pass
def simpleFunction3():
try:
class ClassA(Exception):
pass
class ClassB(Exception):
pass
try:
raise ClassA("foo")
except ClassA as e1:
raise ClassB(str(e1)) from e1
except Exception: # different to Nuitka, pylint: disable=broad-except
pass
def simpleFunction4():
a = 1
def nonlocal_writer():
nonlocal a
for a in range(10): # false alarm, pylint: disable=unused-variable
pass
nonlocal_writer()
assert a == 9, a
def simpleFunction5():
x = 2
def local_func(_a: int, _b: x * x):
pass
local_func(x, x)
def simpleFunction6():
# Make sure exception state is cleaned up as soon as the except
# block is left.
class MyException(Exception):
def __init__(self, obj):
# This is on purpose not called, pylint: disable=super-init-not-called
self.obj = obj
class MyObj:
pass
def inner_raising_func():
local_ref = obj
raise MyException(obj)
# "except" block raising another exception
obj = MyObj()
try:
try:
inner_raising_func()
except:
raise KeyError
except KeyError as e: # on purpose, pylint: disable=unused-variable
pass
range_low = 0
range_high = 256
range_step = 13
def simpleFunction7():
# Make sure xranges work nicely
return range(range_low, range_high, range_step)
def simpleFunction8():
# Make sure xranges work nicely
return range(range_low, range_high)
def simpleFunction9():
# Make sure xranges work nicely
return range(range_high)
def simpleFunction10():
def f(_x: int) -> int:
pass
return f
def simpleFunction11():
try:
raise ImportError(path="lala", name="lele")
except ImportError as e:
assert e.name == "lele"
assert e.path == "lala"
def simpleFunction12():
def g():
for a in range(20):
yield a
def h():
yield 4
yield 5
yield 6
def f():
yield from g()
yield from h()
_x = list(f())
def simpleFunction13():
def g():
for a in range(20):
yield a
def h():
yield 4
yield 5
yield 6
raise TypeError
def f():
yield from g()
yield from h()
try:
_x = list(f())
except TypeError:
pass
# Broken iterator class.
class Broken:
def __iter__(self):
return self
def __next__(self):
return 1
def __getattr__(self, attr):
1 / 0 # pylint: disable=pointless-statement
def simpleFunction14():
def g():
yield from Broken()
try:
gi = g()
next(gi)
except Exception: # pylint: disable=broad-except
pass
def simpleFunction15():
def g():
yield from Broken()
try:
gi = g()
next(gi)
gi.throw(AttributeError)
except Exception: # pylint: disable=broad-except
pass
def simpleFunction16():
def g():
yield from (2, 3)
return list(g())
def simpleFunction17():
def g():
yield from (2, 3)
return 9
return list(g())
def simpleFunction18():
def g():
yield from (2, 3)
return 9, 8
return list(g())
def simpleFunction19():
def g():
x = someGenerator()
assert type(x) is types.GeneratorType
yield from x
gen = g()
next(gen)
try:
gen.throw(ValueError)
except ValueError:
pass
def simpleFunction20():
def g():
x = someGeneratorRaising()
assert type(x) is types.GeneratorType
yield from x
gen = g()
next(gen)
try:
next(gen)
except TypeError:
pass
class ClassIteratorBrokenClose:
def __init__(self):
self.my_iter = iter(range(2))
def __iter__(self):
return self
def next(self):
return next(self.my_iter)
def close(self):
raise TypeError(3)
__next__ = next
def simpleFunction21():
def g():
x = ClassIteratorBrokenClose()
yield from x
gen = g()
next(gen)
try:
gen.throw(GeneratorExit)
except TypeError:
pass
class ClassIteratorBrokenThrow:
def __init__(self):
self.my_iter = iter(range(2))
def __iter__(self):
return self
def next(self):
return next(self.my_iter)
def throw(self, *args):
raise TypeError(3)
__next__ = next
def simpleFunction22():
def g():
x = ClassIteratorBrokenThrow()
yield from x
gen = g()
next(gen)
try:
gen.throw(ValueError)
except GeneratorExit:
pass
except TypeError:
pass
class ClassIteratorRejectingThrow:
def __init__(self):
self.my_iter = iter(range(2))
def __iter__(self):
return self
def next(self):
return next(self.my_iter)
def throw(self, *args):
# This should not be subject normalize exceptions.
assert len(args) == 1, args
__next__ = next
# Lets have an exception that must not be instantiated.
class MyError(Exception):
def __init__(self):
# pylint: disable=super-init-not-called
assert False
def simpleFunction23():
def g():
x = ClassIteratorRejectingThrow()
yield from x
gen = g()
next(gen)
gen.throw(MyError)
# These need stderr to be wrapped.
tests_stderr = (14, 15)
# Disabled tests
tests_skipped = {}
result = executeReferenceChecked(
prefix="simpleFunction",
names=globals(),
tests_skipped=tests_skipped,
tests_stderr=tests_stderr,
)
sys.exit(0 if result else 1)
Nuitka-0.6.19.1/tests/basics/TrickAssignments_2.py 0000600 0003721 0003721 00000003374 14166627112 026767 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
def someFunctionThatReturnsDeletedValueViaLong():
class C:
def __int__(self):
a.append(2)
return False
c = C()
a = [1]
long(c)
return a
if someFunctionThatReturnsDeletedValueViaLong()[-1] == 2:
print("OK, object long correctly modified an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaNot():
class C:
def __nonzero__(self):
a.append(2)
return False
c = C()
a = [1]
not c
return a
if someFunctionThatReturnsDeletedValueViaNot()[-1] == 2:
print("OK, object bool correctly modified an item.")
else:
print("Ouch.!")
def someFunctionThatReturnsDeletedValueViaCompare():
class C:
def __cmp__(self, other):
a.append(2)
return 0
c = C()
a = [1]
c < None
return a
if someFunctionThatReturnsDeletedValueViaCompare()[-1] == 2:
print("OK, object compare correctly modified an item.")
else:
print("Ouch.!")
Nuitka-0.6.19.1/tests/basics/RecursionTest.py 0000600 0003721 0003721 00000001556 14166627112 026067 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 # Copyright 2021, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
count = 0
def recurse():
global count
count += 1
if count < 50:
recurse()
recurse()
Nuitka-0.6.19.1/doc/ 0000700 0003721 0003721 00000000000 14167275622 021040 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/doc/nuitka2.1 0000600 0003721 0003721 00000052312 14167275621 022503 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH NUITKA "1" "January 2022" "nuitka 0.6.19.1" "User Commands"
.SH NAME
nuitka \- the Python compiler
.SH SYNOPSIS
.B nuitka
[\fI\,--module\/\fR] [\fI\,--run\/\fR] [\fI\,options\/\fR] \fI\,main_module.py\/\fR
.SH OPTIONS
.TP
\fB\-\-version\fR
show program's version number and exit
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-\-module\fR
Create an extension module executable instead of a
program. Defaults to off.
.TP
\fB\-\-standalone\fR
Enable standalone mode for output. This allows you to
transfer the created binary to other machines without
it using an existing Python installation. This also
means it will become big. It implies these option:
"\-\-follow\-imports". You may also want to use
"\-\-python\-flag=no_site" to avoid the "site.py" module,
which can save a lot of code dependencies. Defaults to
off.
.TP
\fB\-\-onefile\fR
On top of standalone mode, enable onefile mode. This
means not a folder, but a compressed executable is
created and used. Defaults to off.
.TP
\fB\-\-python\-debug\fR
Use debug version or not. Default uses what you are
using to run Nuitka, most likely a non\-debug version.
.TP
\fB\-\-python\-flag\fR=\fI\,FLAG\/\fR
Python flags to use. Default is what you are using to
run Nuitka, this enforces a specific mode. These are
options that also exist to standard Python executable.
Currently supported: "\-S" (alias "no_site"),
"static_hashes" (do not use hash randomization),
"no_warnings" (do not give Python runtime warnings),
"\-O" (alias "no_asserts"), "no_docstrings" (do not use
docstrings), and "\-m". Default empty.
.TP
\fB\-\-python\-for\-scons\fR=\fI\,PATH\/\fR
If using Python3.3 or Python3.4, provide the path of a
Python binary to use for Scons. Otherwise Nuitka can
use what you run Nuitka with or a "scons" binary that
is found in PATH, or a Python installation from
Windows registry.
.TP
\fB\-\-warn\-implicit\-exceptions\fR
Enable warnings for implicit exceptions detected at
compile time.
.TP
\fB\-\-warn\-unusual\-code\fR
Enable warnings for unusual code detected at compile
time.
.TP
\fB\-\-assume\-yes\-for\-downloads\fR
Allow Nuitka to download external code if necessary,
e.g. dependency walker, ccache, and even gcc on
Windows. To disable, redirect input from nul device,
e.g. "" is used. For compatibility reasons, the
"__file__" value will always have ".py" suffix
independent of what it really is.
.IP
Output choices:
.TP
\fB\-o\fR FILENAME
Specify how the executable should be named. For
extension modules there is no choice, also not for
standalone mode and using it will be an error. This
may include path information that needs to exist
though. Defaults to '' on this platform.
\&.bin
.TP
\fB\-\-output\-dir\fR=\fI\,DIRECTORY\/\fR
Specify where intermediate and final output files
should be put. The DIRECTORY will be populated with C
files, object files, etc. Defaults to current
directory.
.TP
\fB\-\-remove\-output\fR
Removes the build directory after producing the module
or exe file. Defaults to off.
.TP
\fB\-\-no\-pyi\-file\fR
Do not create a ".pyi" file for extension modules
created by Nuitka. This is used to detect implicit
imports. Defaults to off.
.IP
Debug features:
.TP
\fB\-\-debug\fR
Executing all self checks possible to find errors in
Nuitka, do not use for production. Defaults to off.
.TP
\fB\-\-unstripped\fR
Keep debug info in the resulting object file for
better debugger interaction. Defaults to off.
.TP
\fB\-\-profile\fR
Enable vmprof based profiling of time spent. Not
working currently. Defaults to off.
.TP
\fB\-\-internal\-graph\fR
Create graph of optimization process internals, do not
use for whole programs, but only for small test cases.
Defaults to off.
.TP
\fB\-\-trace\-execution\fR
Traced execution output, output the line of code
before executing it. Defaults to off.
.TP
\fB\-\-recompile\-c\-only\fR
This is not incremental compilation, but for Nuitka
development only. Takes existing files and simply
compile them as C again. Allows compiling edited C
files for quick debugging changes to the generated
source, e.g. to see if code is passed by, values
output, etc, Defaults to off. Depends on compiling
Python source to determine which files it should look
at.
.TP
\fB\-\-generate\-c\-only\fR
Generate only C source code, and do not compile it to
binary or module. This is for debugging and code
coverage analysis that doesn't waste CPU. Defaults to
off. Do not think you can use this directly.
.TP
\fB\-\-experimental\fR=\fI\,FLAG\/\fR
Use features declared as 'experimental'. May have no
effect if no experimental features are present in the
code. Uses secret tags (check source) per experimented
feature.
.TP
\fB\-\-low\-memory\fR
Attempt to use less memory, by forking less C
compilation jobs and using options that use less
memory. For use on embedded machines. Use this in case
of out of memory problems. Defaults to off.
.IP
Backend C compiler choice:
.TP
\fB\-\-clang\fR
Enforce the use of clang. On Windows this requires a
working Visual Studio version to piggy back on.
Defaults to off.
.TP
\fB\-\-mingw64\fR
Enforce the use of MinGW64 on Windows. Defaults to
off.
.TP
\fB\-\-msvc\fR=\fI\,MSVC_VERSION\/\fR
Enforce the use of specific MSVC version on Windows.
Allowed values are e.g. "14.2" (MSVC 2019), specify an
illegal value for a list of installed compilers, or
use "latest". Notice that only latest MSVC is really
supported, and you can use "latest" to enforce that.
Defaults to MSVC on Windows being used if installed,
otherwise MinGW64.
.TP
\fB\-j\fR N, \fB\-\-jobs\fR=\fI\,N\/\fR
Specify the allowed number of parallel C compiler
jobs. Defaults to the system CPU count.
.TP
\fB\-\-lto\fR=\fI\,choice\/\fR
Use link time optimizations (MSVC, gcc, clang).
Allowed values are "yes", "no", and "auto" (when it's
known to work). Defaults to "auto".
.TP
\fB\-\-static\-libpython\fR=\fI\,choice\/\fR
Use static link library of Python. Allowed values are
"yes", "no", and "auto" (when it's known to work).
Defaults to "auto".
.TP
\fB\-\-disable\-ccache\fR
Do not attempt to use ccache (gcc, clang, etc.) or
clcache (MSVC, clangcl).
.IP
PGO compilation choices:
.TP
\fB\-\-pgo\fR
Enables C level profile guided optimization (PGO), by
executing a dedicated build first for a profiling run,
and then using the result to feedback into the C
compilation. Note: This is experimental and not
working with standalone modes of Nuitka yet. Defaults
to off.
.TP
\fB\-\-pgo\-args\fR=\fI\,PGO_ARGS\/\fR
Arguments to be passed in case of profile guided
optimization. These are passed to the special built
executable during the PGO profiling run. Default
empty.
.TP
\fB\-\-pgo\-executable\fR=\fI\,PGO_EXECUTABLE\/\fR
Command to execute when collecting profile
information. Use this only, if you need to launch it
through a script that prepares it to run. Default use
created program.
.IP
Tracing features:
.TP
\fB\-\-quiet\fR
Disable all information outputs, but show warnings.
Defaults to off.
.TP
\fB\-\-show\-scons\fR
Operate Scons in non\-quiet mode, showing the executed
commands. Defaults to off.
.TP
\fB\-\-show\-progress\fR
Provide progress information and statistics. Defaults
to off.
.TP
\fB\-\-no\-progressbar\fR
Disable progress bar outputs (if tqdm is installed).
Defaults to off.
.TP
\fB\-\-show\-memory\fR
Provide memory information and statistics. Defaults to
off.
.TP
\fB\-\-show\-modules\fR
Provide information for included modules and DLLs
Defaults to off.
.TP
\fB\-\-show\-modules\-output\fR=\fI\,PATH\/\fR
Where to output \fB\-\-show\-modules\fR, should be a filename.
Default is standard output.
.TP
\fB\-\-report\fR=\fI\,COMPILATION_REPORT_FILENAME\/\fR
Report module inclusion in an XML output file. Default
is off.
.TP
\fB\-\-verbose\fR
Output details of actions taken, esp. in
optimizations. Can become a lot. Defaults to off.
.TP
\fB\-\-verbose\-output\fR=\fI\,PATH\/\fR
Where to output \fB\-\-verbose\fR, should be a filename.
Default is standard output.
.IP
Windows specific controls:
.TP
\fB\-\-windows\-disable\-console\fR
When compiling for Windows, disable the console
window. Defaults to off.
.TP
\fB\-\-windows\-icon\-from\-ico\fR=\fI\,ICON_PATH\/\fR
Add executable icon. Can be given multiple times for
different resolutions or files with multiple icons
inside. In the later case, you may also suffix with
# where n is an integer index starting from 1,
specifying a specific icon to be included, and all
others to be ignored.
.TP
\fB\-\-windows\-icon\-from\-exe\fR=\fI\,ICON_EXE_PATH\/\fR
Copy executable icons from this existing executable
(Windows only).
.TP
\fB\-\-onefile\-windows\-splash\-screen\-image\fR=\fI\,SPLASH_SCREEN_IMAGE\/\fR
When compiling for Windows and onefile, show this
while loading the application. Defaults to off.
.TP
\fB\-\-windows\-uac\-admin\fR
Request Windows User Control, to grant admin rights on
execution. (Windows only). Defaults to off.
.TP
\fB\-\-windows\-uac\-uiaccess\fR
Request Windows User Control, to enforce running from
a few folders only, remote desktop access. (Windows
only). Defaults to off.
.TP
\fB\-\-windows\-company\-name\fR=\fI\,WINDOWS_COMPANY_NAME\/\fR
Name of the company to use in Windows Version
information. One of file or product version is
required, when a version resource needs to be added,
e.g. to specify product name, or company name.
Defaults to unused.
.TP
\fB\-\-windows\-product\-name\fR=\fI\,WINDOWS_PRODUCT_NAME\/\fR
Name of the product to use in Windows Version
information. Defaults to base filename of the binary.
.TP
\fB\-\-windows\-file\-version\fR=\fI\,WINDOWS_FILE_VERSION\/\fR
File version to use in Windows Version information.
Must be a sequence of up to 4 numbers, e.g. 1.0.0.0,
only this format is allowed. One of file or product
version is required, when a version resource needs to
be added, e.g. to specify product name, or company
name. Defaults to unused.
.TP
\fB\-\-windows\-product\-version\fR=\fI\,WINDOWS_PRODUCT_VERSION\/\fR
Product version to use in Windows Version information.
Must be a sequence of up to 4 numbers, e.g. 1.0.0.0,
only this format is allowed. One of file or product
version is required, when a version resource needs to
be added, e.g. to specify product name, or company
name. Defaults to unused.
.TP
\fB\-\-windows\-file\-description\fR=\fI\,WINDOWS_FILE_DESCRIPTION\/\fR
Description of the file use in Windows Version
information. One of file or product version is
required, when a version resource needs to be added,
e.g. to specify product name, or company name.
Defaults to nonsense.
.TP
\fB\-\-windows\-onefile\-tempdir\-spec\fR=\fI\,ONEFILE_TEMPDIR_SPEC\/\fR
Use this as a temporary folder. Defaults to
\&'%TEMP%\eonefile_%PID%_%TIME%', i.e. system temporary
directory.
.TP
\fB\-\-windows\-force\-stdout\-spec\fR=\fI\,WINDOWS_FORCE_STDOUT_SPEC\/\fR
Force standard output of the program to go to this
location. Useful for programs with disabled console
and programs using the Windows Services Plugin of
Nuitka. Defaults to not active, use e.g.
\&'%PROGRAM%.out.txt', i.e. file near your program.
.TP
\fB\-\-windows\-force\-stderr\-spec\fR=\fI\,WINDOWS_FORCE_STDERR_SPEC\/\fR
Force standard error of the program to go to this
location. Useful for programs with disabled console
and programs using the Windows Services Plugin of
Nuitka. Defaults to not active, use e.g.
\&'%PROGRAM%.err.txt', i.e. file near your program.
.IP
macOS specific controls:
.TP
\fB\-\-macos\-onefile\-icon\fR=\fI\,ICON_PATH\/\fR
Add executable icon for binary to use. Can be given
only one time. Defaults to Python icon if available.
.TP
\fB\-\-macos\-disable\-console\fR
When compiling for macOS, disable the console window
and create a GUI application. Defaults to off.
.TP
\fB\-\-macos\-create\-app\-bundle\fR
When compiling for macOS, create a bundle rather than
a plain binary application. Currently experimental and
incomplete. Currently this is the only way to unlock
disabling of console.Defaults to off.
.TP
\fB\-\-macos\-signed\-app\-name\fR=\fI\,MACOS_SIGNED_APP_NAME\/\fR
Name of the application to use for macOS signing.
Follow com.yourcompany.appname naming results for best
results, as these have to be globally unique, and will
grant protected API accesses.
.TP
\fB\-\-macos\-app\-name\fR=\fI\,MACOS_APP_NAME\/\fR
Name of the product to use in macOS bundle
information. Defaults to base filename of the binary.
.TP
\fB\-\-macos\-app\-version\fR=\fI\,MACOS_APP_VERSION\/\fR
Product version to use in macOS bundle information.
Defaults to 1.0 if not given.
.IP
Linux specific controls:
.TP
\fB\-\-linux\-onefile\-icon\fR=\fI\,ICON_PATH\/\fR
Add executable icon for onefile binary to use. Can be
given only one time. Defaults to Python icon if
available.
.IP
Plugin control:
.TP
\fB\-\-enable\-plugin\fR=\fI\,PLUGIN_NAME\/\fR, \fB\-\-plugin\-enable\fR=\fI\,PLUGIN_NAME\/\fR
Enabled plugins. Must be plug\-in names. Use \fB\-\-pluginlist\fR to query the full list and exit. Default empty.
.TP
\fB\-\-disable\-plugin\fR=\fI\,PLUGIN_NAME\/\fR, \fB\-\-plugin\-disable\fR=\fI\,PLUGIN_NAME\/\fR
Disabled plugins. Must be plug\-in names. Use \fB\-\-pluginlist\fR to query the full list and exit. Default empty.
.TP
\fB\-\-plugin\-no\-detection\fR
Plugins can detect if they might be used, and the you
can disable the warning via "\-\-disable\-plugin=pluginthat\-warned", or you can use this option to disable
the mechanism entirely, which also speeds up
compilation slightly of course as this detection code
is run in vain once you are certain of which plugins
to use. Defaults to off.
.TP
\fB\-\-plugin\-list\fR
Show list of all available plugins and exit. Defaults
to off.
.TP
\fB\-\-user\-plugin\fR=\fI\,PATH\/\fR
The file name of user plugin. Can be given multiple
times. Default empty.
.TP
\fB\-\-persist\-source\-changes\fR
Write source changes to original Python files. Use
with care. May need permissions, best for use in a
virtualenv to debug if plugin code changes work with
standard Python or to benefit from bloat removal even
with pure Python. Default False.
.PP
Commercial: None
Python: 2.7.16 (default, Oct 10 2019, 22:02:15)
Flavor: Debian Python
Executable: \fI\,/usr/bin/python2\/\fP
OS: Linux
Arch: x86_64
Distribution: Debian 10.9
.SH EXAMPLES
Compile a Python file "some_module.py" to a module "some_module.so":
.IP
\f(CW$ nuitka \-\-module some_module.py\fR
.PP
Compile a Python program "some_program.py" to an executable "some_program.exe":
.IP
\f(CW$ nuitka some_program.py\fR
.PP
Compile a Python program "some_program.py" and the package "some_package" it
uses to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-to=some_package some_program.py\fR
.PP
Compile a Python program "some_program.py" and all the modules it uses to an executable "some_program.exe". Then execute it immediately when ready:
.IP
\f(CW$ nuitka \-\-run \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses (even standard library) to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-all \-\-recurse\-stdlib some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Keep the debug information, so valgrind, gdb, etc. work
nicely.
Note: This will *not* degrade performance:
.IP
\f(CW$ nuitka \-\-unstriped \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Perform all kinds of checks about correctness of the generated
C and run\-time checks.
Note: This will degrade performance and should only be used to debug Nuitka:
.IP
\f(CW$ nuitka \-\-debug \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Perform all kinds of checks about correctness of the generated
C and run\-time checks. Also use the debug Python library, which does its own checks.
Note: This will degrade performance and should only be used to debug Nuitka:
.IP
\f(CW$ nuitka \-\-debug \-\-python-debug \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the plugins modules it loads at run time to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-all \-\-recurse\-directory=plugins_dir some_program.py\fR
.PP
Nuitka-0.6.19.1/doc/nuitka3.1 0000600 0003721 0003721 00000052310 14167275622 022503 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH NUITKA "1" "January 2022" "nuitka 0.6.19.1" "User Commands"
.SH NAME
nuitka \- the Python compiler
.SH SYNOPSIS
.B nuitka
[\fI\,--module\/\fR] [\fI\,--run\/\fR] [\fI\,options\/\fR] \fI\,main_module.py\/\fR
.SH OPTIONS
.TP
\fB\-\-version\fR
show program's version number and exit
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-\-module\fR
Create an extension module executable instead of a
program. Defaults to off.
.TP
\fB\-\-standalone\fR
Enable standalone mode for output. This allows you to
transfer the created binary to other machines without
it using an existing Python installation. This also
means it will become big. It implies these option: "\-\-
follow\-imports". You may also want to use "\-\-pythonflag=no_site" to avoid the "site.py" module, which can
save a lot of code dependencies. Defaults to off.
.TP
\fB\-\-onefile\fR
On top of standalone mode, enable onefile mode. This
means not a folder, but a compressed executable is
created and used. Defaults to off.
.TP
\fB\-\-python\-debug\fR
Use debug version or not. Default uses what you are
using to run Nuitka, most likely a non\-debug version.
.TP
\fB\-\-python\-flag\fR=\fI\,FLAG\/\fR
Python flags to use. Default is what you are using to
run Nuitka, this enforces a specific mode. These are
options that also exist to standard Python executable.
Currently supported: "\-S" (alias "no_site"),
"static_hashes" (do not use hash randomization),
"no_warnings" (do not give Python runtime warnings),
"\-O" (alias "no_asserts"), "no_docstrings" (do not use
docstrings), and "\-m". Default empty.
.TP
\fB\-\-python\-for\-scons\fR=\fI\,PATH\/\fR
If using Python3.3 or Python3.4, provide the path of a
Python binary to use for Scons. Otherwise Nuitka can
use what you run Nuitka with or a "scons" binary that
is found in PATH, or a Python installation from
Windows registry.
.TP
\fB\-\-warn\-implicit\-exceptions\fR
Enable warnings for implicit exceptions detected at
compile time.
.TP
\fB\-\-warn\-unusual\-code\fR
Enable warnings for unusual code detected at compile
time.
.TP
\fB\-\-assume\-yes\-for\-downloads\fR
Allow Nuitka to download external code if necessary,
e.g. dependency walker, ccache, and even gcc on
Windows. To disable, redirect input from nul device,
e.g. "" is used. For compatibility reasons, the
"__file__" value will always have ".py" suffix
independent of what it really is.
.IP
Output choices:
.TP
\fB\-o\fR FILENAME
Specify how the executable should be named. For
extension modules there is no choice, also not for
standalone mode and using it will be an error. This
may include path information that needs to exist
though. Defaults to '' on this platform.
\&.bin
.TP
\fB\-\-output\-dir\fR=\fI\,DIRECTORY\/\fR
Specify where intermediate and final output files
should be put. The DIRECTORY will be populated with C
files, object files, etc. Defaults to current
directory.
.TP
\fB\-\-remove\-output\fR
Removes the build directory after producing the module
or exe file. Defaults to off.
.TP
\fB\-\-no\-pyi\-file\fR
Do not create a ".pyi" file for extension modules
created by Nuitka. This is used to detect implicit
imports. Defaults to off.
.IP
Debug features:
.TP
\fB\-\-debug\fR
Executing all self checks possible to find errors in
Nuitka, do not use for production. Defaults to off.
.TP
\fB\-\-unstripped\fR
Keep debug info in the resulting object file for
better debugger interaction. Defaults to off.
.TP
\fB\-\-profile\fR
Enable vmprof based profiling of time spent. Not
working currently. Defaults to off.
.TP
\fB\-\-internal\-graph\fR
Create graph of optimization process internals, do not
use for whole programs, but only for small test cases.
Defaults to off.
.TP
\fB\-\-trace\-execution\fR
Traced execution output, output the line of code
before executing it. Defaults to off.
.TP
\fB\-\-recompile\-c\-only\fR
This is not incremental compilation, but for Nuitka
development only. Takes existing files and simply
compile them as C again. Allows compiling edited C
files for quick debugging changes to the generated
source, e.g. to see if code is passed by, values
output, etc, Defaults to off. Depends on compiling
Python source to determine which files it should look
at.
.TP
\fB\-\-generate\-c\-only\fR
Generate only C source code, and do not compile it to
binary or module. This is for debugging and code
coverage analysis that doesn't waste CPU. Defaults to
off. Do not think you can use this directly.
.TP
\fB\-\-experimental\fR=\fI\,FLAG\/\fR
Use features declared as 'experimental'. May have no
effect if no experimental features are present in the
code. Uses secret tags (check source) per experimented
feature.
.TP
\fB\-\-low\-memory\fR
Attempt to use less memory, by forking less C
compilation jobs and using options that use less
memory. For use on embedded machines. Use this in case
of out of memory problems. Defaults to off.
.IP
Backend C compiler choice:
.TP
\fB\-\-clang\fR
Enforce the use of clang. On Windows this requires a
working Visual Studio version to piggy back on.
Defaults to off.
.TP
\fB\-\-mingw64\fR
Enforce the use of MinGW64 on Windows. Defaults to
off.
.TP
\fB\-\-msvc\fR=\fI\,MSVC_VERSION\/\fR
Enforce the use of specific MSVC version on Windows.
Allowed values are e.g. "14.2" (MSVC 2019), specify an
illegal value for a list of installed compilers, or
use "latest". Notice that only latest MSVC is really
supported, and you can use "latest" to enforce that.
Defaults to MSVC on Windows being used if installed,
otherwise MinGW64.
.TP
\fB\-j\fR N, \fB\-\-jobs\fR=\fI\,N\/\fR
Specify the allowed number of parallel C compiler
jobs. Defaults to the system CPU count.
.TP
\fB\-\-lto\fR=\fI\,choice\/\fR
Use link time optimizations (MSVC, gcc, clang).
Allowed values are "yes", "no", and "auto" (when it's
known to work). Defaults to "auto".
.TP
\fB\-\-static\-libpython\fR=\fI\,choice\/\fR
Use static link library of Python. Allowed values are
"yes", "no", and "auto" (when it's known to work).
Defaults to "auto".
.TP
\fB\-\-disable\-ccache\fR
Do not attempt to use ccache (gcc, clang, etc.) or
clcache (MSVC, clangcl).
.IP
PGO compilation choices:
.TP
\fB\-\-pgo\fR
Enables C level profile guided optimization (PGO), by
executing a dedicated build first for a profiling run,
and then using the result to feedback into the C
compilation. Note: This is experimental and not
working with standalone modes of Nuitka yet. Defaults
to off.
.TP
\fB\-\-pgo\-args\fR=\fI\,PGO_ARGS\/\fR
Arguments to be passed in case of profile guided
optimization. These are passed to the special built
executable during the PGO profiling run. Default
empty.
.TP
\fB\-\-pgo\-executable\fR=\fI\,PGO_EXECUTABLE\/\fR
Command to execute when collecting profile
information. Use this only, if you need to launch it
through a script that prepares it to run. Default use
created program.
.IP
Tracing features:
.TP
\fB\-\-quiet\fR
Disable all information outputs, but show warnings.
Defaults to off.
.TP
\fB\-\-show\-scons\fR
Operate Scons in non\-quiet mode, showing the executed
commands. Defaults to off.
.TP
\fB\-\-show\-progress\fR
Provide progress information and statistics. Defaults
to off.
.TP
\fB\-\-no\-progressbar\fR
Disable progress bar outputs (if tqdm is installed).
Defaults to off.
.TP
\fB\-\-show\-memory\fR
Provide memory information and statistics. Defaults to
off.
.TP
\fB\-\-show\-modules\fR
Provide information for included modules and DLLs
Defaults to off.
.TP
\fB\-\-show\-modules\-output\fR=\fI\,PATH\/\fR
Where to output \fB\-\-show\-modules\fR, should be a filename.
Default is standard output.
.TP
\fB\-\-report\fR=\fI\,COMPILATION_REPORT_FILENAME\/\fR
Report module inclusion in an XML output file. Default
is off.
.TP
\fB\-\-verbose\fR
Output details of actions taken, esp. in
optimizations. Can become a lot. Defaults to off.
.TP
\fB\-\-verbose\-output\fR=\fI\,PATH\/\fR
Where to output \fB\-\-verbose\fR, should be a filename.
Default is standard output.
.IP
Windows specific controls:
.TP
\fB\-\-windows\-disable\-console\fR
When compiling for Windows, disable the console
window. Defaults to off.
.TP
\fB\-\-windows\-icon\-from\-ico\fR=\fI\,ICON_PATH\/\fR
Add executable icon. Can be given multiple times for
different resolutions or files with multiple icons
inside. In the later case, you may also suffix with
# where n is an integer index starting from 1,
specifying a specific icon to be included, and all
others to be ignored.
.TP
\fB\-\-windows\-icon\-from\-exe\fR=\fI\,ICON_EXE_PATH\/\fR
Copy executable icons from this existing executable
(Windows only).
.TP
\fB\-\-onefile\-windows\-splash\-screen\-image\fR=\fI\,SPLASH_SCREEN_IMAGE\/\fR
When compiling for Windows and onefile, show this
while loading the application. Defaults to off.
.TP
\fB\-\-windows\-uac\-admin\fR
Request Windows User Control, to grant admin rights on
execution. (Windows only). Defaults to off.
.TP
\fB\-\-windows\-uac\-uiaccess\fR
Request Windows User Control, to enforce running from
a few folders only, remote desktop access. (Windows
only). Defaults to off.
.TP
\fB\-\-windows\-company\-name\fR=\fI\,WINDOWS_COMPANY_NAME\/\fR
Name of the company to use in Windows Version
information. One of file or product version is
required, when a version resource needs to be added,
e.g. to specify product name, or company name.
Defaults to unused.
.TP
\fB\-\-windows\-product\-name\fR=\fI\,WINDOWS_PRODUCT_NAME\/\fR
Name of the product to use in Windows Version
information. Defaults to base filename of the binary.
.TP
\fB\-\-windows\-file\-version\fR=\fI\,WINDOWS_FILE_VERSION\/\fR
File version to use in Windows Version information.
Must be a sequence of up to 4 numbers, e.g. 1.0.0.0,
only this format is allowed. One of file or product
version is required, when a version resource needs to
be added, e.g. to specify product name, or company
name. Defaults to unused.
.TP
\fB\-\-windows\-product\-version\fR=\fI\,WINDOWS_PRODUCT_VERSION\/\fR
Product version to use in Windows Version information.
Must be a sequence of up to 4 numbers, e.g. 1.0.0.0,
only this format is allowed. One of file or product
version is required, when a version resource needs to
be added, e.g. to specify product name, or company
name. Defaults to unused.
.TP
\fB\-\-windows\-file\-description\fR=\fI\,WINDOWS_FILE_DESCRIPTION\/\fR
Description of the file use in Windows Version
information. One of file or product version is
required, when a version resource needs to be added,
e.g. to specify product name, or company name.
Defaults to nonsense.
.TP
\fB\-\-windows\-onefile\-tempdir\-spec\fR=\fI\,ONEFILE_TEMPDIR_SPEC\/\fR
Use this as a temporary folder. Defaults to
\&'%TEMP%\eonefile_%PID%_%TIME%', i.e. system temporary
directory.
.TP
\fB\-\-windows\-force\-stdout\-spec\fR=\fI\,WINDOWS_FORCE_STDOUT_SPEC\/\fR
Force standard output of the program to go to this
location. Useful for programs with disabled console
and programs using the Windows Services Plugin of
Nuitka. Defaults to not active, use e.g.
\&'%PROGRAM%.out.txt', i.e. file near your program.
.TP
\fB\-\-windows\-force\-stderr\-spec\fR=\fI\,WINDOWS_FORCE_STDERR_SPEC\/\fR
Force standard error of the program to go to this
location. Useful for programs with disabled console
and programs using the Windows Services Plugin of
Nuitka. Defaults to not active, use e.g.
\&'%PROGRAM%.err.txt', i.e. file near your program.
.IP
macOS specific controls:
.TP
\fB\-\-macos\-onefile\-icon\fR=\fI\,ICON_PATH\/\fR
Add executable icon for binary to use. Can be given
only one time. Defaults to Python icon if available.
.TP
\fB\-\-macos\-disable\-console\fR
When compiling for macOS, disable the console window
and create a GUI application. Defaults to off.
.TP
\fB\-\-macos\-create\-app\-bundle\fR
When compiling for macOS, create a bundle rather than
a plain binary application. Currently experimental and
incomplete. Currently this is the only way to unlock
disabling of console.Defaults to off.
.TP
\fB\-\-macos\-signed\-app\-name\fR=\fI\,MACOS_SIGNED_APP_NAME\/\fR
Name of the application to use for macOS signing.
Follow com.yourcompany.appname naming results for best
results, as these have to be globally unique, and will
grant protected API accesses.
.TP
\fB\-\-macos\-app\-name\fR=\fI\,MACOS_APP_NAME\/\fR
Name of the product to use in macOS bundle
information. Defaults to base filename of the binary.
.TP
\fB\-\-macos\-app\-version\fR=\fI\,MACOS_APP_VERSION\/\fR
Product version to use in macOS bundle information.
Defaults to 1.0 if not given.
.IP
Linux specific controls:
.TP
\fB\-\-linux\-onefile\-icon\fR=\fI\,ICON_PATH\/\fR
Add executable icon for onefile binary to use. Can be
given only one time. Defaults to Python icon if
available.
.IP
Plugin control:
.TP
\fB\-\-enable\-plugin\fR=\fI\,PLUGIN_NAME\/\fR, \fB\-\-plugin\-enable\fR=\fI\,PLUGIN_NAME\/\fR
Enabled plugins. Must be plug\-in names. Use \fB\-\-pluginlist\fR to query the full list and exit. Default empty.
.TP
\fB\-\-disable\-plugin\fR=\fI\,PLUGIN_NAME\/\fR, \fB\-\-plugin\-disable\fR=\fI\,PLUGIN_NAME\/\fR
Disabled plugins. Must be plug\-in names. Use \fB\-\-pluginlist\fR to query the full list and exit. Default empty.
.TP
\fB\-\-plugin\-no\-detection\fR
Plugins can detect if they might be used, and the you
can disable the warning via "\-\-disable\-plugin=pluginthat\-warned", or you can use this option to disable
the mechanism entirely, which also speeds up
compilation slightly of course as this detection code
is run in vain once you are certain of which plugins
to use. Defaults to off.
.TP
\fB\-\-plugin\-list\fR
Show list of all available plugins and exit. Defaults
to off.
.TP
\fB\-\-user\-plugin\fR=\fI\,PATH\/\fR
The file name of user plugin. Can be given multiple
times. Default empty.
.TP
\fB\-\-persist\-source\-changes\fR
Write source changes to original Python files. Use
with care. May need permissions, best for use in a
virtualenv to debug if plugin code changes work with
standard Python or to benefit from bloat removal even
with pure Python. Default False.
.PP
Commercial: None
Python: 3.7.3 (default, Jan 22 2021, 20:04:44)
Flavor: Debian Python
Executable: \fI\,/usr/bin/python3\/\fP
OS: Linux
Arch: x86_64
Distribution: Debian 10.9
.SH EXAMPLES
Compile a Python file "some_module.py" to a module "some_module.so":
.IP
\f(CW$ nuitka \-\-module some_module.py\fR
.PP
Compile a Python program "some_program.py" to an executable "some_program.exe":
.IP
\f(CW$ nuitka some_program.py\fR
.PP
Compile a Python program "some_program.py" and the package "some_package" it
uses to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-to=some_package some_program.py\fR
.PP
Compile a Python program "some_program.py" and all the modules it uses to an executable "some_program.exe". Then execute it immediately when ready:
.IP
\f(CW$ nuitka \-\-run \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses (even standard library) to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-all \-\-recurse\-stdlib some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Keep the debug information, so valgrind, gdb, etc. work
nicely.
Note: This will *not* degrade performance:
.IP
\f(CW$ nuitka \-\-unstriped \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Perform all kinds of checks about correctness of the generated
C and run\-time checks.
Note: This will degrade performance and should only be used to debug Nuitka:
.IP
\f(CW$ nuitka \-\-debug \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the modules it uses to an executable "some_program.exe". Perform all kinds of checks about correctness of the generated
C and run\-time checks. Also use the debug Python library, which does its own checks.
Note: This will degrade performance and should only be used to debug Nuitka:
.IP
\f(CW$ nuitka \-\-debug \-\-python-debug \-\-recurse\-all some_program.py\fR
.PP
Compile a Python program "some_program.py" and the plugins modules it loads at run time to an executable "some_program.exe":
.IP
\f(CW$ nuitka \-\-recurse\-all \-\-recurse\-directory=plugins_dir some_program.py\fR
.PP
Nuitka-0.6.19.1/doc/Logo/ 0000700 0003721 0003721 00000000000 14167275622 021740 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/doc/Logo/Nuitka-Logo-Symbol.svg 0000600 0003721 0003721 00000016351 14166627112 026057 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000
Nuitka-0.6.19.1/doc/Logo/Nuitka-Logo-Horizontal.svg 0000600 0003721 0003721 00000016231 14166627112 026740 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000
Nuitka-0.6.19.1/doc/Logo/Nuitka-Logo-Vertical.svg 0000600 0003721 0003721 00000042775 14166627112 026374 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000
Nuitka-0.6.19.1/doc/images/ 0000700 0003721 0003721 00000000000 14167275622 022305 5 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 Nuitka-0.6.19.1/doc/images/Nuitka-Logo-Vertical.png 0000600 0003721 0003721 00000023144 14166627112 026713 0 ustar nuitka-buildslave nuitka-buildslave 0000000 0000000 PNG
IHDR U ? cP gAMA a sRGB cHRM z&