[med-svn] [python3-typed-ast] 01/01: New upstream version 0.6.3
Michael Crusoe
misterc-guest at moszumanska.debian.org
Sun Jan 15 18:46:18 UTC 2017
This is an automated email from the git hooks/post-receive script.
misterc-guest pushed a commit to annotated tag upstream/0.6.3
in repository python3-typed-ast.
commit a369aa8c96ccbb3dac23c642ffdce435888e4d61
Author: Michael R. Crusoe <michael.crusoe at gmail.com>
Date: Fri Jan 13 06:41:41 2017 -0800
New upstream version 0.6.3
---
PKG-INFO | 7 ++-
ast27/Include/asdl.h | 4 +-
ast27/Include/ast.h | 2 +-
ast27/Include/node.h | 10 +--
ast27/Include/parsetok.h | 36 +++++------
ast27/Include/token.h | 8 +--
ast27/Parser/grammar.c | 2 +-
ast27/Parser/tokenizer.c | 4 +-
ast27/Python/Python-ast.c | 2 +-
ast27/Python/asdl.c | 64 ++++++++++++++++++++
ast27/Python/graminit.c | 2 +-
ast35/Include/Python-ast.h | 6 +-
ast35/Include/ast.h | 6 +-
ast35/Include/node.h | 10 +--
ast35/Include/parsetok.h | 18 +++---
ast35/Include/token.h | 8 +--
ast35/Parser/grammar.c | 2 +-
ast35/Parser/tokenizer.c | 134 ++++++++++++++++++++++++++++-------------
ast35/Python/Python-ast.c | 29 +++++++--
ast35/Python/asdl.c | 64 ++++++++++++++++++++
ast35/Python/ast.c | 34 ++++++++++-
ast35/Python/graminit.c | 2 +-
setup.py | 10 ++-
typed_ast.egg-info/PKG-INFO | 7 ++-
typed_ast.egg-info/SOURCES.txt | 2 +
25 files changed, 358 insertions(+), 115 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 2316cdf..3c2dafb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: typed-ast
-Version: 0.6.1
+Version: 0.6.3
Summary: fork of Python 2 and 3 ast modules with type comment support
Home-page: https://github.com/dropbox/typed_ast
Author: David Fisher
@@ -10,11 +10,14 @@ Description: This package is a fork of the CPython 2.7 and 3.5 `ast` modules wit
ability to parse PEP 484 (https://www.python.org/dev/peps/pep-0484/) type
comments. The primary goals of this package are correctness and speed.
Platform: POSIX
-Classifier: Development Status :: 3 - Alpha
+Platform: Windows
+Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
+Classifier: Operating System :: Microsoft
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development
diff --git a/ast27/Include/asdl.h b/ast27/Include/asdl.h
index 7b9cf3f..40df222 100644
--- a/ast27/Include/asdl.h
+++ b/ast27/Include/asdl.h
@@ -34,8 +34,8 @@ typedef struct {
#define _Py_asdl_seq_new asdl_seq_new
#define _Py_asdl_int_seq_new asdl_int_seq_new
#endif
-asdl_seq *asdl_seq_new(int size, PyArena *arena);
-asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
+asdl_seq *asdl_seq_new(Py_ssize_t size, PyArena *arena);
+asdl_int_seq *asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
#define asdl_seq_GET(S, I) (S)->elements[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
diff --git a/ast27/Include/ast.h b/ast27/Include/ast.h
index 2db1a2b..2911440 100644
--- a/ast27/Include/ast.h
+++ b/ast27/Include/ast.h
@@ -4,7 +4,7 @@
extern "C" {
#endif
-PyAPI_FUNC(mod_ty) Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
+mod_ty Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
const char *, PyArena *);
#ifdef __cplusplus
diff --git a/ast27/Include/node.h b/ast27/Include/node.h
index 32ced76..32f9b17 100644
--- a/ast27/Include/node.h
+++ b/ast27/Include/node.h
@@ -16,11 +16,11 @@ typedef struct _node {
struct _node *n_child;
} node;
-PyAPI_FUNC(node *) Ta27Node_New(int type);
-PyAPI_FUNC(int) Ta27Node_AddChild(node *n, int type,
- char *str, int lineno, int col_offset);
-PyAPI_FUNC(void) Ta27Node_Free(node *n);
-PyAPI_FUNC(Py_ssize_t) _Ta27Node_SizeOf(node *n);
+node *Ta27Node_New(int type);
+int Ta27Node_AddChild(node *n, int type,
+ char *str, int lineno, int col_offset);
+void Ta27Node_Free(node *n);
+Py_ssize_t _Ta27Node_SizeOf(node *n);
/* Node access functions */
#define NCH(n) ((n)->n_nchildren)
diff --git a/ast27/Include/parsetok.h b/ast27/Include/parsetok.h
index ca652b8..38fc2e4 100644
--- a/ast27/Include/parsetok.h
+++ b/ast27/Include/parsetok.h
@@ -33,30 +33,30 @@ typedef struct {
#define PyPARSE_IGNORE_COOKIE 0x0010
-PyAPI_FUNC(node *) Ta27Parser_ParseString(const char *, grammar *, int,
- perrdetail *);
-PyAPI_FUNC(node *) Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
- char *, char *, perrdetail *);
+node *Ta27Parser_ParseString(const char *, grammar *, int,
+ perrdetail *);
+node *Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
+ char *, char *, perrdetail *);
-PyAPI_FUNC(node *) Ta27Parser_ParseStringFlags(const char *, grammar *, int,
- perrdetail *, int);
-PyAPI_FUNC(node *) Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
- int, char *, char *,
- perrdetail *, int);
-PyAPI_FUNC(node *) Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
- int, char *, char *,
- perrdetail *, int *);
+node *Ta27Parser_ParseStringFlags(const char *, grammar *, int,
+ perrdetail *, int);
+node *Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
+ int, char *, char *,
+ perrdetail *, int);
+node *Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
+ int, char *, char *,
+ perrdetail *, int *);
-PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilename(const char *,
- const char *,
- grammar *, int,
- perrdetail *, int);
-PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilenameEx(const char *,
+node *Ta27Parser_ParseStringFlagsFilename(const char *,
+ const char *,
+ grammar *, int,
+ perrdetail *, int);
+node *Ta27Parser_ParseStringFlagsFilenameEx(const char *,
const char *,
grammar *, int,
perrdetail *, int *);
-PyAPI_FUNC(node *) Ta27Parser_ParseStringObject(
+node *Ta27Parser_ParseStringObject(
const char *s,
PyObject *filename,
grammar *g,
diff --git a/ast27/Include/token.h b/ast27/Include/token.h
index 21578e1..8eab738 100644
--- a/ast27/Include/token.h
+++ b/ast27/Include/token.h
@@ -77,10 +77,10 @@ extern "C" {
#define ISEOF(x) ((x) == ENDMARKER)
-PyAPI_DATA(char *) _Ta27Parser_TokenNames[]; /* Token names */
-PyAPI_FUNC(int) Ta27Token_OneChar(int);
-PyAPI_FUNC(int) Ta27Token_TwoChars(int, int);
-PyAPI_FUNC(int) Ta27Token_ThreeChars(int, int, int);
+extern char *_Ta27Parser_TokenNames[]; /* Token names */
+int Ta27Token_OneChar(int);
+int Ta27Token_TwoChars(int, int);
+int Ta27Token_ThreeChars(int, int, int);
#ifdef __cplusplus
}
diff --git a/ast27/Parser/grammar.c b/ast27/Parser/grammar.c
index e21fb87..73b4d1f 100644
--- a/ast27/Parser/grammar.c
+++ b/ast27/Parser/grammar.c
@@ -13,7 +13,7 @@
#include <unixlib.h>
#endif
-extern int Py_DebugFlag;
+PyAPI_DATA(int) Py_DebugFlag;
grammar *
newgrammar(int start)
diff --git a/ast27/Parser/tokenizer.c b/ast27/Parser/tokenizer.c
index e435d49..29e88d5 100644
--- a/ast27/Parser/tokenizer.c
+++ b/ast27/Parser/tokenizer.c
@@ -20,9 +20,9 @@
#endif /* PGEN */
#if PY_MINOR_VERSION >= 4
-extern char *PyOS_Readline(FILE *, FILE *, const char *);
+PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
#else
-extern char *PyOS_Readline(FILE *, FILE *, char *);
+PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
#endif
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
diff --git a/ast27/Python/Python-ast.c b/ast27/Python/Python-ast.c
index 315a231..0d1212a 100644
--- a/ast27/Python/Python-ast.c
+++ b/ast27/Python/Python-ast.c
@@ -476,7 +476,7 @@ static PyMethodDef ast_type_methods[] = {
};
static PyTypeObject AST_type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ PyVarObject_HEAD_INIT(NULL, 0)
"_ast27.AST",
sizeof(PyObject),
0,
diff --git a/ast27/Python/asdl.c b/ast27/Python/asdl.c
new file mode 100644
index 0000000..df387b2
--- /dev/null
+++ b/ast27/Python/asdl.c
@@ -0,0 +1,64 @@
+#include "Python.h"
+#include "asdl.h"
+
+asdl_seq *
+_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
+{
+ asdl_seq *seq = NULL;
+ size_t n;
+
+ /* check size is sane */
+ if (size < 0 ||
+ (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+ /* check if size can be added safely */
+ if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n += sizeof(asdl_seq);
+
+ seq = (asdl_seq *)PyArena_Malloc(arena, n);
+ if (!seq) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ memset(seq, 0, n);
+ seq->size = size;
+ return seq;
+}
+
+asdl_int_seq *
+_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
+{
+ asdl_int_seq *seq = NULL;
+ size_t n;
+
+ /* check size is sane */
+ if (size < 0 ||
+ (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+ /* check if size can be added safely */
+ if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n += sizeof(asdl_seq);
+
+ seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
+ if (!seq) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ memset(seq, 0, n);
+ seq->size = size;
+ return seq;
+}
diff --git a/ast27/Python/graminit.c b/ast27/Python/graminit.c
index c61ce80..f8ff327 100644
--- a/ast27/Python/graminit.c
+++ b/ast27/Python/graminit.c
@@ -2,7 +2,7 @@
#include "pgenheaders.h"
#include "grammar.h"
-PyAPI_DATA(grammar) _Ta27Parser_Grammar;
+grammar _Ta27Parser_Grammar;
static arc arcs_0_0[3] = {
{2, 1},
{3, 1},
diff --git a/ast35/Include/Python-ast.h b/ast35/Include/Python-ast.h
index 6b070e6..94e9b5e 100644
--- a/ast35/Include/Python-ast.h
+++ b/ast35/Include/Python-ast.h
@@ -304,6 +304,7 @@ struct _expr {
struct {
object n;
+ int contains_underscores;
} Num;
struct {
@@ -570,8 +571,9 @@ expr_ty _Ta35_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
#define Call(a0, a1, a2, a3, a4, a5) _Ta35_Call(a0, a1, a2, a3, a4, a5)
expr_ty _Ta35_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int
lineno, int col_offset, PyArena *arena);
-#define Num(a0, a1, a2, a3) _Ta35_Num(a0, a1, a2, a3)
-expr_ty _Ta35_Num(object n, int lineno, int col_offset, PyArena *arena);
+#define Num(a0, a1, a2, a3, a4) _Ta35_Num(a0, a1, a2, a3, a4)
+expr_ty _Ta35_Num(object n, int contains_underscores, int lineno, int
+ col_offset, PyArena *arena);
#define Str(a0, a1, a2, a3) _Ta35_Str(a0, a1, a2, a3)
expr_ty _Ta35_Str(string s, int lineno, int col_offset, PyArena *arena);
#define Bytes(a0, a1, a2, a3) _Ta35_Bytes(a0, a1, a2, a3)
diff --git a/ast35/Include/ast.h b/ast35/Include/ast.h
index d9926d4..50bba6a 100644
--- a/ast35/Include/ast.h
+++ b/ast35/Include/ast.h
@@ -4,13 +4,13 @@
extern "C" {
#endif
-PyAPI_FUNC(int) Ta35AST_Validate(mod_ty);
-PyAPI_FUNC(mod_ty) Ta35AST_FromNode(
+int Ta35AST_Validate(mod_ty);
+mod_ty Ta35AST_FromNode(
const node *n,
PyCompilerFlags *flags,
const char *filename, /* decoded from the filesystem encoding */
PyArena *arena);
-PyAPI_FUNC(mod_ty) Ta35AST_FromNodeObject(
+mod_ty Ta35AST_FromNodeObject(
const node *n,
PyCompilerFlags *flags,
PyObject *filename,
diff --git a/ast35/Include/node.h b/ast35/Include/node.h
index 82f23c3..27dc06f 100644
--- a/ast35/Include/node.h
+++ b/ast35/Include/node.h
@@ -16,12 +16,12 @@ typedef struct _node {
struct _node *n_child;
} node;
-PyAPI_FUNC(node *) Ta35Node_New(int type);
-PyAPI_FUNC(int) Ta35Node_AddChild(node *n, int type,
+node *Ta35Node_New(int type);
+int Ta35Node_AddChild(node *n, int type,
char *str, int lineno, int col_offset);
-PyAPI_FUNC(void) Ta35Node_Free(node *n);
+void Ta35Node_Free(node *n);
#ifndef Py_LIMITED_API
-PyAPI_FUNC(Py_ssize_t) _Ta35Node_SizeOf(node *n);
+Py_ssize_t _Ta35Node_SizeOf(node *n);
#endif
/* Node access functions */
@@ -36,7 +36,7 @@ PyAPI_FUNC(Py_ssize_t) _Ta35Node_SizeOf(node *n);
/* Assert that the type of a node is what we expect */
#define REQ(n, type) assert(TYPE(n) == (type))
-PyAPI_FUNC(void) Ta35Node_ListTree(node *);
+void Ta35Node_ListTree(node *);
#ifdef __cplusplus
}
diff --git a/ast35/Include/parsetok.h b/ast35/Include/parsetok.h
index cacc492..c7bd194 100644
--- a/ast35/Include/parsetok.h
+++ b/ast35/Include/parsetok.h
@@ -35,15 +35,15 @@ typedef struct {
#define PyPARSE_IGNORE_COOKIE 0x0010
#define PyPARSE_BARRY_AS_BDFL 0x0020
-PyAPI_FUNC(node *) Ta35Parser_ParseString(const char *, grammar *, int,
+node *Ta35Parser_ParseString(const char *, grammar *, int,
perrdetail *);
-PyAPI_FUNC(node *) Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
+node *Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
const char *, const char *,
perrdetail *);
-PyAPI_FUNC(node *) Ta35Parser_ParseStringFlags(const char *, grammar *, int,
+node *Ta35Parser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int);
-PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
+node *Ta35Parser_ParseFileFlags(
FILE *fp,
const char *filename, /* decoded from the filesystem encoding */
const char *enc,
@@ -53,7 +53,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
const char *ps2,
perrdetail *err_ret,
int flags);
-PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
+node *Ta35Parser_ParseFileFlagsEx(
FILE *fp,
const char *filename, /* decoded from the filesystem encoding */
const char *enc,
@@ -63,7 +63,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
const char *ps2,
perrdetail *err_ret,
int *flags);
-PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
+node *Ta35Parser_ParseFileObject(
FILE *fp,
PyObject *filename,
const char *enc,
@@ -74,21 +74,21 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
perrdetail *err_ret,
int *flags);
-PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilename(
+node *Ta35Parser_ParseStringFlagsFilename(
const char *s,
const char *filename, /* decoded from the filesystem encoding */
grammar *g,
int start,
perrdetail *err_ret,
int flags);
-PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilenameEx(
+node *Ta35Parser_ParseStringFlagsFilenameEx(
const char *s,
const char *filename, /* decoded from the filesystem encoding */
grammar *g,
int start,
perrdetail *err_ret,
int *flags);
-PyAPI_FUNC(node *) Ta35Parser_ParseStringObject(
+node *Ta35Parser_ParseStringObject(
const char *s,
PyObject *filename,
grammar *g,
diff --git a/ast35/Include/token.h b/ast35/Include/token.h
index 3a79705..f4a4e32 100644
--- a/ast35/Include/token.h
+++ b/ast35/Include/token.h
@@ -80,10 +80,10 @@ extern "C" {
#define ISEOF(x) ((x) == ENDMARKER)
-PyAPI_DATA(const char *) _Ta35Parser_TokenNames[]; /* Token names */
-PyAPI_FUNC(int) Ta35Token_OneChar(int);
-PyAPI_FUNC(int) Ta35Token_TwoChars(int, int);
-PyAPI_FUNC(int) Ta35Token_ThreeChars(int, int, int);
+extern const char *_Ta35Parser_TokenNames[]; /* Token names */
+int Ta35Token_OneChar(int);
+int Ta35Token_TwoChars(int, int);
+int Ta35Token_ThreeChars(int, int, int);
#ifdef __cplusplus
}
diff --git a/ast35/Parser/grammar.c b/ast35/Parser/grammar.c
index f6c91c5..046a6e7 100644
--- a/ast35/Parser/grammar.c
+++ b/ast35/Parser/grammar.c
@@ -9,7 +9,7 @@
#include "token.h"
#include "grammar.h"
-extern int Py_DebugFlag;
+PyAPI_DATA(int) Py_DebugFlag;
grammar *
newgrammar(int start)
diff --git a/ast35/Parser/tokenizer.c b/ast35/Parser/tokenizer.c
index a23546e..ae1a749 100644
--- a/ast35/Parser/tokenizer.c
+++ b/ast35/Parser/tokenizer.c
@@ -32,9 +32,10 @@
|| (c >= 128))
#if PY_MINOR_VERSION >= 4
-extern char *PyOS_Readline(FILE *, FILE *, const char *);
+PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
#else
-extern char *PyOS_Readline(FILE *, FILE *, char *);
+// Python 3.3 doesn't have PyAPI_FUNC, but it's not supported on Windows anyway.
+char *PyOS_Readline(FILE *, FILE *, char *);
#endif
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
@@ -1343,6 +1344,27 @@ verify_identifier(struct tok_state *tok)
}
#endif
+static int
+tok_decimal_tail(struct tok_state *tok)
+{
+ int c;
+ while (1) {
+ do {
+ c = tok_nextc(tok);
+ } while (isdigit(c));
+ if (c != '_') {
+ break;
+ }
+ c = tok_nextc(tok);
+ if (!isdigit(c)) {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return 0;
+ }
+ }
+ return c;
+}
+
/* Get next token, after space stripping etc. */
static int
@@ -1644,64 +1666,88 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
if (c == '0') {
/* Hex, octal or binary -- maybe. */
c = tok_nextc(tok);
- if (c == '.')
- goto fraction;
- if (c == 'j' || c == 'J')
- goto imaginary;
if (c == 'x' || c == 'X') {
-
/* Hex */
c = tok_nextc(tok);
- if (!isxdigit(c)) {
- tok->done = E_TOKEN;
- tok_backup(tok, c);
- return ERRORTOKEN;
- }
do {
- c = tok_nextc(tok);
- } while (isxdigit(c));
+ if (c == '_')
+ c = tok_nextc(tok);
+ if (!isxdigit(c)) {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return ERRORTOKEN;
+ }
+ do {
+ c = tok_nextc(tok);
+ } while (isxdigit(c));
+ } while (c == '_');
}
else if (c == 'o' || c == 'O') {
/* Octal */
c = tok_nextc(tok);
- if (c < '0' || c >= '8') {
- tok->done = E_TOKEN;
- tok_backup(tok, c);
- return ERRORTOKEN;
- }
do {
- c = tok_nextc(tok);
- } while ('0' <= c && c < '8');
+ if (c == '_')
+ c = tok_nextc(tok);
+ if (c < '0' || c >= '8') {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return ERRORTOKEN;
+ }
+ do {
+ c = tok_nextc(tok);
+ } while ('0' <= c && c < '8');
+ } while (c == '_');
}
else if (c == 'b' || c == 'B') {
/* Binary */
c = tok_nextc(tok);
- if (c != '0' && c != '1') {
- tok->done = E_TOKEN;
- tok_backup(tok, c);
- return ERRORTOKEN;
- }
do {
- c = tok_nextc(tok);
- } while (c == '0' || c == '1');
+ if (c == '_')
+ c = tok_nextc(tok);
+ if (c != '0' && c != '1') {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return ERRORTOKEN;
+ }
+ do {
+ c = tok_nextc(tok);
+ } while (c == '0' || c == '1');
+ } while (c == '_');
}
else {
int nonzero = 0;
/* maybe old-style octal; c is first char of it */
/* in any case, allow '0' as a literal */
- while (c == '0')
+ while (1) {
+ if (c == '_') {
+ c = tok_nextc(tok);
+ if (!isdigit(c)) {
+ tok->done = E_TOKEN;
+ tok_backup(tok, c);
+ return ERRORTOKEN;
+ }
+ }
+ if (c != '0')
+ break;
c = tok_nextc(tok);
- while (isdigit(c)) {
+ }
+ if (isdigit(c)) {
nonzero = 1;
- c = tok_nextc(tok);
+ c = tok_decimal_tail(tok);
+ if (c == 0) {
+ return ERRORTOKEN;
+ }
}
- if (c == '.')
+ if (c == '.') {
+ c = tok_nextc(tok);
goto fraction;
+ }
else if (c == 'e' || c == 'E')
goto exponent;
else if (c == 'j' || c == 'J')
goto imaginary;
else if (nonzero) {
+ /* Old-style octal: now disallowed. */
tok->done = E_TOKEN;
tok_backup(tok, c);
return ERRORTOKEN;
@@ -1710,17 +1756,22 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
}
else {
/* Decimal */
- do {
- c = tok_nextc(tok);
- } while (isdigit(c));
+ c = tok_decimal_tail(tok);
+ if (c == 0) {
+ return ERRORTOKEN;
+ }
{
/* Accept floating point numbers. */
if (c == '.') {
+ c = tok_nextc(tok);
fraction:
/* Fraction */
- do {
- c = tok_nextc(tok);
- } while (isdigit(c));
+ if (isdigit(c)) {
+ c = tok_decimal_tail(tok);
+ if (c == 0) {
+ return ERRORTOKEN;
+ }
+ }
}
if (c == 'e' || c == 'E') {
int e;
@@ -1742,9 +1793,10 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
*p_end = tok->cur;
return NUMBER;
}
- do {
- c = tok_nextc(tok);
- } while (isdigit(c));
+ c = tok_decimal_tail(tok);
+ if (c == 0) {
+ return ERRORTOKEN;
+ }
}
if (c == 'j' || c == 'J')
/* Imaginary part */
diff --git a/ast35/Python/Python-ast.c b/ast35/Python/Python-ast.c
index 45cf4bb..d852b9c 100644
--- a/ast35/Python/Python-ast.c
+++ b/ast35/Python/Python-ast.c
@@ -293,8 +293,10 @@ static char *Call_fields[]={
};
static PyTypeObject *Num_type;
_Py_IDENTIFIER(n);
+_Py_IDENTIFIER(contains_underscores);
static char *Num_fields[]={
"n",
+ "contains_underscores",
};
static PyTypeObject *Str_type;
_Py_IDENTIFIER(s);
@@ -608,7 +610,7 @@ static PyGetSetDef ast_type_getsets[] = {
};
static PyTypeObject AST_type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ PyVarObject_HEAD_INIT(NULL, 0)
"_ast35.AST",
sizeof(AST_object),
0,
@@ -937,7 +939,7 @@ static int init_types(void)
if (!Compare_type) return 0;
Call_type = make_type("Call", expr_type, Call_fields, 3);
if (!Call_type) return 0;
- Num_type = make_type("Num", expr_type, Num_fields, 1);
+ Num_type = make_type("Num", expr_type, Num_fields, 2);
if (!Num_type) return 0;
Str_type = make_type("Str", expr_type, Str_fields, 1);
if (!Str_type) return 0;
@@ -2077,7 +2079,8 @@ Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int lineno, int
}
expr_ty
-Num(object n, int lineno, int col_offset, PyArena *arena)
+Num(object n, int contains_underscores, int lineno, int col_offset, PyArena
+ *arena)
{
expr_ty p;
if (!n) {
@@ -2090,6 +2093,7 @@ Num(object n, int lineno, int col_offset, PyArena *arena)
return NULL;
p->kind = Num_kind;
p->v.Num.n = n;
+ p->v.Num.contains_underscores = contains_underscores;
p->lineno = lineno;
p->col_offset = col_offset;
return p;
@@ -3267,6 +3271,12 @@ ast2obj_expr(void* _o)
if (_PyObject_SetAttrId(result, &PyId_n, value) == -1)
goto failed;
Py_DECREF(value);
+ value = ast2obj_int(o->v.Num.contains_underscores);
+ if (!value) goto failed;
+ if (_PyObject_SetAttrId(result, &PyId_contains_underscores, value) ==
+ -1)
+ goto failed;
+ Py_DECREF(value);
break;
case Str_kind:
result = PyType_GenericNew(Str_type, NULL, NULL);
@@ -6267,6 +6277,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
}
if (isinstance) {
object n;
+ int contains_underscores;
if (_PyObject_HasAttrId(obj, &PyId_n)) {
int res;
@@ -6279,7 +6290,17 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
return 1;
}
- *out = Num(n, lineno, col_offset, arena);
+ if (exists_not_none(obj, &PyId_contains_underscores)) {
+ int res;
+ tmp = _PyObject_GetAttrId(obj, &PyId_contains_underscores);
+ if (tmp == NULL) goto failed;
+ res = obj2ast_int(tmp, &contains_underscores, arena);
+ if (res != 0) goto failed;
+ Py_CLEAR(tmp);
+ } else {
+ contains_underscores = 0;
+ }
+ *out = Num(n, contains_underscores, lineno, col_offset, arena);
if (*out == NULL) goto failed;
return 0;
}
diff --git a/ast35/Python/asdl.c b/ast35/Python/asdl.c
new file mode 100644
index 0000000..df387b2
--- /dev/null
+++ b/ast35/Python/asdl.c
@@ -0,0 +1,64 @@
+#include "Python.h"
+#include "asdl.h"
+
+asdl_seq *
+_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
+{
+ asdl_seq *seq = NULL;
+ size_t n;
+
+ /* check size is sane */
+ if (size < 0 ||
+ (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+ /* check if size can be added safely */
+ if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n += sizeof(asdl_seq);
+
+ seq = (asdl_seq *)PyArena_Malloc(arena, n);
+ if (!seq) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ memset(seq, 0, n);
+ seq->size = size;
+ return seq;
+}
+
+asdl_int_seq *
+_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
+{
+ asdl_int_seq *seq = NULL;
+ size_t n;
+
+ /* check size is sane */
+ if (size < 0 ||
+ (size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+ /* check if size can be added safely */
+ if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ n += sizeof(asdl_seq);
+
+ seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
+ if (!seq) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ memset(seq, 0, n);
+ seq->size = size;
+ return seq;
+}
diff --git a/ast35/Python/ast.c b/ast35/Python/ast.c
index 1340717..d9b632c 100644
--- a/ast35/Python/ast.c
+++ b/ast35/Python/ast.c
@@ -2204,7 +2204,9 @@ ast_for_atom(struct compiling *c, const node *n)
return Str(str, LINENO(n), n->n_col_offset, c->c_arena);
}
case NUMBER: {
- PyObject *pynum = parsenumber(c, STR(ch));
+ const char *s = STR(ch);
+ int contains_underscores = strchr(s, '_') != NULL;
+ PyObject *pynum = parsenumber(c, s);
if (!pynum)
return NULL;
@@ -2212,7 +2214,8 @@ ast_for_atom(struct compiling *c, const node *n)
Py_DECREF(pynum);
return NULL;
}
- return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena);
+ return Num(pynum, contains_underscores, LINENO(n),
+ n->n_col_offset, c->c_arena);
}
case ELLIPSIS: /* Ellipsis */
return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena);
@@ -4124,7 +4127,7 @@ ast_for_stmt(struct compiling *c, const node *n)
}
static PyObject *
-parsenumber(struct compiling *c, const char *s)
+parsenumber_raw(struct compiling *c, const char *s)
{
const char *end;
long x;
@@ -4167,6 +4170,31 @@ parsenumber(struct compiling *c, const char *s)
}
static PyObject *
+parsenumber(struct compiling *c, const char *s)
+{
+ char *dup, *end;
+ PyObject *res = NULL;
+
+ assert(s != NULL);
+
+ if (strchr(s, '_') == NULL) {
+ return parsenumber_raw(c, s);
+ }
+ /* Create a duplicate without underscores. */
+ dup = PyMem_Malloc(strlen(s) + 1);
+ end = dup;
+ for (; *s; s++) {
+ if (*s != '_') {
+ *end++ = *s;
+ }
+ }
+ *end = '\0';
+ res = parsenumber_raw(c, dup);
+ PyMem_Free(dup);
+ return res;
+}
+
+static PyObject *
decode_utf8(struct compiling *c, const char **sPtr, const char *end)
{
const char *s, *t;
diff --git a/ast35/Python/graminit.c b/ast35/Python/graminit.c
index 75b05de..9ce881a 100644
--- a/ast35/Python/graminit.c
+++ b/ast35/Python/graminit.c
@@ -2,7 +2,7 @@
#include "pgenheaders.h"
#include "grammar.h"
-PyAPI_DATA(grammar) _Ta35Parser_Grammar;
+grammar _Ta35Parser_Grammar;
static arc arcs_0_0[3] = {
{2, 1},
{3, 1},
diff --git a/setup.py b/setup.py
index 1cd79e5..1f19fc3 100644
--- a/setup.py
+++ b/setup.py
@@ -19,6 +19,7 @@ _ast27 = Extension(
'ast27/Parser/parser.c',
'ast27/Parser/parsetok.c',
'ast27/Parser/tokenizer.c',
+ 'ast27/Python/asdl.c',
'ast27/Python/ast.c',
'ast27/Python/graminit.c',
'ast27/Python/mystrtoul.c',
@@ -54,6 +55,7 @@ _ast35 = Extension(
'ast35/Parser/parser.c',
'ast35/Parser/parsetok.c',
'ast35/Parser/tokenizer.c',
+ 'ast35/Python/asdl.c',
'ast35/Python/ast.c',
'ast35/Python/graminit.c',
'ast35/Python/Python-ast.c',
@@ -82,22 +84,24 @@ comments. The primary goals of this package are correctness and speed.
""".strip()
setup (name = 'typed-ast',
- version = '0.6.1',
+ version = '0.6.3',
description = 'fork of Python 2 and 3 ast modules with type comment support',
long_description = long_description,
author = 'David Fisher',
author_email = 'ddfisher at dropbox.com',
url = 'https://github.com/dropbox/typed_ast',
license='Apache License 2.0',
- platforms = ['POSIX'],
+ platforms = ['POSIX', 'Windows'],
classifiers = [
- 'Development Status :: 3 - Alpha',
+ 'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'Operating System :: POSIX',
+ 'Operating System :: Microsoft',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
'Topic :: Software Development',
],
packages = ['typed_ast'],
diff --git a/typed_ast.egg-info/PKG-INFO b/typed_ast.egg-info/PKG-INFO
index 2316cdf..3c2dafb 100644
--- a/typed_ast.egg-info/PKG-INFO
+++ b/typed_ast.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: typed-ast
-Version: 0.6.1
+Version: 0.6.3
Summary: fork of Python 2 and 3 ast modules with type comment support
Home-page: https://github.com/dropbox/typed_ast
Author: David Fisher
@@ -10,11 +10,14 @@ Description: This package is a fork of the CPython 2.7 and 3.5 `ast` modules wit
ability to parse PEP 484 (https://www.python.org/dev/peps/pep-0484/) type
comments. The primary goals of this package are correctness and speed.
Platform: POSIX
-Classifier: Development Status :: 3 - Alpha
+Platform: Windows
+Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
+Classifier: Operating System :: Microsoft
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
Classifier: Topic :: Software Development
diff --git a/typed_ast.egg-info/SOURCES.txt b/typed_ast.egg-info/SOURCES.txt
index b174e36..519ca60 100644
--- a/typed_ast.egg-info/SOURCES.txt
+++ b/typed_ast.egg-info/SOURCES.txt
@@ -24,6 +24,7 @@ ast27/Parser/parsetok.c
ast27/Parser/tokenizer.c
ast27/Parser/tokenizer.h
ast27/Python/Python-ast.c
+ast27/Python/asdl.c
ast27/Python/ast.c
ast27/Python/graminit.c
ast27/Python/mystrtoul.c
@@ -50,6 +51,7 @@ ast35/Parser/parsetok.c
ast35/Parser/tokenizer.c
ast35/Parser/tokenizer.h
ast35/Python/Python-ast.c
+ast35/Python/asdl.c
ast35/Python/ast.c
ast35/Python/graminit.c
typed_ast/__init__.py
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python3-typed-ast.git
More information about the debian-med-commit
mailing list