Skip to content

Commit f645159

Browse files
committed
[GR-17483] [GR-17443] Update to CPython 3.7.4
PullRequest: graalpython/604
2 parents f913602 + d6ad8f8 commit f645159

File tree

211 files changed

+4941
-1598
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

+4941
-1598
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
@@ -225,7 +225,7 @@ PyAPI_FUNC(int) _PyObject_HasFastCall(PyObject *callable);
225225
If nargs is equal to zero, args can be NULL. kwargs can be NULL.
226226
nargs must be greater or equal to zero.
227227
228-
Return the result on success. Raise an exception on return NULL on
228+
Return the result on success. Raise an exception and return NULL on
229229
error. */
230230
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(
231231
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
@@ -260,7 +260,11 @@ typedef union _gc_head {
260260
union _gc_head *gc_prev;
261261
Py_ssize_t gc_refs;
262262
} gc;
263-
double dummy; /* force worst-case alignment */
263+
long double dummy; /* force worst-case alignment */
264+
// malloc returns memory block aligned for any built-in types and
265+
// long double is the largest standard C type.
266+
// On amd64 linux, long double requires 16 byte alignment.
267+
// See bpo-27987 for more discussion.
264268
} PyGC_Head;
265269

266270
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
@@ -23,12 +23,12 @@
2323
/*--start constants--*/
2424
#define PY_MAJOR_VERSION 3
2525
#define PY_MINOR_VERSION 7
26-
#define PY_MICRO_VERSION 3
26+
#define PY_MICRO_VERSION 4
2727
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
2828
#define PY_RELEASE_SERIAL 0
2929

3030
/* Version as a string */
31-
#define PY_VERSION "3.7.3"
31+
#define PY_VERSION "3.7.4"
3232
/*--end constants--*/
3333

3434
/* 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
@@ -144,7 +144,9 @@ PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
144144
PyAPI_FUNC(wchar_t *) Py_GetPath(void);
145145
#ifdef Py_BUILD_CORE
146146
PyAPI_FUNC(_PyInitError) _PyPathConfig_Init(const _PyCoreConfig *core_config);
147-
PyAPI_FUNC(PyObject*) _PyPathConfig_ComputeArgv0(int argc, wchar_t **argv);
147+
PyAPI_FUNC(int) _PyPathConfig_ComputeArgv0(
148+
int argc, wchar_t **argv,
149+
PyObject **argv0_p);
148150
PyAPI_FUNC(int) _Py_FindEnvConfigValue(
149151
FILE *env_file,
150152
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
@@ -60,8 +60,6 @@ PyAPI_FUNC(int) PyTraceMalloc_Untrack(
6060
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
6161
unsigned int domain,
6262
uintptr_t ptr);
63-
64-
PyAPI_FUNC(int) _PyMem_IsFreed(void *ptr, size_t size);
6563
#endif /* !defined(Py_LIMITED_API) */
6664

6765

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
@@ -6123,6 +6123,13 @@ os_getpid_impl(PyObject *module)
61236123
}
61246124
#endif /* HAVE_GETPID */
61256125

6126+
#ifdef NGROUPS_MAX
6127+
#define MAX_GROUPS NGROUPS_MAX
6128+
#else
6129+
/* defined to be 16 on Solaris7, so this should be a small number */
6130+
#define MAX_GROUPS 64
6131+
#endif
6132+
61266133
#ifdef HAVE_GETGROUPLIST
61276134

61286135
/* AC 3.5: funny apple logic below */
@@ -6135,13 +6142,6 @@ Returns a list of groups to which a user belongs.\n\n\
61356142
static PyObject *
61366143
posix_getgrouplist(PyObject *self, PyObject *args)
61376144
{
6138-
#ifdef NGROUPS_MAX
6139-
#define MAX_GROUPS NGROUPS_MAX
6140-
#else
6141-
/* defined to be 16 on Solaris7, so this should be a small number */
6142-
#define MAX_GROUPS 64
6143-
#endif
6144-
61456145
const char *user;
61466146
int i, ngroups;
61476147
PyObject *list;
@@ -6150,7 +6150,16 @@ posix_getgrouplist(PyObject *self, PyObject *args)
61506150
#else
61516151
gid_t *groups, basegid;
61526152
#endif
6153-
ngroups = MAX_GROUPS;
6153+
6154+
/*
6155+
* NGROUPS_MAX is defined by POSIX.1 as the maximum
6156+
* number of supplimental groups a users can belong to.
6157+
* We have to increment it by one because
6158+
* getgrouplist() returns both the supplemental groups
6159+
* and the primary group, i.e. all of the groups the
6160+
* user belongs to.
6161+
*/
6162+
ngroups = 1 + MAX_GROUPS;
61546163

61556164
#ifdef __APPLE__
61566165
if (!PyArg_ParseTuple(args, "si:getgrouplist", &user, &basegid))
@@ -6219,13 +6228,6 @@ os_getgroups_impl(PyObject *module)
62196228
/*[clinic end generated code: output=42b0c17758561b56 input=d3f109412e6a155c]*/
62206229
{
62216230
PyObject *result = NULL;
6222-
6223-
#ifdef NGROUPS_MAX
6224-
#define MAX_GROUPS NGROUPS_MAX
6225-
#else
6226-
/* defined to be 16 on Solaris7, so this should be a small number */
6227-
#define MAX_GROUPS 64
6228-
#endif
62296231
gid_t grouplist[MAX_GROUPS];
62306232

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

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public final class PythonLanguage extends TruffleLanguage<PythonContext> {
107107
public static final String NAME = "Python";
108108
public static final int MAJOR = 3;
109109
public static final int MINOR = 7;
110-
public static final int MICRO = 3;
110+
public static final int MICRO = 4;
111111
public static final String VERSION = MAJOR + "." + MINOR + "." + MICRO;
112112

113113
public static final String MIME_TYPE = "text/x-python";

graalpython/lib-python/3/_dummy_thread.py

Lines changed: 33 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,38 @@ 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+
__enter__ = acquire
173+
174+
def release(self):
175+
"""Release needs to be called once for every call to acquire().
176+
"""
177+
if self._levels == 0:
178+
raise error
179+
if self._levels == 1:
180+
super().release()
181+
self._levels -= 1
182+
151183
# Used to signal that interrupt_main was called in a "thread"
152184
_interrupt = False
153185
# 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)