Skip to content

Commit 25136b2

Browse files
committed
Merge branch 'python-import' into topic/GR-21420
2 parents 00558bf + c5134ed commit 25136b2

File tree

108 files changed

+2116
-564
lines changed

Some content is hidden

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

108 files changed

+2116
-564
lines changed

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 8
26-
#define PY_MICRO_VERSION 1
26+
#define PY_MICRO_VERSION 2
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.8.1"
31+
#define PY_VERSION "3.8.2"
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/modules/_memoryview.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
55
*/
66

7-
/* Memoryview object implementation */
7+
/*
8+
* Memoryview object implementation
9+
* --------------------------------
10+
*
11+
* This implementation is a complete rewrite contributed by Stefan Krah in
12+
* Python 3.3. Substantial credit goes to Antoine Pitrou (who had already
13+
* fortified and rewritten the previous implementation) and Nick Coghlan
14+
* (who came up with the idea of the ManagedBuffer) for analyzing the complex
15+
* ownership rules.
16+
*
17+
*/
818

919
#include "../src/capi.h"
1020
#include <limits.h>
@@ -1702,8 +1712,8 @@ unpack_single(const char *ptr, const char *fmt)
17021712
switch (fmt[0]) {
17031713

17041714
/* signed integers and fast path for 'B' */
1705-
case 'B': uc = *((unsigned char *)ptr); goto convert_uc;
1706-
case 'b': ld = *((signed char *)ptr); goto convert_ld;
1715+
case 'B': uc = *((const unsigned char *)ptr); goto convert_uc;
1716+
case 'b': ld = *((const signed char *)ptr); goto convert_ld;
17071717
case 'h': UNPACK_SINGLE(ld, ptr, short); goto convert_ld;
17081718
case 'i': UNPACK_SINGLE(ld, ptr, int); goto convert_ld;
17091719
case 'l': UNPACK_SINGLE(ld, ptr, long); goto convert_ld;
@@ -2704,8 +2714,8 @@ unpack_cmp(const char *p, const char *q, char fmt,
27042714
switch (fmt) {
27052715

27062716
/* signed integers and fast path for 'B' */
2707-
case 'B': return *((unsigned char *)p) == *((unsigned char *)q);
2708-
case 'b': return *((signed char *)p) == *((signed char *)q);
2717+
case 'B': return *((const unsigned char *)p) == *((const unsigned char *)q);
2718+
case 'b': return *((const signed char *)p) == *((const signed char *)q);
27092719
case 'h': CMP_SINGLE(p, q, short); return equal;
27102720
case 'i': CMP_SINGLE(p, q, int); return equal;
27112721
case 'l': CMP_SINGLE(p, q, long); return equal;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ Object type(VirtualFrame frame, LazyPythonClass cls, String name, PTuple bases,
23222322
DictEntry entry = it.next();
23232323
Object setName = getSetNameNode.execute(entry.value);
23242324
if (setName != PNone.NO_VALUE) {
2325-
callSetNameNode.execute(frame, setName, entry.key, newType, entry.value);
2325+
callSetNameNode.execute(frame, setName, entry.value, newType, entry.key);
23262326
}
23272327
}
23282328

graalpython/lib-python/3/argparse.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,24 +2144,23 @@ def _parse_optional(self, arg_string):
21442144
action = self._option_string_actions[option_string]
21452145
return action, option_string, explicit_arg
21462146

2147-
if self.allow_abbrev or not arg_string.startswith('--'):
2148-
# search through all possible prefixes of the option string
2149-
# and all actions in the parser for possible interpretations
2150-
option_tuples = self._get_option_tuples(arg_string)
2151-
2152-
# if multiple actions match, the option string was ambiguous
2153-
if len(option_tuples) > 1:
2154-
options = ', '.join([option_string
2155-
for action, option_string, explicit_arg in option_tuples])
2156-
args = {'option': arg_string, 'matches': options}
2157-
msg = _('ambiguous option: %(option)s could match %(matches)s')
2158-
self.error(msg % args)
2159-
2160-
# if exactly one action matched, this segmentation is good,
2161-
# so return the parsed action
2162-
elif len(option_tuples) == 1:
2163-
option_tuple, = option_tuples
2164-
return option_tuple
2147+
# search through all possible prefixes of the option string
2148+
# and all actions in the parser for possible interpretations
2149+
option_tuples = self._get_option_tuples(arg_string)
2150+
2151+
# if multiple actions match, the option string was ambiguous
2152+
if len(option_tuples) > 1:
2153+
options = ', '.join([option_string
2154+
for action, option_string, explicit_arg in option_tuples])
2155+
args = {'option': arg_string, 'matches': options}
2156+
msg = _('ambiguous option: %(option)s could match %(matches)s')
2157+
self.error(msg % args)
2158+
2159+
# if exactly one action matched, this segmentation is good,
2160+
# so return the parsed action
2161+
elif len(option_tuples) == 1:
2162+
option_tuple, = option_tuples
2163+
return option_tuple
21652164

21662165
# if it was not found as an option, but it looks like a negative
21672166
# number, it was meant to be positional
@@ -2185,16 +2184,17 @@ def _get_option_tuples(self, option_string):
21852184
# split at the '='
21862185
chars = self.prefix_chars
21872186
if option_string[0] in chars and option_string[1] in chars:
2188-
if '=' in option_string:
2189-
option_prefix, explicit_arg = option_string.split('=', 1)
2190-
else:
2191-
option_prefix = option_string
2192-
explicit_arg = None
2193-
for option_string in self._option_string_actions:
2194-
if option_string.startswith(option_prefix):
2195-
action = self._option_string_actions[option_string]
2196-
tup = action, option_string, explicit_arg
2197-
result.append(tup)
2187+
if self.allow_abbrev:
2188+
if '=' in option_string:
2189+
option_prefix, explicit_arg = option_string.split('=', 1)
2190+
else:
2191+
option_prefix = option_string
2192+
explicit_arg = None
2193+
for option_string in self._option_string_actions:
2194+
if option_string.startswith(option_prefix):
2195+
action = self._option_string_actions[option_string]
2196+
tup = action, option_string, explicit_arg
2197+
result.append(tup)
21982198

21992199
# single character options can be concatenated with their arguments
22002200
# but multiple character options always have to have their argument

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,14 +547,17 @@ async def shutdown_asyncgens(self):
547547
'asyncgen': agen
548548
})
549549

550-
def run_forever(self):
551-
"""Run until stop() is called."""
552-
self._check_closed()
550+
def _check_running(self):
553551
if self.is_running():
554552
raise RuntimeError('This event loop is already running')
555553
if events._get_running_loop() is not None:
556554
raise RuntimeError(
557555
'Cannot run the event loop while another loop is running')
556+
557+
def run_forever(self):
558+
"""Run until stop() is called."""
559+
self._check_closed()
560+
self._check_running()
558561
self._set_coroutine_origin_tracking(self._debug)
559562
self._thread_id = threading.get_ident()
560563

@@ -586,6 +589,7 @@ def run_until_complete(self, future):
586589
Return the Future's result, or raise its exception.
587590
"""
588591
self._check_closed()
592+
self._check_running()
589593

590594
new_task = not futures.isfuture(future)
591595
future = tasks.ensure_future(future, loop=self)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import typing
77

88
from . import events
9-
from . import futures
9+
from . import exceptions as exceptions_mod
1010
from . import locks
1111
from . import tasks
1212

@@ -83,7 +83,7 @@ async def run_one_coro(
8383
previous_failed: typing.Optional[locks.Event]) -> None:
8484
# Wait for the previous task to finish, or for delay seconds
8585
if previous_failed is not None:
86-
with contextlib.suppress(futures.TimeoutError):
86+
with contextlib.suppress(exceptions_mod.TimeoutError):
8787
# Use asyncio.wait_for() instead of asyncio.wait() here, so
8888
# that if we get cancelled at this point, Event.wait() is also
8989
# cancelled, otherwise there will be a "Task destroyed but it is

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,14 @@ def is_active(self):
12661266
return True
12671267

12681268
def close(self):
1269-
pass
1269+
self._join_threads()
1270+
1271+
def _join_threads(self):
1272+
"""Internal: Join all non-daemon threads"""
1273+
threads = [thread for thread in list(self._threads.values())
1274+
if thread.is_alive() and not thread.daemon]
1275+
for thread in threads:
1276+
thread.join()
12701277

12711278
def __enter__(self):
12721279
return self

graalpython/lib-python/3/base64.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def b64decode(s, altchars=None, validate=False):
8282
altchars = _bytes_from_decode_data(altchars)
8383
assert len(altchars) == 2, repr(altchars)
8484
s = s.translate(bytes.maketrans(altchars, b'+/'))
85-
if validate and not re.match(b'^[A-Za-z0-9+/]*={0,2}$', s):
85+
if validate and not re.fullmatch(b'[A-Za-z0-9+/]*={0,2}', s):
8686
raise binascii.Error('Non-base64 digit found')
8787
return binascii.a2b_base64(s)
8888

graalpython/lib-python/3/bdb.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,7 @@ def format_stack_entry(self, frame_lineno, lprefix=': '):
548548
s += frame.f_code.co_name
549549
else:
550550
s += "<lambda>"
551-
if '__args__' in frame.f_locals:
552-
args = frame.f_locals['__args__']
553-
else:
554-
args = None
555-
if args:
556-
s += reprlib.repr(args)
557-
else:
558-
s += '()'
551+
s += '()'
559552
if '__return__' in frame.f_locals:
560553
rv = frame.f_locals['__return__']
561554
s += '->'

graalpython/lib-python/3/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def runsource(self, source, filename="<input>", symbol="single"):
4040
4141
Arguments are as for compile_command().
4242
43-
One several things can happen:
43+
One of several things can happen:
4444
4545
1) The input is incorrect; compile_command() raised an
4646
exception (SyntaxError or OverflowError). A syntax traceback

0 commit comments

Comments
 (0)