| 1050 | reason="https://github.com/python/cpython/issues/92932", |
| 1051 | ) |
| 1052 | def test_extended_arg(self): |
| 1053 | # Functions with more than 65535 global vars prefix some global |
| 1054 | # variable references with the EXTENDED_ARG opcode. |
| 1055 | nvars = 65537 + 258 |
| 1056 | names = ["g%d" % i for i in range(1, nvars)] |
| 1057 | r = random.Random(42) |
| 1058 | d = {name: r.randrange(100) for name in names} |
| 1059 | # def f(x): |
| 1060 | # x = g1, g2, ... |
| 1061 | # return zlib.crc32(bytes(bytearray(x))) |
| 1062 | code = """ |
| 1063 | import zlib |
| 1064 | |
| 1065 | def f(): |
| 1066 | x = {tup} |
| 1067 | return zlib.crc32(bytes(bytearray(x))) |
| 1068 | """.format( |
| 1069 | tup=", ".join(names) |
| 1070 | ) |
| 1071 | exec(textwrap.dedent(code), d, d) |
| 1072 | f = d["f"] |
| 1073 | res = f() |
| 1074 | data = cloudpickle.dumps([f, f], protocol=self.protocol) |
| 1075 | d = f = None |
| 1076 | f2, f3 = pickle.loads(data) |
| 1077 | self.assertTrue(f2 is f3) |
| 1078 | self.assertEqual(f2(), res) |
| 1079 | |
| 1080 | def test_submodule(self): |
| 1081 | # Function that refers (by attribute) to a sub-module of a package. |