Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 45aecf4

Browse files
committed
Checkpoint. 218 tests are okay; 53 are failing. Done so far:
- all classes are new-style (but ripping out classobject.[ch] isn't done) - int/int -> float - all exceptions must derive from BaseException - absolute import - 'as' and 'with' are keywords
1 parent f3175f6 commit 45aecf4

24 files changed

Lines changed: 90 additions & 6368 deletions

File tree

Grammar/Grammar

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
# with someone who can; ask around on python-dev for help. Fred
88
# Drake <[email protected]> will probably be listening there.
99

10-
# Commands for Kees Blom's railroad program
11-
#diagram:token NAME
12-
#diagram:token NUMBER
13-
#diagram:token STRING
14-
#diagram:token NEWLINE
15-
#diagram:token ENDMARKER
16-
#diagram:token INDENT
17-
#diagram:output\input python.bla
18-
#diagram:token DEDENT
19-
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
20-
#diagram:rules
21-
2210
# Start symbols for the grammar:
2311
# single_input is a single interactive statement;
2412
# file_input is a module or sequence of commands read from an input file;
@@ -61,8 +49,8 @@ import_stmt: import_name | import_from
6149
import_name: 'import' dotted_as_names
6250
import_from: ('from' ('.'* dotted_name | '.')
6351
'import' ('*' | '(' import_as_names ')' | import_as_names))
64-
import_as_name: NAME [('as' | NAME) NAME]
65-
dotted_as_name: dotted_name [('as' | NAME) NAME]
52+
import_as_name: NAME ['as' NAME]
53+
dotted_as_name: dotted_name ['as' NAME]
6654
import_as_names: import_as_name (',' import_as_name)* [',']
6755
dotted_as_names: dotted_as_name (',' dotted_as_name)*
6856
dotted_name: NAME ('.' NAME)*
@@ -80,7 +68,7 @@ try_stmt: ('try' ':' suite
8068
['finally' ':' suite] |
8169
'finally' ':' suite))
8270
with_stmt: 'with' test [ with_var ] ':' suite
83-
with_var: ('as' | NAME) expr
71+
with_var: 'as' expr
8472
# NB compile.c makes sure that the default except clause is last
8573
except_clause: 'except' [test [',' test]]
8674
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT

