Skip to content

Commit

Permalink
Checkpoint. 218 tests are okay; 53 are failing. Done so far:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
gvanrossum committed Mar 15, 2006
1 parent f3175f6 commit 45aecf4
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 6,368 deletions.
18 changes: 3 additions & 15 deletions Grammar/Grammar
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
# with someone who can; ask around on python-dev for help. Fred
# Drake <fdrake@acm.org> will probably be listening there.

# Commands for Kees Blom's railroad program
#diagram:token NAME
#diagram:token NUMBER
#diagram:token STRING
#diagram:token NEWLINE
#diagram:token ENDMARKER
#diagram:token INDENT
#diagram:output\input python.bla
#diagram:token DEDENT
#diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm
#diagram:rules

# Start symbols for the grammar:
# single_input is a single interactive statement;
# file_input is a module or sequence of commands read from an input file;
Expand Down Expand Up @@ -61,8 +49,8 @@ import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
import_from: ('from' ('.'* dotted_name | '.')
'import' ('*' | '(' import_as_names ')' | import_as_names))
import_as_name: NAME [('as' | NAME) NAME]
dotted_as_name: dotted_name [('as' | NAME) NAME]
import_as_name: NAME ['as' NAME]
dotted_as_name: dotted_name ['as' NAME]
import_as_names: import_as_name (',' import_as_name)* [',']
dotted_as_names: dotted_as_name (',' dotted_as_name)*
dotted_name: NAME ('.' NAME)*
Expand All @@ -80,7 +68,7 @@ try_stmt: ('try' ':' suite
['finally' ':' suite] |
'finally' ':' suite))
with_stmt: 'with' test [ with_var ] ':' suite
with_var: ('as' | NAME) expr
with_var: 'as' expr
# NB compile.c makes sure that the default except clause is last
except_clause: 'except' [test [',' test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
Expand Down
6 changes: 3 additions & 3 deletions Include/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ typedef struct {
#define CO_NOFREE 0x0040

#if 0
/* This is no longer used. Stopped defining in 2.5, do not re-use. */
/* These are no longer used. */
#define CO_GENERATOR_ALLOWED 0x1000
#endif
#define CO_FUTURE_DIVISION 0x2000
#define CO_FUTURE_ABSIMPORT 0x4000 /* absolute import by default */
#define CO_FUTURE_WITH_STATEMENT 0x8000
#endif

/* This should be defined if a future statement modifies the syntax.
For example, when a keyword is added.
*/
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
/* #define PY_PARSER_REQUIRES_FUTURE_KEYWORD */

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

Expand Down
2 changes: 2 additions & 0 deletions Include/parsetok.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ typedef struct {

#define PyPARSE_DONT_IMPLY_DEDENT 0x0002

#if 0
#define PyPARSE_WITH_IS_KEYWORD 0x0003
#endif

PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
perrdetail *);
Expand Down
12 changes: 4 additions & 8 deletions Include/patchlevel.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@

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

/* Version parsed out into numeric values */
#define PY_MAJOR_VERSION 2
#define PY_MINOR_VERSION 5
#define PY_MAJOR_VERSION 0
#define PY_MINOR_VERSION 0
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
#define PY_RELEASE_SERIAL 0

/* Version as a string */
#define PY_VERSION "2.5a0"
#define PY_VERSION "3.0x"

/* Subversion Revision number of this file (not of the repository) */
#define PY_PATCHLEVEL_REVISION "$Revision$"
Expand Down
23 changes: 8 additions & 15 deletions Include/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,18 @@ PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);

/* */

#define PyExceptionClass_Check(x) \
(PyClass_Check((x)) \
|| (PyType_Check((x)) && PyType_IsSubtype( \
(PyTypeObject*)(x), (PyTypeObject*)PyExc_BaseException)))
#define PyExceptionClass_Check(x) \
(PyType_Check((x)) && PyType_IsSubtype( \
(PyTypeObject*)(x), (PyTypeObject*)PyExc_BaseException))


#define PyExceptionInstance_Check(x) \
(PyInstance_Check((x)) || \
(PyType_IsSubtype((x)->ob_type, (PyTypeObject*)PyExc_BaseException)))
#define PyExceptionInstance_Check(x) \
(PyType_IsSubtype((x)->ob_type, (PyTypeObject*)PyExc_BaseException))

#define PyExceptionClass_Name(x) \
(PyClass_Check((x)) \
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
: (char *)(((PyTypeObject*)(x))->tp_name))
#define PyExceptionClass_Name(x) \
((char *)(((PyTypeObject*)(x))->tp_name))

#define PyExceptionInstance_Class(x) \
((PyInstance_Check((x)) \
? (PyObject*)((PyInstanceObject*)(x))->in_class \
: (PyObject*)((x)->ob_type)))
#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type))


/* Predefined exceptions */
Expand Down
5 changes: 2 additions & 3 deletions Include/pythonrun.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
extern "C" {
#endif

#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSIMPORT | \
CO_FUTURE_WITH_STATEMENT)
#define PyCF_MASK_OBSOLETE (CO_NESTED)
#define PyCF_MASK 0
#define PyCF_MASK_OBSOLETE 0
#define PyCF_SOURCE_IS_UTF8 0x0100
#define PyCF_DONT_IMPLY_DEDENT 0x0200
#define PyCF_ONLY_AST 0x0400
Expand Down
5 changes: 0 additions & 5 deletions Lib/copy_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
C, not for instances of user-defined classes.
"""

from types import ClassType as _ClassType

__all__ = ["pickle", "constructor",
"add_extension", "remove_extension", "clear_extension_cache"]

dispatch_table = {}

def pickle(ob_type, pickle_function, constructor_ob=None):
if type(ob_type) is _ClassType:
raise TypeError("copy_reg is not intended for use with classes")

if not callable(pickle_function):
raise TypeError("reduction functions must be callable")
dispatch_table[ob_type] = pickle_function
Expand Down
2 changes: 1 addition & 1 deletion Lib/distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import string
import sys

from errors import DistutilsPlatformError
from .errors import DistutilsPlatformError

# These are needed in a couple of spots, so just compute them once.
PREFIX = os.path.normpath(sys.prefix)
Expand Down
3 changes: 2 additions & 1 deletion Lib/encodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"""#"

import codecs, types, aliases
import codecs, types
from . import aliases

_cache = {}
_unknown = '--unknown--'
Expand Down
8 changes: 4 additions & 4 deletions Lib/test/test_opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

print '2.2 raise class exceptions'

class AClass: pass
class AClass(Exception): pass
class BClass(AClass): pass
class CClass: pass
class CClass(Exception): pass
class DClass(AClass):
def __init__(self, ignore):
pass
Expand Down Expand Up @@ -58,8 +58,8 @@ def __init__(self, ignore):
if v != b: raise TestFailed, "v!=b AClass"

# not enough arguments
try: raise BClass, a
except TypeError: pass
##try: raise BClass, a
##except TypeError: pass

try: raise DClass, a
except DClass, v:
Expand Down
Loading

0 comments on commit 45aecf4

Please sign in to comment.