Skip to content

Commit 8e7cdcb

Browse files
committed
Some touches
1 parent d1bc106 commit 8e7cdcb

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

mypy/test/testcheck.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010

1111
from mypy import build
1212
from mypy.build import Graph
13-
from mypy.cache import Buffer
1413
from mypy.errors import CompileError
15-
from mypy.fixup import fixup_module
1614
from mypy.modulefinder import BuildSource, FindModuleCache, SearchPaths
17-
from mypy.nodes import MypyFile
1815
from mypy.test.config import test_data_prefix, test_temp_dir
1916
from mypy.test.data import DataDrivenTestCase, DataSuite, FileOperation, module_from_path
2017
from mypy.test.helpers import (
@@ -257,19 +254,6 @@ def verify_cache(
257254
with open(cachedir_tag) as f:
258255
assert f.read().startswith("Signature: 8a477f597d28d172789f06886806bc55")
259256

260-
# Also validate new cache format works correctly
261-
for id in graph:
262-
tree = graph[id].tree
263-
if not tree:
264-
continue
265-
data = Buffer()
266-
tree.write(data)
267-
new_data = Buffer()
268-
new_tree = MypyFile.read(Buffer(data.getvalue()))
269-
fixup_module(new_tree, manager.modules, False)
270-
new_tree.write(new_data)
271-
assert data.getvalue() == new_data.getvalue()
272-
273257
def find_error_message_paths(self, a: list[str]) -> set[str]:
274258
hits = set()
275259
for line in a:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "0.0.*"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Buffer:
2+
def __init__(self, source: bytes = ...) -> None: ...
3+
def getvalue(self) -> bytes: ...
4+
5+
def write_bool(data: Buffer, value: bool) -> None: ...
6+
def read_bool(data: Buffer) -> bool: ...
7+
def write_str(data: Buffer, value: str) -> None: ...
8+
def read_str(data: Buffer) -> str: ...
9+
def write_float(data: Buffer, value: float) -> None: ...
10+
def read_float(data: Buffer) -> float: ...
11+
def write_int(data: Buffer, value: int) -> None: ...
12+
def read_int(data: Buffer) -> int: ...

mypyc/analysis/ircheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def check_op_sources_valid(fn: FuncIR) -> list[FnError]:
182182
set_rprimitive.name,
183183
tuple_rprimitive.name,
184184
range_rprimitive.name,
185-
} | set(KNOWN_NATIVE_TYPES.values())
185+
} | set(KNOWN_NATIVE_TYPES)
186186

187187

188188
def can_coerce_to(src: RType, dest: RType) -> bool:

mypyc/lib-rt/native_internal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ write_str_internal(PyObject *data, PyObject *value) {
268268
if (!chunk)
269269
return 2;
270270
if (size > MAX_STR_SIZE) {
271+
// This is a micro-optimization to reduce cache size, if someone
272+
// will complain about their 65K-long string literals we can adjust.
271273
PyErr_Format(
272274
PyExc_OverflowError,
273275
"cannot store string longer than %d bytes",
@@ -379,6 +381,7 @@ read_int_internal(PyObject *data) {
379381
((BufferObject *)data)->pos += sizeof(CPyTagged);
380382
if ((ret & CPY_INT_TAG) == 0)
381383
return ret;
384+
// People who have literal ints not fitting in size_t should be punished :-)
382385
PyObject *str_ret = read_str_internal(data);
383386
if (str_ret == NULL)
384387
return CPY_INT_TAG;
@@ -487,7 +490,7 @@ native_internal_module_exec(PyObject *m)
487490
(void *)read_float_internal,
488491
(void *)write_int_internal,
489492
(void *)read_int_internal,
490-
(void *)&NativeInternal_ABI_Version,
493+
(void *)NativeInternal_ABI_Version,
491494
};
492495
PyObject *c_api_object = PyCapsule_New((void *)NativeInternal_API, "native_internal._C_API", NULL);
493496
if (PyModule_Add(m, "_C_API", c_api_object) < 0) {

mypyc/lib-rt/setup.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,7 @@ def run(self):
8080
ext_modules=[
8181
Extension(
8282
"native_internal",
83-
[
84-
"native_internal.c",
85-
"init.c",
86-
"int_ops.c",
87-
"exc_ops.c",
88-
"pythonsupport.c",
89-
],
83+
["native_internal.c", "init.c", "int_ops.c", "exc_ops.c", "pythonsupport.c"],
9084
include_dirs=["."],
9185
**kwargs,
9286
)

0 commit comments

Comments
 (0)