Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove tabs

  • Loading branch information...
commit e908c0b9262008014d0698732acb5de48dbbf950 1 parent 8907aef
@robertwb robertwb authored
View
2  Cython/Compiler/Builtin.py
@@ -13,7 +13,7 @@
('abs', "O", "O", "PyNumber_Absolute"),
#('chr', "", "", ""),
#('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
- #('compile', "", "", ""), # PyObject* Py_CompileString( char *str, char *filename, int start)
+ #('compile', "", "", ""), # PyObject* Py_CompileString( char *str, char *filename, int start)
('delattr', "OO", "r", "PyObject_DelAttr"),
('dir', "O", "O", "PyObject_Dir"),
('divmod', "OO", "O", "PyNumber_Divmod"),
View
2  Cython/Compiler/Code.py
@@ -849,7 +849,7 @@ def put_init_to_py_none(self, cname, type, nanny=True):
def put_init_var_to_py_none(self, entry, template = "%s", nanny=True):
code = template % entry.cname
#if entry.type.is_extension_type:
- # code = "((PyObject*)%s)" % code
+ # code = "((PyObject*)%s)" % code
self.put_init_to_py_none(code, entry.type, nanny)
def put_pymethoddef(self, entry, term):
View
72 Cython/Compiler/ExprNodes.py
@@ -425,9 +425,9 @@ def target_code(self):
def calculate_result_code(self):
self.not_implemented("calculate_result_code")
-# def release_target_temp(self, env):
-# # Release temporaries used by LHS of an assignment.
-# self.release_subexpr_temps(env)
+# def release_target_temp(self, env):
+# # Release temporaries used by LHS of an assignment.
+# self.release_subexpr_temps(env)
def release_temp(self, env):
# If this node owns a temporary result, release it,
@@ -2454,7 +2454,7 @@ def generate_result_code(self, code):
if self.is_temp and self.type.is_pyobject:
#return_type = self.type # func_type.return_type
#print "SimpleCallNode.generate_result_code: casting", rhs, \
- # "from", return_type, "to pyobject" ###
+ # "from", return_type, "to pyobject" ###
rhs = typecast(py_object_type, self.type, rhs)
else:
lhs = ""
@@ -2749,7 +2749,7 @@ def analyse_as_ordinary_attribute(self, env, target):
pass
## Reference to C array turns into pointer to first element.
#while self.type.is_array:
- # self.type = self.type.element_ptr_type()
+ # self.type = self.type.element_ptr_type()
if self.is_py_attr:
if not target:
self.is_temp = 1
@@ -2990,12 +2990,12 @@ def allocate_target_temps(self, env, rhs):
for node in self.coerced_unpacked_items:
node.release_temp(env)
-# def release_target_temp(self, env):
-# #for arg in self.args:
-# # arg.release_target_temp(env)
-# #for node in self.coerced_unpacked_items:
-# # node.release_temp(env)
-# self.iterator.release_temp(env)
+# def release_target_temp(self, env):
+# #for arg in self.args:
+# # arg.release_target_temp(env)
+# #for node in self.coerced_unpacked_items:
+# # node.release_temp(env)
+# self.iterator.release_temp(env)
def generate_result_code(self, code):
self.generate_operation_code(code)
@@ -4134,17 +4134,17 @@ def py_operation_function(self):
return self.py_functions[self.operator]
py_functions = {
- "|": "PyNumber_Or",
- "^": "PyNumber_Xor",
- "&": "PyNumber_And",
- "<<": "PyNumber_Lshift",
- ">>": "PyNumber_Rshift",
- "+": "PyNumber_Add",
- "-": "PyNumber_Subtract",
- "*": "PyNumber_Multiply",
- "/": "__Pyx_PyNumber_Divide",
- "//": "PyNumber_FloorDivide",
- "%": "PyNumber_Remainder",
+ "|": "PyNumber_Or",
+ "^": "PyNumber_Xor",
+ "&": "PyNumber_And",
+ "<<": "PyNumber_Lshift",
+ ">>": "PyNumber_Rshift",
+ "+": "PyNumber_Add",
+ "-": "PyNumber_Subtract",
+ "*": "PyNumber_Multiply",
+ "/": "__Pyx_PyNumber_Divide",
+ "//": "PyNumber_FloorDivide",
+ "%": "PyNumber_Remainder",
"**": "PyNumber_Power"
}
@@ -4834,20 +4834,20 @@ def annotate(self, code):
binop_node_classes = {
- "or": BoolBinopNode,
- "and": BoolBinopNode,
- "|": IntBinopNode,
- "^": IntBinopNode,
- "&": IntBinopNode,
- "<<": IntBinopNode,
- ">>": IntBinopNode,
- "+": AddNode,
- "-": SubNode,
- "*": MulNode,
- "/": NumBinopNode,
- "//": FloorDivNode,
- "%": ModNode,
- "**": PowNode
+ "or": BoolBinopNode,
+ "and": BoolBinopNode,
+ "|": IntBinopNode,
+ "^": IntBinopNode,
+ "&": IntBinopNode,
+ "<<": IntBinopNode,
+ ">>": IntBinopNode,
+ "+": AddNode,
+ "-": SubNode,
+ "*": MulNode,
+ "/": NumBinopNode,
+ "//": FloorDivNode,
+ "%": ModNode,
+ "**": PowNode
}
def binop_node(pos, operator, operand1, operand2):
View
118 Cython/Compiler/ModuleNode.py
@@ -695,7 +695,7 @@ def generate_typeobject_predeclaration(self, entry, code):
name))
# ??? Do we really need the rest of this? ???
#else:
- # code.putln("staticforward PyTypeObject %s;" % name)
+ # code.putln("staticforward PyTypeObject %s;" % name)
def generate_exttype_vtable_struct(self, entry, code):
code.mark_pos(entry.pos)
@@ -884,7 +884,7 @@ def generate_new_function(self, scope, code):
"p = %s;"
% type.cast_code("o"))
#if need_self_cast:
- # self.generate_self_cast(scope, code)
+ # self.generate_self_cast(scope, code)
if type.vtabslot_cname:
vtab_base_type = type
while vtab_base_type.base_type and vtab_base_type.base_type.vtabstruct_cname:
@@ -1343,7 +1343,7 @@ def generate_descr_set_function(self, scope, code):
code.putln(
"return -1;")
code.putln(
- "}")
+ "}")
code.putln(
"}")
@@ -2234,65 +2234,65 @@ def generate_utility_functions(self, env, code, h_code):
static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
- PyObject *all = __Pyx_GetAttrString(v, "__all__");
- PyObject *dict, *name, *value;
- int skip_leading_underscores = 0;
- int pos, err;
-
- if (all == NULL) {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError))
- return -1; /* Unexpected error */
- PyErr_Clear();
- dict = __Pyx_GetAttrString(v, "__dict__");
- if (dict == NULL) {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError))
- return -1;
- PyErr_SetString(PyExc_ImportError,
- "from-import-* object has no __dict__ and no __all__");
- return -1;
- }
- all = PyMapping_Keys(dict);
- Py_DECREF(dict);
- if (all == NULL)
- return -1;
- skip_leading_underscores = 1;
- }
-
- for (pos = 0, err = 0; ; pos++) {
- name = PySequence_GetItem(all, pos);
- if (name == NULL) {
- if (!PyErr_ExceptionMatches(PyExc_IndexError))
- err = -1;
- else
- PyErr_Clear();
- break;
- }
- if (skip_leading_underscores &&
+ PyObject *all = __Pyx_GetAttrString(v, "__all__");
+ PyObject *dict, *name, *value;
+ int skip_leading_underscores = 0;
+ int pos, err;
+
+ if (all == NULL) {
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
+ return -1; /* Unexpected error */
+ PyErr_Clear();
+ dict = __Pyx_GetAttrString(v, "__dict__");
+ if (dict == NULL) {
+ if (!PyErr_ExceptionMatches(PyExc_AttributeError))
+ return -1;
+ PyErr_SetString(PyExc_ImportError,
+ "from-import-* object has no __dict__ and no __all__");
+ return -1;
+ }
+ all = PyMapping_Keys(dict);
+ Py_DECREF(dict);
+ if (all == NULL)
+ return -1;
+ skip_leading_underscores = 1;
+ }
+
+ for (pos = 0, err = 0; ; pos++) {
+ name = PySequence_GetItem(all, pos);
+ if (name == NULL) {
+ if (!PyErr_ExceptionMatches(PyExc_IndexError))
+ err = -1;
+ else
+ PyErr_Clear();
+ break;
+ }
+ if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
- PyString_Check(name) &&
- PyString_AS_STRING(name)[0] == '_')
+ PyString_Check(name) &&
+ PyString_AS_STRING(name)[0] == '_')
#else
- PyUnicode_Check(name) &&
- PyUnicode_AS_UNICODE(name)[0] == '_')
+ PyUnicode_Check(name) &&
+ PyUnicode_AS_UNICODE(name)[0] == '_')
#endif
- {
- Py_DECREF(name);
- continue;
- }
- value = PyObject_GetAttr(v, name);
- if (value == NULL)
- err = -1;
- else if (PyDict_CheckExact(locals))
- err = PyDict_SetItem(locals, name, value);
- else
- err = PyObject_SetItem(locals, name, value);
- Py_DECREF(name);
- Py_XDECREF(value);
- if (err != 0)
- break;
- }
- Py_DECREF(all);
- return err;
+ {
+ Py_DECREF(name);
+ continue;
+ }
+ value = PyObject_GetAttr(v, name);
+ if (value == NULL)
+ err = -1;
+ else if (PyDict_CheckExact(locals))
+ err = PyDict_SetItem(locals, name, value);
+ else
+ err = PyObject_SetItem(locals, name, value);
+ Py_DECREF(name);
+ Py_XDECREF(value);
+ if (err != 0)
+ break;
+ }
+ Py_DECREF(all);
+ return err;
}
View
48 Cython/Compiler/Nodes.py
@@ -2994,11 +2994,11 @@ def analyse_expressions(self, env):
for stat in self.stats:
stat.allocate_lhs_temps(env)
-# def analyse_expressions(self, env):
-# for stat in self.stats:
-# stat.analyse_expressions_1(env, use_temp = 1)
-# for stat in self.stats:
-# stat.analyse_expressions_2(env)
+# def analyse_expressions(self, env):
+# for stat in self.stats:
+# stat.analyse_expressions_1(env, use_temp = 1)
+# for stat in self.stats:
+# stat.analyse_expressions_2(env)
def generate_execution_code(self, code):
for stat in self.stats:
@@ -3158,18 +3158,18 @@ def py_operation_function(self):
return self.py_functions[self.operator]
py_functions = {
- "|": "PyNumber_InPlaceOr",
- "^": "PyNumber_InPlaceXor",
- "&": "PyNumber_InPlaceAnd",
- "+": "PyNumber_InPlaceAdd",
- "-": "PyNumber_InPlaceSubtract",
- "*": "PyNumber_InPlaceMultiply",
- "/": "PyNumber_InPlaceDivide",
- "%": "PyNumber_InPlaceRemainder",
- "<<": "PyNumber_InPlaceLshift",
- ">>": "PyNumber_InPlaceRshift",
- "**": "PyNumber_InPlacePower",
- "//": "PyNumber_InPlaceFloorDivide",
+ "|": "PyNumber_InPlaceOr",
+ "^": "PyNumber_InPlaceXor",
+ "&": "PyNumber_InPlaceAnd",
+ "+": "PyNumber_InPlaceAdd",
+ "-": "PyNumber_InPlaceSubtract",
+ "*": "PyNumber_InPlaceMultiply",
+ "/": "PyNumber_InPlaceDivide",
+ "%": "PyNumber_InPlaceRemainder",
+ "<<": "PyNumber_InPlaceLshift",
+ ">>": "PyNumber_InPlaceRshift",
+ "**": "PyNumber_InPlacePower",
+ "//": "PyNumber_InPlaceFloorDivide",
}
def annotate(self, code):
@@ -3625,8 +3625,8 @@ def generate_execution_code(self, code, end_label):
self.condition.free_temps(code)
self.body.generate_execution_code(code)
#code.putln(
- # "goto %s;" %
- # end_label)
+ # "goto %s;" %
+ # end_label)
code.put_goto(end_label)
code.putln("}")
@@ -3865,9 +3865,9 @@ def analyse_expressions(self, env):
error(self.target.pos,
"Integer for-loop variable must be of type int or Python object")
#if not (target_type.is_pyobject
- # or target_type.assignable_from(PyrexTypes.c_int_type)):
- # error(self.target.pos,
- # "Cannot assign integer to variable of type '%s'" % target_type)
+ # or target_type.assignable_from(PyrexTypes.c_int_type)):
+ # error(self.target.pos,
+ # "Cannot assign integer to variable of type '%s'" % target_type)
if target_type.is_numeric:
self.is_py_target = 0
if isinstance(self.target, ExprNodes.IndexNode) and self.target.is_buffer_access:
@@ -4383,8 +4383,8 @@ def put_error_catcher(self, code, error_label, i, catch_label, temps_to_clean_up
"%s = %s;" % (
Naming.exc_lineno_name, Naming.lineno_cname))
#code.putln(
- # "goto %s;" %
- # catch_label)
+ # "goto %s;" %
+ # catch_label)
code.put_goto(catch_label)
code.putln(
"}")
View
14 Cython/Compiler/Parsing.py
@@ -681,11 +681,11 @@ def p_string_literal(s):
#print "p_string_literal: value =", repr(value) ###
return kind, value
-# list_display ::= "[" [listmaker] "]"
-# listmaker ::= expression ( list_for | ( "," expression )* [","] )
-# list_iter ::= list_for | list_if
-# list_for ::= "for" expression_list "in" testlist [list_iter]
-# list_if ::= "if" test [list_iter]
+# list_display ::= "[" [listmaker] "]"
+# listmaker ::= expression ( list_for | ( "," expression )* [","] )
+# list_iter ::= list_for | list_if
+# list_for ::= "for" expression_list "in" testlist [list_iter]
+# list_if ::= "if" test [list_iter]
def p_list_maker(s):
# s.sy == '['
@@ -1363,7 +1363,7 @@ def p_include_statement(s, ctx):
def p_with_statement(s):
pos = s.position()
s.next() # 'with'
-# if s.sy == 'IDENT' and s.systring in ('gil', 'nogil'):
+# if s.sy == 'IDENT' and s.systring in ('gil', 'nogil'):
if s.sy == 'IDENT' and s.systring == 'nogil':
state = s.systring
s.next()
@@ -1380,7 +1380,7 @@ def p_with_statement(s):
s.error("Multiple with statement target values not allowed without paranthesis")
body = p_suite(s)
return Nodes.WithStatNode(pos, manager = manager,
- target = target, body = body)
+ target = target, body = body)
def p_simple_statement(s, first_statement = 0):
#print "p_simple_statement:", s.sy, s.systring ###
View
10 Cython/Compiler/PyrexTypes.py
@@ -558,7 +558,7 @@ class CBIntType(CIntType):
class CAnonEnumType(CIntType):
- is_enum = 1
+ is_enum = 1
class CUIntType(CIntType):
@@ -754,7 +754,7 @@ def same_c_signature_as(self, other_type, as_cmethod = 0):
def same_c_signature_as_resolved_type(self, other_type, as_cmethod = 0):
#print "CFuncType.same_c_signature_as_resolved_type:", \
- # self, other_type, "as_cmethod =", as_cmethod ###
+ # self, other_type, "as_cmethod =", as_cmethod ###
if other_type is error_type:
return 1
if not other_type.is_cfunction:
@@ -786,7 +786,7 @@ def compatible_signature_with(self, other_type, as_cmethod = 0):
def compatible_signature_with_resolved_type(self, other_type, as_cmethod):
#print "CFuncType.same_c_signature_as_resolved_type:", \
- # self, other_type, "as_cmethod =", as_cmethod ###
+ # self, other_type, "as_cmethod =", as_cmethod ###
if other_type is error_type:
return 1
if not other_type.is_cfunction:
@@ -901,7 +901,7 @@ def declaration_code(self, entity_code,
return self.return_type.declaration_code(
"%s%s(%s)%s" % (cc, entity_code, arg_decl_code, trailer),
for_display, dll_linkage, pyrex)
-
+
def function_header_code(self, func_name, arg_code):
return "%s%s(%s)" % (self.calling_convention_prefix(),
func_name, arg_code)
@@ -1134,7 +1134,7 @@ class ErrorType(PyrexType):
is_error = 1
exception_value = "0"
- exception_check = 0
+ exception_check = 0
to_py_function = "dummy"
from_py_function = "dummy"
View
2  Cython/Compiler/Scanning.py
@@ -371,7 +371,7 @@ def indentation_action(self, text):
self.begin('')
# Indentation within brackets should be ignored.
#if self.bracket_nesting_level > 0:
- # return
+ # return
# Check that tabs and spaces are being used consistently.
if text:
c = text[0]
View
12 Cython/Compiler/Symtab.py
@@ -392,7 +392,7 @@ def declare_enum(self, name, pos, cname, typedef_flag,
visibility = visibility)
entry.enum_values = []
self.sue_entries.append(entry)
- return entry
+ return entry
def declare_var(self, name, type, pos,
cname = None, visibility = 'private', is_cdef = 0):
@@ -662,7 +662,7 @@ def defines_any(self, names):
# Test whether any of the given names are
# defined in this scope.
for name in names:
- if name in self.entries:
+ if name in self.entries:
return 1
return 0
@@ -1028,7 +1028,7 @@ def declare_c_class(self, name, pos, defining = 0, implementing = 0,
if objstruct_cname:
type.objstruct_cname = objstruct_cname
elif not entry.in_cinclude:
- type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
+ type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
else:
error(entry.pos,
"Object name required for 'public' or 'extern' C class")
@@ -1067,13 +1067,13 @@ def declare_c_class(self, name, pos, defining = 0, implementing = 0,
if objstruct_cname:
if type.objstruct_cname and type.objstruct_cname != objstruct_cname:
error(pos, "Object struct name differs from previous declaration")
- type.objstruct_cname = objstruct_cname
+ type.objstruct_cname = objstruct_cname
if typeobj_cname:
if type.typeobj_cname and type.typeobj_cname != typeobj_cname:
error(pos, "Type object name differs from previous declaration")
type.typeobj_cname = typeobj_cname
#
- # Return new or existing entry
+ # Return new or existing entry
#
return entry
@@ -1329,7 +1329,7 @@ def release_temp(self, cname):
self.outer_scope.release_temp(cname)
#def recycle_pending_temps(self):
- # self.outer_scope.recycle_pending_temps()
+ # self.outer_scope.recycle_pending_temps()
def add_default_value(self, type):
return self.outer_scope.add_default_value(type)
View
2  Cython/Compiler/TypeSlots.py
@@ -398,7 +398,7 @@ def generate_dynamic_init_code(self, scope, code):
## extern function pointer.
#
#slots_initialised_from_extern = (
-# "tp_free",
+# "tp_free",
#)
#------------------------------------------------------------------------------------------
View
30 Cython/Distutils/build_ext.py
@@ -106,17 +106,17 @@ def cython_sources(self, sources, extension):
# cplus will also be set to true is extension.language is equal to
# 'C++' or 'c++'.
#try:
- # create_listing = self.pyrex_create_listing or \
- # extension.pyrex_create_listing
- # cplus = self.pyrex_cplus or \
- # extension.pyrex_cplus or \
- # (extension.language != None and \
- # extension.language.lower() == 'c++')
+ # create_listing = self.pyrex_create_listing or \
+ # extension.pyrex_create_listing
+ # cplus = self.pyrex_cplus or \
+ # extension.pyrex_cplus or \
+ # (extension.language != None and \
+ # extension.language.lower() == 'c++')
#except AttributeError:
- # create_listing = self.pyrex_create_listing
- # cplus = self.pyrex_cplus or \
- # (extension.language != None and \
- # extension.language.lower() == 'c++')
+ # create_listing = self.pyrex_create_listing
+ # cplus = self.pyrex_cplus or \
+ # (extension.language != None and \
+ # extension.language.lower() == 'c++')
create_listing = self.pyrex_create_listing or \
getattr(extension, 'pyrex_create_listing', 0)
@@ -125,10 +125,10 @@ def cython_sources(self, sources, extension):
pyrex_gen_pxi = self.pyrex_gen_pxi or getattr(extension, 'pyrex_gen_pxi', 0)
# Set up the include_path for the Cython compiler:
- # 1. Start with the command line option.
- # 2. Add in any (unique) paths from the extension
- # pyrex_include_dirs (if Cython.Distutils.extension is used).
- # 3. Add in any (unique) paths from the extension include_dirs
+ # 1. Start with the command line option.
+ # 2. Add in any (unique) paths from the extension
+ # pyrex_include_dirs (if Cython.Distutils.extension is used).
+ # 3. Add in any (unique) paths from the extension include_dirs
includes = self.pyrex_include_dirs
try:
for i in extension.pyrex_include_dirs:
@@ -162,7 +162,7 @@ def cython_sources(self, sources, extension):
if ext == ".py":
# FIXME: we might want to special case this some more
ext = '.pyx'
- if ext == ".pyx": # Cython source file
+ if ext == ".pyx": # Cython source file
output_dir = target_dir or os.path.dirname(source)
new_sources.append(os.path.join(output_dir, base + target_ext))
pyrex_sources.append(source)
View
4 Cython/Mac/DarwinSystem.py
@@ -51,8 +51,8 @@
"-Wl,-F.,-w -bundle -undefined dynamic_lookup" \
.split()
#linker_options = \
-# "-Wl,-F.,-w -bundle -framework Python" \
-# .split()
+# "-Wl,-F.,-w -bundle -framework Python" \
+# .split()
class CCompilerError(PyrexError):
pass
View
4 Cython/Mac/TS_Misc_Suite.py
@@ -27,10 +27,10 @@ def DoScript(self, _object, _attributes={}, **_arguments):
_reply, _arguments, _attributes = self.send(_code, _subcode,
_arguments, _attributes)
#if _arguments.has_key('errn'):
- # raise aetools.Error, aetools.decodeerror(_arguments)
+ # raise aetools.Error, aetools.decodeerror(_arguments)
# XXXX Optionally decode result
#if _arguments.has_key('----'):
- # return _arguments['----']
+ # return _arguments['----']
errn = 0
stat = 0
stdout = ""
View
12 Cython/Plex/DFA.py
@@ -126,12 +126,12 @@ def highest_priority_action(self, state_set):
best_priority = priority
return best_action
-# def old_to_new_set(self, old_state_set):
-# """
-# Return the new state corresponding to a set of old states as
-# a singleton set.
-# """
-# return {self.old_to_new(old_state_set):1}
+# def old_to_new_set(self, old_state_set):
+# """
+# Return the new state corresponding to a set of old states as
+# a singleton set.
+# """
+# return {self.old_to_new(old_state_set):1}
def new_to_old(self, new_state):
"""Given a new state, return a set of corresponding old states."""
View
12 Cython/Plex/Machines.py
@@ -101,12 +101,12 @@ def get_action(self):
def get_action_priority(self):
return self.action_priority
-# def merge_actions(self, other_state):
-# """Merge actions of other state into this state according
+# def merge_actions(self, other_state):
+# """Merge actions of other state into this state according
# to their priorities."""
-# action = other_state.get_action()
-# priority = other_state.get_action_priority()
-# self.set_action(action, priority)
+# action = other_state.get_action()
+# priority = other_state.get_action_priority()
+# self.set_action(action, priority)
def is_accepting(self):
return self.action is not None
@@ -119,7 +119,7 @@ def dump(self, file):
# Header
file.write(" State %d:\n" % self.number)
# Transitions
-# self.dump_transitions(file)
+# self.dump_transitions(file)
self.transitions.dump(file)
# Action
action = self.action
View
84 Cython/Plex/Regexps.py
@@ -1,8 +1,8 @@
#=======================================================================
#
-# Python Lexical Analyser
+# Python Lexical Analyser
#
-# Regular Expressions
+# Regular Expressions
#
#=======================================================================
@@ -14,7 +14,7 @@
import Errors
#
-# Constants
+# Constants
#
BOL = 'bol'
@@ -24,7 +24,7 @@
nl_code = ord('\n')
#
-# Helper functions
+# Helper functions
#
def chars_to_ranges(s):
@@ -98,20 +98,20 @@ def CodeRange(code1, code2):
return RawCodeRange(code1, code2)
#
-# Abstract classes
+# Abstract classes
#
class RE:
"""RE is the base class for regular expression constructors.
The following operators are defined on REs:
- re1 + re2 is an RE which matches |re1| followed by |re2|
- re1 | re2 is an RE which matches either |re1| or |re2|
+ re1 + re2 is an RE which matches |re1| followed by |re2|
+ re1 | re2 is an RE which matches either |re1| or |re2|
"""
nullable = 1 # True if this RE can match 0 input symbols
match_nl = 1 # True if this RE can match a string ending with '\n'
- str = None # Set to a string to override the class's __str__ result
+ str = None # Set to a string to override the class's __str__ result
def build_machine(self, machine, initial_state, final_state,
match_bol, nocase):
@@ -173,42 +173,42 @@ def wrong_type(self, num, value, expected):
num, self.__class__.__name__, expected, got))
#
-# Primitive RE constructors
-# -------------------------
+# Primitive RE constructors
+# -------------------------
#
-# These are the basic REs from which all others are built.
+# These are the basic REs from which all others are built.
#
## class Char(RE):
-## """
-## Char(c) is an RE which matches the character |c|.
-## """
+## """
+## Char(c) is an RE which matches the character |c|.
+## """
-## nullable = 0
+## nullable = 0
-## def __init__(self, char):
-## self.char = char
-## self.match_nl = char == '\n'
+## def __init__(self, char):
+## self.char = char
+## self.match_nl = char == '\n'
-## def build_machine(self, m, initial_state, final_state, match_bol, nocase):
-## c = self.char
-## if match_bol and c != BOL:
-## s1 = self.build_opt(m, initial_state, BOL)
-## else:
-## s1 = initial_state
-## if c == '\n' or c == EOF:
-## s1 = self.build_opt(m, s1, EOL)
-## if len(c) == 1:
-## code = ord(self.char)
-## s1.add_transition((code, code+1), final_state)
-## if nocase and is_letter_code(code):
-## code2 = other_case_code(code)
-## s1.add_transition((code2, code2+1), final_state)
-## else:
-## s1.add_transition(c, final_state)
-
-## def calc_str(self):
-## return "Char(%s)" % repr(self.char)
+## def build_machine(self, m, initial_state, final_state, match_bol, nocase):
+## c = self.char
+## if match_bol and c != BOL:
+## s1 = self.build_opt(m, initial_state, BOL)
+## else:
+## s1 = initial_state
+## if c == '\n' or c == EOF:
+## s1 = self.build_opt(m, s1, EOL)
+## if len(c) == 1:
+## code = ord(self.char)
+## s1.add_transition((code, code+1), final_state)
+## if nocase and is_letter_code(code):
+## code2 = other_case_code(code)
+## s1.add_transition((code2, code2+1), final_state)
+## else:
+## s1.add_transition(c, final_state)
+
+## def calc_str(self):
+## return "Char(%s)" % repr(self.char)
def Char(c):
"""
@@ -229,7 +229,7 @@ class RawCodeRange(RE):
"""
nullable = 0
match_nl = 0
- range = None # (code, code)
+ range = None # (code, code)
uppercase_range = None # (code, code) or None
lowercase_range = None # (code, code) or None
@@ -420,10 +420,10 @@ def calc_str(self):
return "%s(%s)" % (name, self.re)
#
-# Composite RE constructors
-# -------------------------
+# Composite RE constructors
+# -------------------------
#
-# These REs are defined in terms of the primitive REs.
+# These REs are defined in terms of the primitive REs.
#
Empty = Seq()
@@ -531,7 +531,7 @@ def Case(re):
return SwitchCase(re, nocase = 0)
#
-# RE Constants
+# RE Constants
#
Bol = Char(BOL)
View
108 Cython/Plex/Scanners.py
@@ -130,10 +130,10 @@ def scan_a_token(self):
self.start_pos = self.cur_pos
self.start_line = self.cur_line
self.start_col = self.cur_pos - self.cur_line_start
-# if self.trace:
-# action = self.run_machine()
-# else:
-# action = self.run_machine_inlined()
+# if self.trace:
+# action = self.run_machine()
+# else:
+# action = self.run_machine_inlined()
action = self.run_machine_inlined()
if action:
if self.trace:
@@ -257,48 +257,48 @@ def run_machine_inlined(self):
self.cur_line_start = cur_line_start
self.cur_char = cur_char
self.input_state = input_state
- self.next_pos = next_pos
+ self.next_pos = next_pos
if trace: #TRACE#
if action: #TRACE#
print("Doing " + action) #TRACE#
return action
-# def transition(self):
-# self.save_for_backup()
-# c = self.cur_char
-# new_state = self.state.new_state(c)
-# if new_state:
-# if self.trace:
-# print "Scanner: read: State %d: %s --> State %d" % (
-# self.state.number, repr(c), new_state.number)
-# self.state = new_state
-# self.next_char()
-# return 1
-# else:
-# if self.trace:
-# print "Scanner: read: State %d: %s --> blocked" % (
-# self.state.number, repr(c))
-# return 0
+# def transition(self):
+# self.save_for_backup()
+# c = self.cur_char
+# new_state = self.state.new_state(c)
+# if new_state:
+# if self.trace:
+# print "Scanner: read: State %d: %s --> State %d" % (
+# self.state.number, repr(c), new_state.number)
+# self.state = new_state
+# self.next_char()
+# return 1
+# else:
+# if self.trace:
+# print "Scanner: read: State %d: %s --> blocked" % (
+# self.state.number, repr(c))
+# return 0
-# def save_for_backup(self):
-# action = self.state.get_action()
-# if action:
-# if self.trace:
-# print "Scanner: read: Saving backup point at", self.cur_pos
-# self.backup_state = (
-# action, self.cur_pos, self.cur_line, self.cur_line_start,
-# self.cur_char, self.input_state, self.next_pos)
+# def save_for_backup(self):
+# action = self.state.get_action()
+# if action:
+# if self.trace:
+# print "Scanner: read: Saving backup point at", self.cur_pos
+# self.backup_state = (
+# action, self.cur_pos, self.cur_line, self.cur_line_start,
+# self.cur_char, self.input_state, self.next_pos)
-# def back_up(self):
-# backup_state = self.backup_state
-# if backup_state:
-# (action, self.cur_pos, self.cur_line, self.cur_line_start,
-# self.cur_char, self.input_state, self.next_pos) = backup_state
-# if self.trace:
-# print "Scanner: read: Backing up to", self.cur_pos
-# return action
-# else:
-# return None
+# def back_up(self):
+# backup_state = self.backup_state
+# if backup_state:
+# (action, self.cur_pos, self.cur_line, self.cur_line_start,
+# self.cur_char, self.input_state, self.next_pos) = backup_state
+# if self.trace:
+# print "Scanner: read: Backing up to", self.cur_pos
+# return action
+# else:
+# return None
def next_char(self):
input_state = self.input_state
@@ -331,24 +331,24 @@ def next_char(self):
if self.trace:
print("--> [%d] %d %s" % (input_state, self.cur_pos, repr(self.cur_char)))
-# def read_char(self):
-# """
+# def read_char(self):
+# """
# Get the next input character, filling the buffer if necessary.
# Returns '' at end of file.
# """
-# next_pos = self.next_pos
-# buf_index = next_pos - self.buf_start_pos
-# if buf_index == len(self.buffer):
-# discard = self.start_pos - self.buf_start_pos
-# data = self.stream.read(0x1000)
-# self.buffer = self.buffer[discard:] + data
-# self.buf_start_pos = self.buf_start_pos + discard
-# buf_index = buf_index - discard
-# if not data:
-# return ''
-# c = self.buffer[buf_index]
-# self.next_pos = next_pos + 1
-# return c
+# next_pos = self.next_pos
+# buf_index = next_pos - self.buf_start_pos
+# if buf_index == len(self.buffer):
+# discard = self.start_pos - self.buf_start_pos
+# data = self.stream.read(0x1000)
+# self.buffer = self.buffer[discard:] + data
+# self.buf_start_pos = self.buf_start_pos + discard
+# buf_index = buf_index - discard
+# if not data:
+# return ''
+# c = self.buffer[buf_index]
+# self.next_pos = next_pos + 1
+# return c
def position(self):
"""
View
4 Cython/Plex/Transitions.py
@@ -239,8 +239,8 @@ def dump_set(self, set):
#
#def merge_state_sets(set1, set2):
-# for state in set2.keys():
-# set1[state] = 1
+# for state in set2.keys():
+# set1[state] = 1
def state_set_str(set):
state_list = set.keys()
View
2  pyximport/Setup.py
@@ -30,6 +30,6 @@
# ("examples/dependencies",
# ["README", "test.pyx", "test.pyxdep", "header.h",
# "header2.h", "header3.h", "header4.h"])
-# ],
+# ],
py_modules = ["pyximport", "pyxbuild"])
View
4 pyximport/test/test_pyximport.py
@@ -38,7 +38,7 @@ def test():
build_file.write("""
from distutils.extension import Extension
def make_ext(name, filename):
- return Extension(name=name, sources=[filename])
+ return Extension(name=name, sources=[filename])
""")
build_file.close()
@@ -60,5 +60,5 @@ def make_ext(name, filename):
remove_tempdir(tempdir)
if __name__=="__main__":
- test()
+ test()
View
38 pyximport/test/test_reload.py
@@ -4,30 +4,30 @@
# debugging the 2.2 problem
if 1:
- from distutils import sysconfig
- try:
- sysconfig.set_python_build()
- except AttributeError:
- pass
- import pyxbuild
- print pyxbuild.distutils.sysconfig == sysconfig
+ from distutils import sysconfig
+ try:
+ sysconfig.set_python_build()
+ except AttributeError:
+ pass
+ import pyxbuild
+ print pyxbuild.distutils.sysconfig == sysconfig
def test():
- tempdir = test_pyximport.make_tempdir()
- sys.path.append(tempdir)
- hello_file = os.path.join(tempdir, "hello.pyx")
- open(hello_file, "w").write("x = 1; print x; before = 'before'\n")
- import hello
+ tempdir = test_pyximport.make_tempdir()
+ sys.path.append(tempdir)
+ hello_file = os.path.join(tempdir, "hello.pyx")
+ open(hello_file, "w").write("x = 1; print x; before = 'before'\n")
+ import hello
assert hello.x == 1
- time.sleep(1) # sleep to make sure that new "hello.pyx" has later
- # timestamp than object file.
+ time.sleep(1) # sleep to make sure that new "hello.pyx" has later
+ # timestamp than object file.
- open(hello_file, "w").write("x = 2; print x; after = 'after'\n")
- reload(hello)
- assert hello.x == 2, "Reload should work on Python 2.3 but not 2.2"
- test_pyximport.remove_tempdir(tempdir)
+ open(hello_file, "w").write("x = 2; print x; after = 'after'\n")
+ reload(hello)
+ assert hello.x == 2, "Reload should work on Python 2.3 but not 2.2"
+ test_pyximport.remove_tempdir(tempdir)
if __name__=="__main__":
- test()
+ test()
Please sign in to comment.
Something went wrong with that request. Please try again.