1. 13 Mar, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Variety of small INC/DECREF patches that fix reported memory leaks · 30c9f399
      Jeremy Hylton yazdı
      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().
      30c9f399
  2. 16 Şub, 2001 1 kayıt (commit)
  3. 09 Şub, 2001 1 kayıt (commit)
  4. 05 Şub, 2001 1 kayıt (commit)
  5. 01 Şub, 2001 2 kayıt (commit)
  6. 31 Ock, 2001 1 kayıt (commit)
  7. 29 Ock, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Remove f_closure slot of frameobject and use f_localsplus instead. · 2b724da8
      Jeremy Hylton yazdı
      This change eliminates an extra malloc/free when a frame with free
      variables is created.  Any cell vars or free vars are stored in
      f_localsplus after the locals and before the stack.
      
      eval_code2() fills in the appropriate values after handling
      initialization of locals.
      
      To track the size the frame has an f_size member that tracks the total
      size of f_localsplus. It used to be implicitly f_nlocals + f_stacksize.
      2b724da8
  8. 25 Ock, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      PEP 227 implementation · 64949cb7
      Jeremy Hylton yazdı
      The majority of the changes are in the compiler.  The mainloop changes
      primarily to implement the new opcodes and to pass a function's
      closure to eval_code2().  Frames and functions got new slots to hold
      the closure.
      
      Include/compile.h
          Add co_freevars and co_cellvars slots to code objects.
          Update PyCode_New() to take freevars and cellvars as arguments
      Include/funcobject.h
          Add func_closure slot to function objects.
          Add GetClosure()/SetClosure() functions (and corresponding
          macros) for getting at the closure.
      Include/frameobject.h
          PyFrame_New() now takes a closure.
      Include/opcode.h
          Add four new opcodes: MAKE_CLOSURE, LOAD_CLOSURE, LOAD_DEREF,
          STORE_DEREF.
          Remove comment about old requirement for opcodes to fit in 7
          bits.
      compile.c
          Implement changes to code objects for co_freevars and co_cellvars.
      
          Modify symbol table to use st_cur_name (string object for the name
          of the current scope) and st_cur_children (list of nested blocks).
          Also define st_nested, which might more properly be called
          st_cur_nested.  Add several DEF_XXX flags to track def-use
          information for free variables.
      
          New or modified functions of note:
          com_make_closure(struct compiling *, PyCodeObject *)
              Emit LOAD_CLOSURE opcodes as needed to pass cells for free
              variables into nested scope.
          com_addop_varname(struct compiling *, int, char *)
              Emits opcodes for LOAD_DEREF and STORE_DEREF.
          get_ref_type(struct compiling *, char *name)
              Return NAME_CLOSURE if ref type is FREE or CELL
          symtable_load_symbols(struct compiling *)
              Decides what variables are cell or free based on def-use info.
              Can now raise SyntaxError if nested scopes are mixed with
              exec or from blah import *.
          make_scope_info(PyObject *, PyObject *, int, int)
              Helper functions for symtable scope stack.
          symtable_update_free_vars(struct symtable *)
              After a code block has been analyzed, it must check each of
              its children for free variables that are not defined in the
              block.  If a variable is free in a child and not defined in
              the parent, then it is defined by block the enclosing the
              current one or it is a global.  This does the right logic.
          symtable_add_use() is now a macro for symtable_add_def()
          symtable_assign(struct symtable *, node *)
              Use goto instead of for (;;)
      
          Fixed bug in symtable where name of keyword argument in function
          call was treated as assignment in the scope of the call site. Ex:
              def f():
                  g(a=2) # a was considered a local of f
      
      ceval.c
          eval_code2() now take one more argument, a closure.
          Implement LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE>
      
          Also: When name error occurs for global variable, report that the
          name was global in the error mesage.
      
      Objects/frameobject.c
          Initialize f_closure to be a tuple containing space for cellvars
          and freevars.  f_closure is NULL if neither are present.
      Objects/funcobject.c
          Add support for func_closure.
      Python/import.c
          Change the magic number.
      Python/marshal.c
          Track changes to code objects.
      64949cb7
  9. 19 Ock, 2001 1 kayıt (commit)
  10. 17 Ock, 2001 1 kayıt (commit)
    • Guido van Rossum's avatar
      Rich comparisons fall-out: · ac7be688
      Guido van Rossum yazdı
      - Use PyObject_RichCompare*() where possible: when comparing
        keyword arguments, in _PyEval_SliceIndex(), and of course in
        cmp_outcome().
      
      Unrelated stuff:
      
      - Removed all trailing whitespace.
      
      - Folded some long lines.
      ac7be688
  11. 15 Ock, 2001 1 kayıt (commit)
  12. 12 Ock, 2001 1 kayıt (commit)
    • Guido van Rossum's avatar
      Two changes to from...import: · 18d4d8f7
      Guido van Rossum yazdı
      1) "from M import X" now works even if M is not a real module; it's
         basically a getattr() operation with AttributeError exceptions
         changed into ImportError.
      
      2) "from M import *" now looks for M.__all__ to decide which names to
         import; if M.__all__ doesn't exist, it uses M.__dict__.keys() but
         filters out names starting with '_' as before.  Whether or not
         __all__ exists, there's no restriction on the type of M.
      18d4d8f7
  13. 11 Ock, 2001 2 kayıt (commit)
  14. 10 Ock, 2001 1 kayıt (commit)
  15. 04 Ock, 2001 1 kayıt (commit)
    • Fred Drake's avatar
      When a PyCFunction that takes only positional parameters is called with · 1a7aab70
      Fred Drake yazdı
      an empty keywords dictionary (via apply() or the extended call syntax),
      the keywords dict should be ignored.  If the keywords dict is not empty,
      TypeError should be raised.  (Between the restructuring of the call
      machinery and this patch, an empty dict in this situation would trigger
      a SystemError via PyErr_BadInternalCall().)
      
      Added regression tests to detect errors for this.
      1a7aab70
  16. 03 Ock, 2001 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Revised implementation of CALL_FUNCTION and friends. · 5282044b
      Jeremy Hylton yazdı
      More revision still needed.
      
      Much of the code that was in the mainloop was moved to a series of
      helper functions.  PyEval_CallObjectWithKeywords was split into two
      parts.  The first part now only does argument handling.  The second
      part is now named call_object and delegates the call to a
      call_(function,method,etc.) helper.
      
      XXX The call_XXX helper functions should be replaced with tp_call
      functions for the respective types.
      
      The CALL_FUNCTION implementation contains three kinds of optimization:
      1. fast_cfunction and fast_function are called when the arguments on
         the stack can be passed directly to eval_code2() without copying
         them into a tuple.
      2. PyCFunction objects are dispatched immediately, because they are
         presumed to occur more often than anything else.
      3. Bound methods are dispatched inline.  The method object contains a
         pointer to the function object that will be called.  The function
         is called from within the mainloop, which may allow optimization #1
         to be used, too.
      
      The extened call implementation -- f(*args) and f(**kw) -- are
      implemented as a separate case in the mainloop.  This allows the
      common case of normal function calls to execute without wasting time
      on checks for extended calls, although it does introduce a small
      amount of code duplication.
      
      Also, the unused final argument of eval_code2() was removed.  This is
      probably the last trace of the access statement :-).
      5282044b
  17. 30 Eki, 2000 1 kayıt (commit)
    • Jeremy Hylton's avatar
      Fix for SF bug #117241 · 6b4ec513
      Jeremy Hylton yazdı
      When a method is called with no regular arguments and * args, defer
      the first arg is subclass check until after the * args have been
      expanded.
      
      N.B. The CALL_FUNCTION implementation is getting really hairy; should
      review it to see if it can be simplified.
      6b4ec513
  18. 24 Eki, 2000 1 kayıt (commit)
    • Fred Drake's avatar
      Ka-Ping Yee <ping@lfw.org>: · 661ea26b
      Fred Drake yazdı
      Changes to error messages to increase consistency & clarity.
      
      This (mostly) closes SourceForge patch #101839.
      661ea26b
  19. 11 Eki, 2000 4 kayıt (commit)
  20. 26 Eyl, 2000 1 kayıt (commit)
  21. 19 Eyl, 2000 1 kayıt (commit)
    • Marc-André Lemburg's avatar
      This patch adds a new Python C API called PyString_AsStringAndSize() · d1ba4432
      Marc-André Lemburg yazdı
      which implements the automatic conversion from Unicode to a string
      object using the default encoding.
      
      The new API is then put to use to have eval() and exec accept
      Unicode objects as code parameter. This closes bugs #110924
      and #113890.
      
      As side-effect, the traditional C APIs PyString_Size() and
      PyString_AsString() will also accept Unicode objects as
      parameters.
      d1ba4432
  22. 01 Eyl, 2000 5 kayıt (commit)
  23. 31 Agu, 2000 1 kayıt (commit)
    • Jeremy Hylton's avatar
      add user-modifiable recursion_limit · ee5adfba
      Jeremy Hylton yazdı
      ceval.c:
          define recurion_limit (static), default value is 2500
          define Py_GetRecursionLimit and Py_SetRecursionLimit
          raise RuntimeError if limit is exceeded
      PC/config.h:
          remove plat-specific definition
      sysmodule.c:
          add sys.(get|set)recursionlimit
      ee5adfba
  24. 30 Agu, 2000 1 kayıt (commit)
  25. 29 Agu, 2000 1 kayıt (commit)
  26. 27 Agu, 2000 2 kayıt (commit)
  27. 24 Agu, 2000 2 kayıt (commit)
    • Thomas Wouters's avatar
      Support for three-token characters (**=, >>=, <<=) which was written by · 434d0828
      Thomas Wouters yazdı
      Michael Hudson, and support in general for the augmented assignment syntax.
      The graminit.c patch is large!
      434d0828
    • Fred Drake's avatar
      Charles G. Waldman <cgw@fnal.gov>: · ef8ace3a
      Fred Drake yazdı
      Add the EXTENDED_ARG opcode to the virtual machine, allowing 32-bit
      arguments to opcodes instead of being forced to stick to the 16-bit
      limit.  This is especially useful for machine-generated code, which
      can be too long for the SET_LINENO parameter to fit into 16 bits.
      
      This closes the implementation portion of SourceForge patch #100893.
      ef8ace3a
  28. 21 Agu, 2000 1 kayıt (commit)
  29. 20 Agu, 2000 1 kayıt (commit)
    • Thomas Wouters's avatar
      Fix the bug Sjoerd Mullender discovered, where find_from_args() wasn't · 0400515f
      Thomas Wouters yazdı
      trying hard enough to find out what the arguments to an import were. There
      is no test-case for this bug, yet, but this is what it looked like:
      
      from encodings import cp1006, cp1026
      ImportError: cannot import name cp1026
      
      '__import__' was called with only the first name in the 'arguments' list.
      0400515f