Skip to content

Commit 7dd08ed

Browse files
committed
Update Python inlined files: [GR-17428] [GR-17483] [GR-17443] Update to CPython 3.7.4
1 parent 4a7e313 commit 7dd08ed

File tree

211 files changed

+4942
-1599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+4942
-1599
lines changed

graalpython/com.oracle.graal.python.cext/include/abstract.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);
220220
If nargs is equal to zero, args can be NULL. kwargs can be NULL.
221221
nargs must be greater or equal to zero.
222222
223-
Return the result on success. Raise an exception on return NULL on
223+
Return the result on success. Raise an exception and return NULL on
224224
error. */
225225
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
226226
PyObject *callable,

graalpython/com.oracle.graal.python.cext/include/objimpl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,11 @@ typedef union _gc_head {
255255
union _gc_head *gc_prev;
256256
Py_ssize_t gc_refs;
257257
} gc;
258-
double dummy; /* force worst-case alignment */
258+
long double dummy; /* force worst-case alignment */
259+
// malloc returns memory block aligned for any built-in types and
260+
// long double is the largest standard C type.
261+
// On amd64 linux, long double requires 16 byte alignment.
262+
// See bpo-27987 for more discussion.
259263
} PyGC_Head;
260264

261265
extern PyGC_Head *_PyGC_generation0;

graalpython/com.oracle.graal.python.cext/include/patchlevel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
/*--start constants--*/
1919
#define PY_MAJOR_VERSION 3
2020
#define PY_MINOR_VERSION 7
21-
#define PY_MICRO_VERSION 3
21+
#define PY_MICRO_VERSION 4
2222
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2323
#define PY_RELEASE_SERIAL 0
2424

2525
/* Version as a string */
26-
#define PY_VERSION "3.7.3"
26+
#define PY_VERSION "3.7.4"
2727
/*--end constants--*/
2828

2929
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.

