| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
SF bug 433228: repr(list) woes when len(list) big
call_object: If the object isn't callable, display its type in the error
msg rather than its repr.
|
|
|
|
|
|
|
|
| |
SF bug 430991: wrong co_lnotab
Armin Rigo pointed out that the way the line-# table got built didn't work
for lines generating more than 255 bytes of bytecode. Fixed as he
suggested, plus corresponding changes to pyassem.py, plus added some long
overdue docs about this subtle table to compile.c.
|
|
|
|
|
|
| |
vgetargs1() and vgetargskeywords(): Replace uses of PyTuple_Size() and
PyTuple_GetItem() with PyTuple_GET_SIZE() and PyTuple_GET_ITEM().
The code has already done a PyTuple_Check().
|
|
|
|
|
|
|
|
| |
Add a second special case to the inline function call code in eval_code2().
If we have a PyCFunction (builtin) and it is METH_VARARGS only, load
the args and dispatch to call_cfunction() directly. This provides a
small speedup for perhaps the most common function calls -- builtins.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SF bug #417093: Case sensitive import: dir and .py file w/ same name
Directory containing
Spam.py
spam/__init__.py
Then "import Spam" caused a SystemError, because code checking for
the existence of "Spam/__init__.py" finds it on a case-insensitive
filesystem, but then bails because the directory it finds it in
doesn't match case, and then old code assumed that was still an error
even though it isn't anymore. Changed the code to just continue
looking in this case (instead of calling it an error). So
import Spam
and
import spam
both work now.
|
|
|
|
|
|
|
|
|
| |
Fix buglet reported on c.l.py: map(fnc, file.xreadlines()) blows up.
Took away map()'s insistence that sequences support __len__, and cleaned
up the convoluted code that made it *look* like it really cared about
__len__ (in fact the old ->len field was only *used* as a flag bit, as
the main loop only looked at its sign bit, setting the field to -1 when
IndexError got raised; renamed the field to ->saw_IndexError instead).
|
|
|
|
|
|
|
|
|
|
| |
Fix 2.1 nested scopes crash reported by Evan Simpson
The new test case demonstrates the bug. Be more careful in
symtable_resolve_free() to add a var to cells or frees only if it
won't be added under some other rule.
XXX Add new assertion that will catch this bug.
|
|
|
|
| |
'release21-maint'.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
now raises NameError instead of UnboundLocalError, because the var in
question is definitely not local. (This affects test_scope.py)
Also update the recent fix by Ping using get_func_name(). Replace
tests of get_func_name() return value with call to get_func_desc() to
match all the other uses.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Calling an unbound method on a C extension class without providing
an instance can yield a segfault. Try "Exception.__init__()" or
"ValueError.__init__()".
This is a simple fix. The error-reporting bits in call_method
mistakenly treat the misleadingly-named variable "func" as a
function, when in fact it is a method.
If we let get_func_name take care of the work, all is fine.
|
|
|
|
| |
CNRI copyright should be updated to include 2001.
|
| |
|
|
|
|
|
|
|
|
| |
Fix based on patch #414750 by Michael Hudson.
New functions get_func_name() and get_func_desc() return reasonable
names and descriptions for all objects. XXX Even objects that aren't
actually callable.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
pickle.py
The code implicitly assumed that all ints fit in 4 bytes, causing all
sorts of mischief (from nonsense results to corrupted pickles).
Repaired that.
marshal.c
The int marshaling code assumed that right shifts of signed longs
sign-extend. Repaired that.
|
| |
|
|
|
|
|
|
|
|
|
| |
Jeffery Collins pointed out that filterstring decrefs a character object
before it's done using it. This works by accident today because another
module always happens to have an active reference too at the time. The
accident doesn't work after his Pippy modifications, and since it *is*
an accident even in the mainline Python, it should work by design there too.
The patch accomplishes that.
|
|
|
|
|
| |
using nested scopes to compile its argument. Pass compiler flags
through to underlying compile call.
|
|
|
|
|
|
|
|
| |
but apparently he had to go to school, so I am checking it in for him.
This makes PyRun_HandleSystemExit() a static instead, called
handle_system_exit(), and let it use the current exception rather than
passing in an exception. This slightly simplifies the code.
|
| |
|
|
|
|
| |
sys.exitfunc gets the last word on the exit status of the program.
|
| |
|
|
|
|
|
| |
inside a piece of code that was deemed reduntant; the DECREF was
unfortunately *not* redundant!)
|
|
|
|
|
|
|
|
| |
Update docstring and library reference section on 'sys' module.
New API PyErr_Display, just for displaying errors, called by excepthook.
Uncaught exceptions now call sys.excepthook; if that fails, we fall back
to calling PyErr_Display directly.
Also comes with sys.__excepthook__ and sys.__displayhook__.
|
|
|
|
| |
import *. Mark the offending stmt rather than the function def line.
|
|
|
|
| |
functions and import */exec.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If a module has a future statement enabling nested scopes, they are
also enable for the exec statement and the functions compile() and
execfile() if they occur in the module.
If Python is run with the -i option, which enters interactive mode
after executing a script, and the script it runs enables nested
scopes, they are also enabled in interactive mode.
XXX The use of -i with -c "from __future__ import nested_scopes" is
not supported. What's the point?
To support these changes, many function variants have been added to
pythonrun.c. All the variants names end with Flags and they take an
extra PyCompilerFlags * argument. It is possible that this complexity
will be eliminated in a future version of the interpreter in which
nested scopes are not optional.
|
|
|
|
|
| |
Add PyEval_GetNestedScopes() which returns a non-zero value if the
code for the current interpreter frame has CO_NESTED defined.
|
|
|
|
|
| |
unbound method is of the right type. Hopefully this solves SF patch
#409355 (Meta-class inheritance problem); I have no easy way to test.
|
| |
|
|
|
|
|
| |
APIs, PyObject_IsInstance() and PyObject_IsSubclass() -- both
returning an int, or -1 for errors.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
frees. Note there doesn't seem to be any way to test LocalsToFast(),
because the instructions that trigger it are illegal in nested scopes
with free variables.
Fix allocation strategy for cells that are also formal parameters.
Instead of emitting LOAD_FAST / STORE_DEREF pairs for each parameter,
have the argument handling code in eval_code2() do the right thing.
A side-effect of this change is that cell variables that are also
arguments are listed at the front of co_cellvars in the order they
appear in the argument list.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
has a binding for the name. The fix is in two places:
- in symtable_update_free_vars, ignore a global stmt in a class scope
- in symtable_load_symbols, add extra handling for names that are
defined at class scope and free in a method
Closes SF bug 407800
|
|
|
|
|
|
| |
SF bugs 409230 and 407800
Also remove bogus list comp code from symtable_assign().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
with free variables. Thanks to Martin v. Loewis for finding two of
the problems. This fixes SF buf 405583.
There is also a C API change: PyFrame_New() is reverting to its
pre-2.1 signature. The change introduced by nested scopes was a
mistake. XXX Is this okay between beta releases?
cell_clear(), the GC helper, must decref its reference to break
cycles.
frame_dealloc() must dealloc all cell vars and free vars in addition
to locals.
eval_code2() setup code must INCREF cells it copies out of the
closure.
The STORE_DEREF opcode implementation must DECREF the object it passes
to PyCell_Set().
|
|
|
|
|
|
|
| |
a Py_complex C value.
Patch by Walter Dörwald.
This partially closes SF patch #407148.
|
|
|
|
|
|
| |
commas in the concrete syntax; checking those causes a segfault.
This fixes SF bug #407394.
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
Made sure that the warnings issued by symtable_check_unoptimized()
(about import * and exec) contain the proper filename and line number,
and are transformed into SyntaxError exceptions with -Werror.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(Also remove warning about module-level global decl, because we can't
distinguish from code passed to exec.)
Define PyCompilerFlags type contains a single element,
cf_nested_scopes, that is true if a nested scopes future statement has
been entered at the interactive prompt.
New API functions:
PyNode_CompileFlags()
PyRun_InteractiveOneFlags()
-- same as their non Flags counterparts except that the take an
optional PyCompilerFlags pointer
compile.c: In jcompile() use PyCompilerFlags argument. If
cf_nested_scopes is true, compile code with nested scopes. If it
is false, but the code has a valid future nested scopes statement,
set it to true.
pythonrun.c: Create a new PyCompilerFlags object in
PyRun_InteractiveLoop() and thread it through to
PyRun_InteractiveOneFlags().
|
|
|
|
|
| |
of these "search the directory" schemes (including this one) are still prone
to making mistakes.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
the more recent versions of that platform, so we use the value (time_t)(-1)
as the error value. This is the type used in the OpenVMS documentation:
http://www.openvms.compaq.com/commercial/c/5763p048.htm#inde
This closes SF tracker bug #404240.
Also clean up an exception message when detecting overflow of time_t values
beyond 4 bytes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
from __future__ import nested_scopes
x=7
def f():
x=1
def g():
global x
def i():
def h():
return x
return h()
return i()
return g()
print f()
print x
This kind of code didn't work correctly because x was treated as free
in i, leading to an attempt to load x in g to make a closure for i.
Solution is to make global decl apply to nested scopes unless their is
an assignment. Thus, x in h is global.
|