Author: Raffael Tfirst <[email protected]>
Branch: py3.5-async
Changeset: r85816:2d1d323942eb
Date: 2016-07-22 20:58 +0200
http://bitbucket.org/pypy/pypy/changeset/2d1d323942eb/
Log: Only return token.Async and token.Await if it's not a function name,
create dummy method _set_sentinel for thread module (not yet
implemented) -> asyncio can be imported
diff --git a/pypy/interpreter/pyparser/pytokenizer.py
b/pypy/interpreter/pyparser/pytokenizer.py
--- a/pypy/interpreter/pyparser/pytokenizer.py
+++ b/pypy/interpreter/pyparser/pytokenizer.py
@@ -96,6 +96,7 @@
altindents = [0]
last_comment = ''
parenlevstart = (0, 0, "")
+ last_token = ''
# make the annotator happy
endDFA = DUMMY_DFA
@@ -253,9 +254,9 @@
if not verify_identifier(token):
raise TokenError("invalid character in identifier",
line, lnum, start + 1, token_list)
- if token == 'async':
+ if token == 'async' and not last_token == 'def':
token_list.append((tokens.ASYNC, token, lnum, start,
line))
- elif token == 'await':
+ elif token == 'await' and not last_token == 'def':
token_list.append((tokens.AWAIT, token, lnum, start,
line))
else:
token_list.append((tokens.NAME, token, lnum, start,
line))
@@ -289,6 +290,7 @@
token_list.append(tok)
last_comment = ''
pos = pos + 1
+ last_token = token
lnum -= 1
if not (flags & consts.PyCF_DONT_IMPLY_DEDENT):
diff --git a/pypy/module/thread/__init__.py b/pypy/module/thread/__init__.py
--- a/pypy/module/thread/__init__.py
+++ b/pypy/module/thread/__init__.py
@@ -21,6 +21,7 @@
'allocate': 'os_lock.allocate_lock', # obsolete synonym
'LockType': 'os_lock.Lock',
'RLock': 'os_lock.W_RLock',
+ '_set_sentinel': 'os_lock.set_sentinel',
'_local': 'os_local.Local',
'TIMEOUT_MAX': 'space.wrap(float(os_lock.TIMEOUT_MAX) /
1000000.0)',
'error': 'space.fromcache(error.Cache).w_error',
diff --git a/pypy/module/thread/os_lock.py b/pypy/module/thread/os_lock.py
--- a/pypy/module/thread/os_lock.py
+++ b/pypy/module/thread/os_lock.py
@@ -143,6 +143,11 @@
See LockType.__doc__ for information about locks."""
return space.wrap(Lock(space))
+def set_sentinel(space):
+ """Set a sentinel lock that will be released when the current thread
+state is finalized (after it is untied from the interpreter)."""
+ #NOT IMPLEMENTED YET!!! (required for some libs to work)
+ return space.wrap(Lock(space))
class W_RLock(W_Root):
def __init__(self, space):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit