Commit Graph

168 Commits

Author SHA1 Message Date
Guido van Rossum c600411755 * mpzmodule.c: removed redundant mpz_print function.
* object.[ch], bltinmodule.c, fileobject.c: changed str() to call
  strobject() which calls an object's __str__ method if it has one.
  strobject() is also called by writeobject() when PRINT_RAW is passed.
* ceval.c: rationalize code for PRINT_ITEM (no change in function!)
* funcobject.c, codeobject.c: added compare and hash functionality.
  Functions with identical code objects and the same global dictionary are
  equal.  Code objects are equal when their code, constants list and names
  list are identical (i.e. the filename and code name don't count).
  (hash doesn't work yet since the constants are in a list and lists can't
  be hashed -- suppose this should really be done with a tuple now we have
  resizetuple!)
1993-11-05 10:22:19 +00:00
Guido van Rossum 2e8f8a398e Added compare operations for functions and code objects.
(Also hash, but it doesn't work yet.)
1993-11-05 10:20:10 +00:00
Guido van Rossum 4199facacd Added getmappingsize(). (Needed by previous checkin of posixmodule.c) 1993-11-05 10:18:44 +00:00
Guido van Rossum b73cc04e62 * ceval.c, longobject.c, methodobject.c, listnode.c, arraymodule.c,
pythonrun.c: added static forward declarations
* pythonrun.h, ceval.h, longobject.h, node.h: removed declarations of
  static routines
1993-11-01 16:28:59 +00:00
Guido van Rossum 82d410e733 * fileobject.c (softspace): fix bug if called with NULL file. 1993-11-01 16:26:16 +00:00
Guido van Rossum 2586bf0a34 * rangeobject.{c,h}, bltinmodule.c: removed non-essential ops from range
object.
1993-11-01 16:21:44 +00:00
Sjoerd Mullender 615194a352 Fixed bugs in resizetuple and extended the interface.
Added ifdefs in stringobject.c for shared strings of length 1.
Renamed free_list in tupleobject.c to free_tuples.
1993-11-01 13:46:50 +00:00
Guido van Rossum dc4b93db70 * listobject.c (list_ass_slice): XDECREF instead of DECREF so
setlistslice() can be used to cut the unused part out of a freshly made
  slice (as done by bagof()).  [needed by the next mod!]
* structural changes to bagof(), map() etc.
1993-10-27 14:56:44 +00:00
Guido van Rossum 12d12c5faf * compile.[ch]: support for lambda()
* PROTO.h, mymalloc.h: added #ifdefs for TURBOC and GNUC.
* allobjects.h: added #include "rangeobject.h"
* Grammar: added lambda_input; relaxed syntax for exec.
* bltinmodule.c: added bagof, map, reduce, lambda, xrange.
* tupleobject.[ch]: added resizetuple().
* rangeobject.[ch]: new object type to speed up range operations (not
  convinced this is needed!!!)
1993-10-26 17:58:25 +00:00
Guido van Rossum 444fc7c90c Add some necessary casts; use double quotes to represent strings in
some cases.
1993-10-26 15:25:16 +00:00
Guido van Rossum 72481a3497 Changes to make range checks portable to 64-bit machines. 1993-10-26 15:21:51 +00:00
Guido van Rossum 5a2a683e72 * filemodule.c: added writelines() -- analogous to readlines()
* import.c: fixed core dump when out-of-date .pyc file encountered (again!)
1993-10-25 09:59:04 +00:00
Sjoerd Mullender 52c1f51554 import.c: When something is wrong with the .pyc, properly open the .py
file.
object.c: Write allocation statistics to stderr.
1993-10-25 08:40:52 +00:00
Sjoerd Mullender 3bb8a05947 Several optimizations and speed improvements.
cstubs: Use Matrix type instead of float[4][4].
1993-10-22 12:04:32 +00:00
Guido van Rossum db3165e655 * bltinmodule.c: removed exec() built-in function.
* Grammar: add exec statement; allow testlist in expr statement.
* ceval.c, compile.c, opcode.h: support exec statement;
  avoid optimizing locals when it is used
* fileobject.{c,h}: add getfilename() internal function.
1993-10-18 17:06:59 +00:00
Sjoerd Mullender 842d2ccdcd intobject.c: Save references to small integers, so that they can be
shared.  The default is to save references to the integers in
	the range -1..99.  The lower limit can be set by defining
	NSMALLNEGINTS (absolute value of smallest integer to be saved)
	and NSMALLPOSINTS (1 more than the largest integer to be
	saved).
tupleobject.c: Save a reference to the empty tuple to be returned
	whenever a tuple of size 0 is requested.  Tuples of size 1
	upto, but not including, MAXSAVESIZE (default 20) are put in
	free lists when deallocated.  When MAXSAVESIZE equals 1, only
	share references to the empty tuple, when MAXSAVESIZE equals
	0, don't include the code at all and revert to the old
	behavior.
object.c: Print some more statistics when COUNT_ALLOCS is defined.
1993-10-15 16:18:48 +00:00
Guido van Rossum 21d335ed9e Makefile, import.c: Lance's alternative module search (allow .pyc file
without .py file); Bill's dynamic loading for SunOS using shared
libraries.

pwdmodule.c (mkgrent): remove DECREF of uninitialized variable.

classobject.c (instance_getattr): Fix case when class lookup returns
unbound method instead of function.
1993-10-15 13:01:11 +00:00
Sjoerd Mullender a9c3c22c33 * Extended X interface: pixmap objects, colormap objects visual objects,
image objects, and lots of new methods.
* Added counting of allocations and deallocations of builtin types if
  COUNT_ALLOCS is defined.  Had to move calls to NEWREF down in some
  files.
* Bug fix in sorting lists.
1993-10-11 12:54:31 +00:00
Sjoerd Mullender f64992e95d * clmodule.c (doParams): free PVbuffer in error condition.
* frameobject.c (newframeobject): initialize ob_type if taking entry
  from the free list, since it is zeroed out when DEBUG is defined.
1993-08-03 15:11:36 +00:00
Guido van Rossum 1fc238a813 Minor fixes / changes for Mac compatibility. 1993-07-29 08:25:09 +00:00
Guido van Rossum ed18fdc9fc * accessobject.c (ownercheck): allow a base class access to protected
objects of its derived classes; allow anything that has an attribute
  named "__privileged__" access to anything.
* object.[ch]: added hasattr() -- test whether getattr() will succeed.
1993-07-11 19:55:34 +00:00
Guido van Rossum f1dc566328 * Makefile: added all: and default: targets.
* many files: made some functions static; removed "extern int errno;".
* frozenmain.c: fixed bugs introduced on 24 June...
* flmodule.c: remove 1.5 bw compat hacks, add new functions in 2.2a
  (and some old functions that were omitted).
* timemodule.c: added MSDOS floatsleep version .
* pgenmain.c: changed exit() to goaway() and added defn of goaway().
* intrcheck.c: add hack (to UNIX only) so interrupting 3 times
  will exit from a hanging program.  The second interrupt prints
  a message explaining this to the user.
1993-07-05 10:31:29 +00:00
Guido van Rossum 234f942aef * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Added $(SYSDEF) to its build rule in Makefile.
* cgensupport.[ch], modsupport.[ch]: removed some old stuff.  Also
  changed files that still used it...  And made several things static
  that weren't but should have been...  And other minor cleanups...
* listobject.[ch]: add external interfaces {set,get}listslice
* socketmodule.c: fix bugs in new send() argument parsing.
* sunaudiodevmodule.c: added flush() and close().
1993-06-17 12:35:49 +00:00
Guido van Rossum eb6b33a837 * classobject.c: in instance_getattr, don't make a method out of a
function found as instance data.
* socketmodule.c: added 'flags' argument sendto/recvfrom, rewrite
  argument parsing in send/recv.
* More changes related to access (terminology change: owner instead of
  class; allow any object as owner; local/global variables are owned
  by their dictionary, only class/instance data is owned by the class;
  "from...import *" now only imports objects with public access; etc.)
1993-05-25 09:38:27 +00:00
Guido van Rossum b3f7258f14 * Lots of small changes related to access.
* Added "access *: ...", made access work for class methods.
* Introduced subclass check: make sure that when calling
  ClassName.methodname(instance, ...), the instance is an instance of
  ClassName or of a subclass thereof (this might break some old code!)
1993-05-21 19:56:10 +00:00
Guido van Rossum 81daa32c15 Access checks now work, at least for instance data (not for methods
yet).  The class is now passed to eval_code and stored in the current
frame.  It is also stored in instance method objects.  An "unbound"
instance method is now returned when a function is retrieved through
"classname.funcname", which when called passes the class to eval_code.
1993-05-20 14:24:46 +00:00
Guido van Rossum 25831652fd Several changes in one:
(1) dictionaries/mappings now have attributes values() and items() as
well as keys(); at the C level, use the new function mappinggetnext()
to iterate over a dictionary.

(2) "class C(): ..." is now illegal; you must write "class C: ...".

(3) Class objects now know their own name (finally!); and minor
improvements to the way how classes, functions and methods are
represented as strings.

(4) Added an "access" statement and semantics.  (This is still
experimental -- as long as you don't use the keyword 'access' nothing
should be changed.)
1993-05-19 14:50:45 +00:00
Guido van Rossum 6ac258d381 * pythonrun.c: Print exception type+arg *after* stack trace instead of
before it.
* ceval.c, object.c: moved testbool() to object.c (now extern visible)
* stringobject.c: fix bugs in and rationalize string resize in formatstring()
* tokenizer.[ch]: fix non-working code for lines longer than BUFSIZ
1993-05-12 08:24:20 +00:00
Guido van Rossum 8a0c3456c2 Fix bug in class instance hash (forgot to clear error condition). 1993-04-08 12:56:19 +00:00
Guido van Rossum 9575a44575 * Microscopic corrections to make things compile on the Cray APP.
* Removed one use of $> in Makefile and warned about others.
  Added configurable lines in Makefile to change CC and AR.
1993-04-07 14:06:14 +00:00
Guido van Rossum 5b7221849e * Fixed some subtleties with fastlocals. You can no longer access
f_fastlocals in a traceback object (this is a core dump hazard
  if there are <nil> entries), but instead eval_code() merges the fast
  locals back into the locals dictionary if it looks like the local
  variables will be retained.  Also, the merge routines save
  exceptions since this is sometimes needed (alas!).

* Added id() to bltinmodule.c, which returns an object's address
  (identity).  Useful to walk arbitrary data structures containing
  cycles.

* Added compile() to bltinmodule.c and compile_string() to
  pythonrun.[ch]: support to exec/eval arbitrary code objects.  The
  code that defaults globals and locals is moved from run_node in
  pythonrun.c (which is now identical to eval_node) to eval_code in
  ceval.c.  [XXX For elegance a clean-up session is necessary.]
1993-03-30 17:46:03 +00:00
Guido van Rossum 8b17d6bd89 Changes to speed up local variables enormously, by avoiding dictionary
lookup (opcode.h, ceval.[ch], compile.c, frameobject.[ch],
pythonrun.c, import.c).  The .pyc MAGIC number is changed again.
Added get_menu_text to flmodule.
1993-03-30 13:18:41 +00:00
Guido van Rossum 9bfef44d97 * Changed all copyright messages to include 1993.
* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object.  Print it for code and function
  objects.  THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
  number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
  string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
  and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
  added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
1993-03-29 10:43:31 +00:00
Guido van Rossum 4b1302bd1d Generalized version of dictionaries, with compatibility hacks. 1993-03-27 18:11:32 +00:00
Guido van Rossum e537240c25 * Changed many files to use mkvalue() instead of newtupleobject().
* Fixcprt.py: added [-y file] option, do only files younger than file.
* modsupport.[ch]: added vmkvalue().
* intobject.c: use mkvalue().
* stringobject.c: added "formatstring"; renamed string* to string_*;
  ceval.c: call formatstring for string % value.
* longobject.c: close memory leak in divmod.
* parsetok.c: set result node to NULL when returning an error.
1993-03-16 12:15:04 +00:00
Guido van Rossum 9e51f9bec8 bltinmodule.c: added round(x, [n]); coerce() of two class instances
will try to coerce anyway.
classobject.c: instance 'nonzero' should first try __nonzero__
only then __len__.
1993-02-12 16:29:05 +00:00
Guido van Rossum bf80e5407f * stdwinmodule.c: various new commands: setwin{pos,size},
listfontnames, bitmap ops.
* listobject.c: use mkvalue() when possible; avoid weird error when
  calling append() without args.
* modsupport.c: new feature in getargs(): if the format string
  contains a semicolor the string after that is used as the error
  message instead of "bad argument list (format %s)" when there's an
  error.
1993-02-08 15:49:17 +00:00
Guido van Rossum 34679b7661 * Added Fixcprt.py: script to fix copyright message.
* various modules: added 1993 to copyright.
* thread.c: added copyright notice.
* ceval.c: minor change to error message for "+"
* stdwinmodule.c: check for error from wfetchcolor
* config.c: MS-DOS fixes (define PYTHONPATH, use DELIM, use osdefs.h)
* Add declaration of inittab to import.h
* sysmodule.c: added sys.builtin_module_names
* xxmodule.c, xxobject.c: fix minor errors
1993-01-26 13:33:44 +00:00
Guido van Rossum 0b0db8e3a0 Added separate main program for the Mac: macmain.c
stdwinmodule.c: wsetfont can now return an error
Makefile: add CL_USE and CL_LIB*S; config.c: move CL part around
New things in imgfile; also in Makefile.
longobject.c: fix comparison of negative long ints...  [REAL BUG!]
marshal.c: add dumps() and loads() to read/write strings
timemodule.c: make sure there's always a floatsleep()
posixmodule.c: rationalize struct returned by times()
Makefile: add test target, disable imgfile by default
thread.c: Improved coexistance with dl module (sjoerd)
stdwinmodule.c: Change include stdwin.h if macintosh
rotormodule.c: added missing last argument to RTR_?_region calls
confic.c: merged with configmac.c, added 1993 to copyright message
fileobject.c: int compared to NULL in writestring(); change fopenRF ifdef
timemodule.c: simplify times() using mkvalue; include myselect.h
  earlier (for sequent).
posixmodule: for sequent, include unistd.h instead of explicit
  extern definitions and don't define rename()
Makefile: change misleading/wrong MD5 comments
1993-01-21 16:07:51 +00:00
Guido van Rossum e35399ea7b Checking in last-minute changes that are already part of release 0.9.8 1993-01-10 18:33:56 +00:00
Guido van Rossum a2b7f40513 * Configure.py: use #!/usr/local/bin/python
* posixmodule.c: move extern function declarations to top
* listobject.c: cmp() arguments must be void* if __STDC__
* Makefile, allobjects.h, panelmodule.c, modsupport.c: get rid of
  strdup() -- it is a portability risk
* Makefile: enclosed ranlib command in parentheses for Sequent Make
  which aborts if the command is not found even if '-' is present
* timemodule.c: time() returns a floating point number, in microsecond
  precision if BSD_TIME is defined.
1993-01-04 09:09:59 +00:00
Guido van Rossum de788b8261 fileobject.c: fix nasty bug; Makefile; turn on STROP and change lint flags. 1992-12-22 14:24:04 +00:00
Guido van Rossum d014ea6b5e * classobject.c: in instance_lenth, test result of call_object
for exception before using it.  Fixed a few other places where the
  outcome of calling sq_length wasn't tested for exceptions
  (bltinmodule.c, ceval.c).
1992-11-26 10:30:26 +00:00
Guido van Rossum a9e7dc1081 * bltinmodule.c: added built-in function cmp(a, b)
* flmodule.c: added {do,check}_only_forms to fl's list of functions;
  and don't print a message when an unknown object is returned.

* pythonrun.c: catch SIGHUP and SIGTERM to do essential cleanup.

* Made jpegmodule.c smaller by using getargs() and mkvalue() consistently.

* Increased parser stack size to 500 in parser.h.

* Implemented custom allocation of stack frames to frameobject.c and
  added dynamic stack overflow checks (value stack only) to ceval.c.
  (There seems to be a bug left: sometimes stack traces don't make sense.)
1992-10-18 18:53:57 +00:00
Guido van Rossum 3165fe6a56 Modified most (but not yet all) I/O to always go through sys.stdout or
sys.stderr or sys.stdin, and to work with any object as long as it has
a write() (respectively readline()) methods.  Some functions that took
a FILE* argument now take an object* argument.
1992-09-25 21:59:05 +00:00
Guido van Rossum 7066dd75c5 * Makefile: added IMGFILE; moved some stuff around.
* flmodule.c: added some missing functions; changed readonly flags of
  some data members based upon FORMS documentation.
* listobject.c: fixed int/long arg lint bug (bites PC compilers).
* several: removed redundant print methods (repr is good enough).
* posixmodule.c: added (still experimental) process group functions.
1992-09-17 17:54:56 +00:00
Guido van Rossum 1899c2e055 Made builtins int(), long(), float(), oct() and hex() more generic. 1992-09-12 11:09:23 +00:00
Guido van Rossum 94472a0374 classobject.c moduleobject.c stdwinmodule.c xxobject.c:
raise AttributeError, not KeyError, when attribute deletion fails.
sunaudiodevmodule.c: check for deletion before calling setmember.
1992-09-04 09:45:18 +00:00
Guido van Rossum ba3690cd09 Remove outdated warning in comments. 1992-09-03 20:44:36 +00:00
Guido van Rossum 67daef567f Remove bogus type-and-refcnt setting from newsizedstringobject(). 1992-09-03 20:44:02 +00:00