Include/code.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ typedef struct {
4141
#define CO_NOFREE 0x0040
4242

4343
#if 0
44-
/* This is no longer used. Stopped defining in 2.5, do not re-use. */
44+
/* These are no longer used. */
4545
#define CO_GENERATOR_ALLOWED 0x1000
46-
#endif
4746
#define CO_FUTURE_DIVISION 0x2000
4847
#define CO_FUTURE_ABSIMPORT 0x4000 /* absolute import by default */
4948
#define CO_FUTURE_WITH_STATEMENT 0x8000
49+
#endif
5050

5151
/* This should be defined if a future statement modifies the syntax.
5252
For example, when a keyword is added.
5353
*/
54-
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
54+
/* #define PY_PARSER_REQUIRES_FUTURE_KEYWORD */
5555

5656
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
5757

Include/parsetok.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ typedef struct {
2323

2424
#define PyPARSE_DONT_IMPLY_DEDENT 0x0002
2525

26+
#if 0
2627
#define PyPARSE_WITH_IS_KEYWORD 0x0003
28+
#endif
2729

2830
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
2931
perrdetail *);

Include/patchlevel.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11

2-
/* Newfangled version identification scheme.
3-
4-
This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL
5-
was available. To test for presence of the scheme, test for
6-
defined(PY_MAJOR_VERSION).
2+
/* Python version identification scheme.
73
84
When the major or minor version changes, the VERSION variable in
95
configure.in must also be changed.
@@ -19,14 +15,14 @@
1915
/* Higher for patch releases */
2016

2117
/* Version parsed out into numeric values */
22-
#define PY_MAJOR_VERSION 2
23-
#define PY_MINOR_VERSION 5
18+
#define PY_MAJOR_VERSION 0
19+
#define PY_MINOR_VERSION 0
2420
#define PY_MICRO_VERSION 0
2521
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
2622
#define PY_RELEASE_SERIAL 0
2723

2824
/* Version as a string */
29-
#define PY_VERSION "2.5a0"
25+
#define PY_VERSION "3.0x"
3026

3127
/* Subversion Revision number of this file (not of the repository) */
3228
#define PY_PATCHLEVEL_REVISION "$Revision$"

Include/pyerrors.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,18 @@ PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
2828

2929
/* */
3030

31-
#define PyExceptionClass_Check(x) \
32-
(PyClass_Check((x)) \
33-
|| (PyType_Check((x)) && PyType_IsSubtype( \
34-
(PyTypeObject*)(x), (PyTypeObject*)PyExc_BaseException)))
31+
#define PyExceptionClass_Check(x) \
32+
(PyType_Check((x)) && PyType_IsSubtype( \
33+
(PyTypeObject*)(x), (PyTypeObject*)PyExc_BaseException))
3534

3635

37-
#define PyExceptionInstance_Check(x) \
38-
(PyInstance_Check((x)) || \
39-
(PyType_IsSubtype((x)->ob_type, (PyTypeObject*)PyExc_BaseException)))
36+
#define PyExceptionInstance_Check(x) \
37+
(PyType_IsSubtype((x)->ob_type, (PyTypeObject*)PyExc_BaseException))
4038

41-
#define PyExceptionClass_Name(x) \
42-
(PyClass_Check((x)) \
43-
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
44-
: (char *)(((PyTypeObject*)(x))->tp_name))
39+
#define PyExceptionClass_Name(x) \
40+
((char *)(((PyTypeObject*)(x))->tp_name))
4541

46-
#define PyExceptionInstance_Class(x) \
47-
((PyInstance_Check((x)) \
48-
? (PyObject*)((PyInstanceObject*)(x))->in_class \
49-
: (PyObject*)((x)->ob_type)))
42+
#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))
5043

5144

5245
/* Predefined exceptions */

Include/pythonrun.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
extern "C" {
88
#endif
99

10-
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSIMPORT | \
11-
CO_FUTURE_WITH_STATEMENT)
12-
#define PyCF_MASK_OBSOLETE (CO_NESTED)
10+
#define PyCF_MASK 0
11+
#define PyCF_MASK_OBSOLETE 0
1312
#define PyCF_SOURCE_IS_UTF8 0x0100
1413
#define PyCF_DONT_IMPLY_DEDENT 0x0200
1514
#define PyCF_ONLY_AST 0x0400

Lib/copy_reg.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
C, not for instances of user-defined classes.
55
"""
66

7-
from types import ClassType as _ClassType
8-
97
__all__ = ["pickle", "constructor",
108
"add_extension", "remove_extension", "clear_extension_cache"]
119

1210
dispatch_table = {}
1311

1412
def pickle(ob_type, pickle_function, constructor_ob=None):
15-
if type(ob_type) is _ClassType:
16-
raise TypeError("copy_reg is not intended for use with classes")
17-
1813
if not callable(pickle_function):
1914
raise TypeError("reduction functions must be callable")
2015
dispatch_table[ob_type] = pickle_function

Lib/distutils/sysconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import string
1717
import sys
1818

19-
from errors import DistutilsPlatformError
19+
from .errors import DistutilsPlatformError
2020

2121
# These are needed in a couple of spots, so just compute them once.
2222
PREFIX = os.path.normpath(sys.prefix)

Lib/encodings/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
2828
"""#"
2929

30-
import codecs, types, aliases
30+
import codecs, types
31+
from . import aliases
3132

3233
_cache = {}
3334
_unknown = '--unknown--'

Lib/test/test_opcodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
print '2.2 raise class exceptions'
2727

28-
class AClass: pass
28+
class AClass(Exception): pass
2929
class BClass(AClass): pass
30-
class CClass: pass
30+
class CClass(Exception): pass
3131
class DClass(AClass):
3232
def __init__(self, ignore):
3333
pass
@@ -58,8 +58,8 @@ def __init__(self, ignore):
5858
if v != b: raise TestFailed, "v!=b AClass"
5959

6060
# not enough arguments
61-
try: raise BClass, a
62-
except TypeError: pass
61+
##try: raise BClass, a
62+
##except TypeError: pass
6363

6464
try: raise DClass, a
6565
except DClass, v:

0 commit comments

Comments
 (0)