graalpython/com.oracle.graal.python.cext/include/pylifecycle.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
139139
PyAPI_FUNC(wchar_t *) Py_GetPath(void);
140140
#ifdef Py_BUILD_CORE
141141
PyAPI_FUNC(_PyInitError) _PyPathConfig_Init(const _PyCoreConfig *core_config);
142-
PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv);
142+
PyAPI_FUNC(int) _PyPathConfig_ComputeArgv0(
143+
int argc, wchar_t **argv,
144+
PyObject **argv0_p);
143145
PyAPI_FUNC(int) _Py_FindEnvConfigValue(
144146
FILE *env_file,
145147
const wchar_t *key,

graalpython/com.oracle.graal.python.cext/include/pymem.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ PyAPI_FUNC(int) PyTraceMalloc_Untrack(
5555
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
5656
unsigned int domain,
5757
uintptr_t ptr);
58-
59-
PyAPI_FUNC(int) _PyMem_IsFreed(void *ptr, size_t size);
6058
#endif /* !defined(Py_LIMITED_API) */
6159

6260

graalpython/com.oracle.graal.python.cext/modules/_mmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ mmap_subscript(mmap_object *self, PyObject *item)
790790
slicelen);
791791
else {
792792
char *result_buf = (char *)PyMem_Malloc(slicelen);
793-
Py_ssize_t cur, i;
793+
size_t cur;
794+
Py_ssize_t i;
794795
PyObject *result;
795796

796797
if (result_buf == NULL)
@@ -910,7 +911,8 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
910911
memcpy(self->data + start, vbuf.buf, slicelen);
911912
}
912913
else {
913-
Py_ssize_t cur, i;
914+
size_t cur;
915+
Py_ssize_t i;
914916

915917
for (cur = start, i = 0;
916918
i < slicelen;

graalpython/com.oracle.graal.python.test/src/tests/cpyext/posixmodule.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6120,6 +6120,13 @@ os_getpid_impl(PyObject *module)
61206120
}
61216121
#endif /* HAVE_GETPID */
61226122

6123+
#ifdef NGROUPS_MAX
6124+
#define MAX_GROUPS NGROUPS_MAX
6125+
#else
6126+
/* defined to be 16 on Solaris7, so this should be a small number */
6127+
#define MAX_GROUPS 64
6128+
#endif
6129+
61236130
#ifdef HAVE_GETGROUPLIST
61246131

61256132
/* AC 3.5: funny apple logic below */
@@ -6132,13 +6139,6 @@ Returns a list of groups to which a user belongs.\n\n\
61326139
static PyObject *
61336140
posix_getgrouplist(PyObject *self, PyObject *args)
61346141
{
6135-
#ifdef NGROUPS_MAX
6136-
#define MAX_GROUPS NGROUPS_MAX
6137-
#else
6138-
/* defined to be 16 on Solaris7, so this should be a small number */
6139-
#define MAX_GROUPS 64
6140-
#endif
6141-
61426142
const char *user;
61436143
int i, ngroups;
61446144
PyObject *list;
@@ -6147,7 +6147,16 @@ posix_getgrouplist(PyObject *self, PyObject *args)
61476147
#else
61486148
gid_t *groups, basegid;
61496149
#endif
6150-
ngroups = MAX_GROUPS;
6150+
6151+
/*
6152+
* NGROUPS_MAX is defined by POSIX.1 as the maximum
6153+
* number of supplimental groups a users can belong to.
6154+
* We have to increment it by one because
6155+
* getgrouplist() returns both the supplemental groups
6156+
* and the primary group, i.e. all of the groups the
6157+
* user belongs to.
6158+
*/
6159+
ngroups = 1 + MAX_GROUPS;
61516160

61526161
#ifdef __APPLE__
61536162
if (!PyArg_ParseTuple(args, "si:getgrouplist", &user, &basegid))
@@ -6216,13 +6225,6 @@ os_getgroups_impl(PyObject *module)
62166225
/*[clinic end generated code: output=42b0c17758561b56 input=d3f109412e6a155c]*/
62176226
{
62186227
PyObject *result = NULL;
6219-
6220-
#ifdef NGROUPS_MAX
6221-
#define MAX_GROUPS NGROUPS_MAX
6222-
#else
6223-
/* defined to be 16 on Solaris7, so this should be a small number */
6224-
#define MAX_GROUPS 64
6225-
#endif
62266228
gid_t grouplist[MAX_GROUPS];
62276229

62286230
/* On MacOSX getgroups(2) can return more than MAX_GROUPS results

graalpython/lib-python/3/_dummy_thread.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Exports only things specified by thread documentation;
1515
# skipping obsolete synonyms allocate(), start_new(), exit_thread().
1616
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
17-
'interrupt_main', 'LockType']
17+
'interrupt_main', 'LockType', 'RLock']
1818

1919
# A dummy value
2020
TIMEOUT_MAX = 2**31
@@ -148,6 +148,36 @@ def __repr__(self):
148148
hex(id(self))
149149
)
150150

151+
152+
class RLock(LockType):
153+
"""Dummy implementation of threading._RLock.
154+
155+
Re-entrant lock can be aquired multiple times and needs to be released
156+
just as many times. This dummy implemention does not check wheter the
157+
current thread actually owns the lock, but does accounting on the call
158+
counts.
159+
"""
160+
def __init__(self):
161+
super().__init__()
162+
self._levels = 0
163+
164+
def acquire(self, waitflag=None, timeout=-1):
165+
"""Aquire the lock, can be called multiple times in succession.
166+
"""
167+
locked = super().acquire(waitflag, timeout)
168+
if locked:
169+
self._levels += 1
170+
return locked
171+
172+
def release(self):
173+
"""Release needs to be called once for every call to acquire().
174+
"""
175+
if self._levels == 0:
176+
raise error
177+
if self._levels == 1:
178+
super().release()
179+
self._levels -= 1
180+
151181
# Used to signal that interrupt_main was called in a "thread"
152182
_interrupt = False
153183
# True when not executing in a "thread"

graalpython/lib-python/3/_pyio.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,15 @@ class IOBase(metaclass=abc.ABCMeta):
287287
derived classes can override selectively; the default implementations
288288
represent a file that cannot be read, written or seeked.
289289
290-
Even though IOBase does not declare read, readinto, or write because
290+
Even though IOBase does not declare read or write because
291291
their signatures will vary, implementations and clients should
292292
consider those methods part of the interface. Also, implementations
293293
may raise UnsupportedOperation when operations they do not support are
294294
called.
295295
296296
The basic type used for binary data read from or written to a file is
297-
bytes. Other bytes-like objects are accepted as method arguments too. In
298-
some cases (such as readinto), a writable object is required. Text I/O
299-
classes work with str data.
297+
bytes. Other bytes-like objects are accepted as method arguments too.
298+
Text I/O classes work with str data.
300299
301300
Note that calling any method (even inquiries) on a closed stream is
302301
undefined. Implementations may raise OSError in this case.
@@ -547,6 +546,11 @@ def readlines(self, hint=None):
547546
return lines
548547

549548
def writelines(self, lines):
549+
"""Write a list of lines to the stream.
550+
551+
Line separators are not added, so it is usual for each of the lines
552+
provided to have a line separator at the end.
553+
"""
550554
self._checkClosed()
551555
for line in lines:
552556
self.write(line)
@@ -835,6 +839,10 @@ class BytesIO(BufferedIOBase):
835839

836840
"""Buffered I/O implementation using an in-memory bytes buffer."""
837841

842+
# Initialize _buffer as soon as possible since it's used by __del__()
843+
# which calls close()
844+
_buffer = None
845+
838846
def __init__(self, initial_bytes=None):
839847
buf = bytearray()
840848
if initial_bytes is not None:
@@ -862,7 +870,8 @@ def getbuffer(self):
862870
return memoryview(self._buffer)
863871

864872
def close(self):
865-
self._buffer.clear()
873+
if self._buffer is not None:
874+
self._buffer.clear()
866875
super().close()
867876

868877
def read(self, size=-1):
@@ -1759,8 +1768,7 @@ class TextIOBase(IOBase):
17591768
"""Base class for text I/O.
17601769
17611770
This class provides a character and line based interface to stream
1762-
I/O. There is no readinto method because Python's character strings
1763-
are immutable. There is no public constructor.
1771+
I/O. There is no public constructor.
17641772
"""
17651773

17661774
def read(self, size=-1):
@@ -1933,6 +1941,10 @@ class TextIOWrapper(TextIOBase):
19331941

19341942
_CHUNK_SIZE = 2048
19351943

1944+
# Initialize _buffer as soon as possible since it's used by __del__()
1945+
# which calls close()
1946+
_buffer = None
1947+
19361948
# The write_through argument has no effect here since this
19371949
# implementation always writes through. The argument is present only
19381950
# so that the signature can match the signature of the C version.

graalpython/lib-python/3/asyncio/base_events.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@
5656
# before cleanup of cancelled handles is performed.
5757
_MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5
5858

59-
# Exceptions which must not call the exception handler in fatal error
60-
# methods (_fatal_error())
61-
_FATAL_ERROR_IGNORE = (BrokenPipeError,
62-
ConnectionResetError, ConnectionAbortedError)
63-
6459
_HAS_IPv6 = hasattr(socket, 'AF_INET6')
6560

6661
# Maximum timeout passed to select to avoid OS limitations
@@ -96,7 +91,7 @@ def _set_reuseport(sock):
9691
'SO_REUSEPORT defined but not implemented.')
9792

9893

99-
def _ipaddr_info(host, port, family, type, proto):
94+
def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0):
10095
# Try to skip getaddrinfo if "host" is already an IP. Users might have
10196
# handled name resolution in their own code and pass in resolved IPs.
10297
if not hasattr(socket, 'inet_pton'):
@@ -145,7 +140,7 @@ def _ipaddr_info(host, port, family, type, proto):
145140
socket.inet_pton(af, host)
146141
# The host has already been resolved.
147142
if _HAS_IPv6 and af == socket.AF_INET6:
148-
return af, type, proto, '', (host, port, 0, 0)
143+
return af, type, proto, '', (host, port, flowinfo, scopeid)
149144
else:
150145
return af, type, proto, '', (host, port)
151146
except OSError:
@@ -832,7 +827,7 @@ async def _sock_sendfile_fallback(self, sock, file, offset, count):
832827
read = await self.run_in_executor(None, file.readinto, view)
833828
if not read:
834829
break # EOF
835-
await self.sock_sendall(sock, view)
830+
await self.sock_sendall(sock, view[:read])
836831
total_sent += read
837832
return total_sent
838833
finally:
@@ -1083,11 +1078,11 @@ async def _sendfile_fallback(self, transp, file, offset, count):
10831078
if blocksize <= 0:
10841079
return total_sent
10851080
view = memoryview(buf)[:blocksize]
1086-
read = file.readinto(view)
1081+
read = await self.run_in_executor(None, file.readinto, view)
10871082
if not read:
10881083
return total_sent # EOF
10891084
await proto.drain()
1090-
transp.write(view)
1085+
transp.write(view[:read])
10911086
total_sent += read
10921087
finally:
10931088
if total_sent > 0 and hasattr(file, 'seek'):
@@ -1229,7 +1224,8 @@ async def create_datagram_endpoint(self, protocol_factory,
12291224
if local_addr:
12301225
sock.bind(local_address)
12311226
if remote_addr:
1232-
await self.sock_connect(sock, remote_address)
1227+
if not allow_broadcast:
1228+
await self.sock_connect(sock, remote_address)
12331229
r_addr = remote_address
12341230
except OSError as exc:
12351231
if sock is not None:
@@ -1270,7 +1266,7 @@ async def _ensure_resolved(self, address, *,
12701266
family=0, type=socket.SOCK_STREAM,
12711267
proto=0, flags=0, loop):
12721268
host, port = address[:2]
1273-
info = _ipaddr_info(host, port, family, type, proto)
1269+
info = _ipaddr_info(host, port, family, type, proto, *address[2:])
12741270
if info is not None:
12751271
# "host" is already a resolved IP.
12761272
return [info]

0 commit comments

Comments
 (0)