Patches from Greg Stein to support 'P' format in struct module's
native format, as void* (translated to Python int or long).
Also adds PyLong_FromVoidPtr and PyLong_AsVoidPtr to longobject.c.
In load_inst(), when instantiating an instance the old way (i.e. when
there's an __getinitargs__() method), if a TypeError occurs, catch and
reraise it but add info to the error about the class name being
instantiated. This makes debugging a lot easier if __getinitargs__()
returns something bogus (e.g. a string instead of a singleton tuple).
Ignore the TclError exception raised when deleting the registration
for callit, used by the after() command. This can happen when the
callback deletes the window.
Barry Warsaw [Mon, 14 Sep 1998 18:51:11 +0000 (18:51 +0000)]
Several changes that Python carry on in the face of errors in the
initialization of class exceptions. Specifically:
init_class_exc(): This function now returns an integer status of the
class exception initialization. No fatal errors in this method now.
Also, use PySys_WriteStderr() when writing error messages. When an
error occurs in this function, 0 is returned, but the partial creation
of the exception classes is not undone (this happens elsewhere).
Things that could trigger the fallback:
- exceptions.py fails to be imported (due to syntax error, etc.)
- one of the exception classes is missing (e.g. due to library
version mismatch)
- exception class can't be inserted into __builtin__'s dictionary
- MemoryError instance can't be pre-allocated
- some other PyErr_Occurred
newstdexception(): Changed the error message. This is still a fatal
error because if the string based exceptions can't be created, we
really can't continue.
initerrors(): Be sure to xdecref the .exc field, which might be
non-NULL if class exceptions init was aborted.
_PyBuiltin_Init_2(): If class exception init fails, print a warning
message and reinstate the string based exceptions.
There was a confusion in my checkin of the code to support list() with
and without a message number argument: the argument was called 'msg'
but the code expected it to be called 'which'. In line with the other
methods, I've renamed the argument to 'which', and adapted the doc
string not to refer to 'msg'.
Patch by Marc-Andre Lemburg: use re module to compare test results.
This makes it possible to accept that on Linux %w returns "01" instead
of "1", for example.
pdb.py Uses the Breakpoint class so one can enable/disable breakpoints,
set temporary ones, set ignore counts, and conditions. The last
can be set using the 'b' command
b 243 , i>4 ( b 243,i>4 if you are space adverse)
or with the condition command so conditions can be changed
for a particular breakpoint.
Breakpoints are numbered from 1 on, and if a breakpoint is deleted,
the number is not reused. All the breakpoint handling commands
refer to breakpoints by number. To be consistent, the clear command
does so as well, which is the one change from the original pdb that
is not transparent. Thus only the breakpoint command 'b' uses a
line number or file:line or method. You can also give
b whrandom.random and the method will be searched for along
sys.path. This is implemented with an 'egrep' command and so
is not as portable as it might be. [ see lineinfo() and
lineinfoCmd ]
Breakpoints cannot be set at a line that is blank or a '#' comment
or starts a triply quoted comment. This is because I would like
this behavior in my DDD interface and think it reasonable for
pdb as well. It can be removed readily, however as it is all
incorporated in the routine checkline(). If one attempts to
set a breakpoint at a 'def' line, the breakpoint is automatically
moved to the first executable line after the 'def'. This too is
in checkline().
do_EOF() returns zero so typing an end-of-file character as a command
does nothing. 'quit' does the quitting.
The routine defaultFile() is present so as to preserve the current
pdb behavior and yet allow me to override it in pydb.
There's some code in lineinfo() that is probably mainly useful only
for pydb and if you prefer, much up to the comment "Best first guess"
could be removed.
Keith Davidson provided the code for handling $HOME/.pdbrc and
./.pdbrc, and it has been incorporated. He also provided the
alias handling routine. I modified it a bit so it could live
nicely in precmd(). He and I have been in contact; he has the
new pdb (and pydb) with his code incorporated. He also asked
about the possibility of allowing multiple commands on one
line, such as step;step or s;s or with an alias such as
alias ct tbreak %1 ; continue
and since it was so easy, that's in place as well. It's a simple
'split the line at the first ";"' operation and puts the second
half in the command queue (self.cmdqueue). This has the unfortunate
effect of destroying a line like print "i: "+i+"; j: "+j
but either there's a simple way to deal with this, or my attitude
will remain that pdb is a debugger, not a compiler/parser/etc.
An alias like alias 4s s;;s;
will work because the adjacent and trailing ";" act like a <cr> which
repeats the last command. Of course, either s;s;s;s or s;;; would be
a bit more sensible.
bdb.py now has a class definition called Breakpoint along with
associated methods. There's no reason why this class has to
be there; if you prefer it elsewhere, 'tis easily done.
(Minor reformatting by GvR; e.g. moved Breakpoint's doc string to
proper point.)
cmd.py has incorporated the changes we discussed a couple of weeks ago
(a command queue, returning line from precmd, and stop from postcmd)
and some changes to help that were occasioned because I wanted to
inherit from pdb which inherits from cmd.py and the help routine
didn't look for commands or the associated help deeply enough.
Fix a bug where comparison of a rational with a float failed because
the difference got converted to float.
Put brackets around the string representation of (non-integer)
rationals.
(Sjoerd Mullender.)
Should no longer surround PyOS_Readline() call with
Py_{BEGIN,END}_ALLOW_THREADS macros. Also get rid of the declaration
for it (it's now in pythonrun.h).
Jeremy Hylton [Wed, 2 Sep 1998 21:53:16 +0000 (21:53 +0000)]
Easy optimizations of urlparse for the common case of parsing an http URL.
1. use dict.get instead of try/except KeyError
2. if the url scheme is 'http' then avoid the series of
'if var in [someseq]:'. instead, inline all of the code.
3. find = string.find
Guido van Rossum [Mon, 31 Aug 1998 14:14:09 +0000 (14:14 +0000)]
Now that we have standard (optional) long long support, the long long
support in this module can go. The patch only deletes code
(PyLong_FromLongLong() and PyLong_AsLongLong()). By Sjoerd Mullender.
Guido van Rossum [Thu, 27 Aug 1998 19:43:43 +0000 (19:43 +0000)]
We now assume that PyOS_Readline() is called with the interpreter lock
held. It releases the lock around the call to the function pointed to by
PyOS_ReadlineFunctionPointer (default PyOS_StdioReadline()).
Guido van Rossum [Thu, 27 Aug 1998 19:21:53 +0000 (19:21 +0000)]
Add a 'volatile' to the declaration of threadid in get_thread_ident().
According to Vladimir Marangozov, this is necessary for AIX, where
high optimization levels inline this function and then get it wrong :-(
Guido van Rossum [Thu, 27 Aug 1998 19:02:51 +0000 (19:02 +0000)]
Changes by Richard Wolff:
1) I added a command queue which is helpful to me (at least so far) and
would also allow syntax like 's;s' (step; step) in conjunction with precmd
2) doc_leader allows the derived class to print a message before the help
output. Defaults to current practise of a blank line
3) nohelp allows one to override the 'No help on' message. I need
'Undefined command: "%s". Try "help".'
4) Pass line to self.precmd to allow one to do some parsing: change first
word to lower case, strip out a leading number, whatever.
5) Pass the result of onecmd and the input line to postcmd. This allows
one to ponder the stop result before it is effective.
6) emptyline() requires a if self.lastcmd: conditional because if the
first command is null (<cr>), you get an infinite recursion with the
code as it stands.
Guido van Rossum [Tue, 25 Aug 1998 18:44:34 +0000 (18:44 +0000)]
__file__ used to be always set to the .pyc (or .pyo) file, even if
that file in fact did not exist or at least was not used. Change this
so that __file__ is *only* set to the .pyc/.pyo file when it actually
read the code object from it; otherwise __file__ is set to the .py
file.
Guido van Rossum [Tue, 25 Aug 1998 18:22:17 +0000 (18:22 +0000)]
Comment out the print statement about underflow. (This only seems to
happen when you use a non-keyword argument after a keyword argument,
and in this case you also get a syntax error. I fully suspect that
the underflow is caused by the code that stops generating code when it
detects the syntax error, but I can't find the culprit right now. I
know, I know.)
Guido van Rossum [Tue, 25 Aug 1998 16:07:15 +0000 (16:07 +0000)]
Patch by Mark Hammond to support 64-bit ints on MS platforms.
The MS compiler doesn't call it 'long long', it uses __int64,
so a new #define, LONG_LONG, has been added and all occurrences
of 'long long' are replaced with it.
2-digit years are now converted using rules that are (according to
Fredrik Lundh) recommended by POSIX or X/Open: 0-68 mean 2000-2068,
69-99 mean 1969-1999.
2-digit years are now only accepted if time.accept2dyear is set to a
nonzero integer; if it is zero or not an integer or absent, only year
values >= 1900 are accepted. Year values 100-1899 and negative year
values are never accepted.
The initial value of time.accept2dyear depends on the environment
variable PYTHONY2K: if PYTHONY2K is set and non-empty,
time.accept2dyear is initialized to 0; if PYTHONY2K is empty or not
set, time.accept2dyear is initialized to 0.
Guido van Rossum [Tue, 25 Aug 1998 14:06:55 +0000 (14:06 +0000)]
New version, with contributions from Sjoerd Mullender and Mark Hammond.
Sjoerd writes:
This version of freeze creates one file per Python module, instead of
one humongous file for all Python modules.
bkfile: new module to used to write files with backups. No new file
is produced if the new contents is identical to the old.
New option "-x excluded-module" for modulefinder test program.
New option "-i filename" for freeze main program to include a list of
options in place of the -i option.
Guido van Rossum [Tue, 25 Aug 1998 12:29:08 +0000 (12:29 +0000)]
There was still something wrong. The original NOTTESTS are replaced
by the new '-x' arguments, losing the previous items. Thus,
test_support, test_b1 & test_b2 are executed (and warnings issued).
(Discovered by Vladimir Marangozov.)
Guido van Rossum [Mon, 24 Aug 1998 14:15:44 +0000 (14:15 +0000)]
Ted Horst writes in psa-members@python.org:
This is a patch that Bill Bummgarner did for 1.4 that hasn't made its
way into the distribution yet. This is important if you want to use
the ObjC module.
The .subn() method wasn't setting _num_regs, which is used by the .groups()
method, so .groups() didn't work inside the replacement function
called by re.sub. One-line fix: set self._num_regs inside subn().
Barry Warsaw [Thu, 20 Aug 1998 21:51:27 +0000 (21:51 +0000)]
(py-shell-map): New variable contains the keymap used in *Python*
shell buffers.
(py-shell): Moved the require of comint to the top level. Also
use-local-map py-shell-map instead of hacking on the comint-mode-map.
This eliminates breakage of other comint-mode buffers (e.g. shell).