Skip to content

Commit bf55aa3

Browse files
committed
Sync from mypy
1 parent 85722d3 commit bf55aa3

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib-rt/librt_internal.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ Buffer_init_internal(BufferObject *self, PyObject *source) {
7070
PyErr_SetString(PyExc_TypeError, "source must be a bytes object");
7171
return -1;
7272
}
73-
self->size = PyBytes_GET_SIZE(source);
74-
self->end = self->size;
73+
self->end = PyBytes_GET_SIZE(source);
74+
// Allocate at least one byte to simplify resizing logic.
75+
// The original bytes buffer has last null byte, so this is safe.
76+
self->size = self->end + 1;
7577
// This returns a pointer to internal bytes data, so make our own copy.
7678
char *buf = PyBytes_AsString(source);
7779
self->buf = PyMem_Malloc(self->size);
78-
memcpy(self->buf, buf, self->size);
80+
memcpy(self->buf, buf, self->end);
7981
} else {
8082
self->buf = PyMem_Malloc(START_SIZE);
8183
self->size = START_SIZE;

lib-rt/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import subprocess
1010
import sys
1111
from distutils import ccompiler, sysconfig
12-
from setuptools.command.build_ext import build_ext
1312
from typing import Any
1413

1514
from setuptools import Extension, setup
15+
from setuptools.command.build_ext import build_ext
1616

1717
C_APIS_TO_TEST = [
1818
"init.c",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = [
1919
{name = "Jukka Lehtosalo", email = "[email protected]"},
2020
{name = "Ivan Levkivskyi", email = "[email protected]"},
2121
]
22-
version = "0.2.1"
22+
version = "0.2.2"
2323
license = {text = "MIT"}
2424
classifiers = [
2525
"Development Status :: 3 - Alpha",

0 commit comments

Comments
 (0)