1. 27 Oct, 2001 18 commits
    • Tim Peters's avatar
      SF bug #475327: type() produces incorrect error msg · 3abca127
      Tim Peters authored
      object.h:  Added PyType_CheckExact macro.
      
      typeobject.c, type_new():
      
      + Use the new macro.
      + Assert that the arguments have the right types rather than do incomplete
        runtime checks "sometimes".
      + If this isn't the 1-argument flavor() of type, and there aren't 3 args
        total, produce a "types() takes 1 or 3 args" msg before
        PyArg_ParseTupleAndKeywords produces a "takes exactly 3" msg.
      3abca127
    • Tim Peters's avatar
      dictionary() constructor: · 4d85953f
      Tim Peters authored
      + Change keyword arg name from "x" to "items".  People passing a mapping
        object can stretch their imaginations <wink>.
      + Simplify the docstring text.
      4d85953f
    • Tim Peters's avatar
      vgetargskeywords() · c2f01120
      Tim Peters authored
      + Squash another potential buffer overrun.
      + Simplify the keyword-arg loop by decrementing the count of keywords
        remaining instead of incrementing Yet Another Variable; also break
        out early if the number of keyword args remaining hits 0.
      
      Since I hit the function's closing curly brace with this patch, that's
      enough of this for now <wink>.
      c2f01120
    • Tim Peters's avatar
      vgetargskeywords: Now that it's clear that nkwlist must equal max, and · b639d497
      Tim Peters authored
      we're ensuring that's true during the format parse, get rid of nkwlist.
      b639d497
    • Tim Peters's avatar
    • Tim Peters's avatar
      vgetargskeywords: Verify kwlist has the required length while parsing · 62d48e17
      Tim Peters authored
      the format, instead of waiting until after we can overindex it by
      mistake.
      62d48e17
    • Fred Drake's avatar
      PyObject_CallFunction(), PyObject_CallMethod(): Make sure we do not touch · b92cf067
      Fred Drake authored
      the va_list until we are sure we have a format string and need to use it;
      this avoid premature initialization and having to finalize it several
      different places because of error returns.
      b92cf067
    • Tim Peters's avatar
      vgetargskeywords: Removed all PyErr_Clear() calls. It's possible that · 0af4916a
      Tim Peters authored
      this routine will report an error now when it didn't before, but, if so,
      it's a legitimate error that should never have been suppressed.
      0af4916a
    • Tim Peters's avatar
      vgetargskeywords: The keywords arg is a dict (if non-NULL), so use the · 077f574d
      Tim Peters authored
      dict API everywhere on it instead of sometimes using the slower mapping
      API.
      077f574d
    • Tim Peters's avatar
      vgetargskeywords: Removed one of the mysterious PyErr_Clear() calls. · 61dde63e
      Tim Peters authored
      The "need" for this was probably removed by an earlier patch that stopped
      the loop right before it from passing NULL to a dict lookup routine.
      I still haven't convinced myself that the next loop is correct, so am
      leaving the next mysterious PyErr_Clear() call in for now.
      61dde63e
    • Tim Peters's avatar
      vgetargskeywords: · b054be41
      Tim Peters authored
      + Generally test nkeywords against 0 instead of keywords against NULL
        (saves a little work if an empty keywords dict is passed, and is
        conceptually more on-target regardless).
      + When a call erroneously specifies a keyword argument both by position
        and by keyword name:
          - It was easy to provoke this routine into an internal buffer overrun
            by using a long argument name.  Now uses PyErr_format instead (which
            computes a safe buffer size).
          - Improved the error msg.
      b054be41
    • Tim Peters's avatar
      vgetargskeywords: · b0872fc8
      Tim Peters authored
      + Got rid of now-redundant dict typecheck.
      + Renamed nkwds to nkwlist.  Now all the "counting" vrbls have names
        related to the things they're counting in an obvious way.
      b0872fc8
    • Tim Peters's avatar
      vgetargskeywords: · 6fb2635f
      Tim Peters authored
      + Renamed argslen to nargs.
      + Renamed kwlen to nkeywords.  This one was especially confusing because
        kwlen wasn't the length of the kwlist argument, but of the keywords
        argument.
      6fb2635f
    • Tim Peters's avatar
      vgetargskeywords: · 28bf7a97
      Tim Peters authored
      + Removed now-redundant tuple typecheck.
      + Renamed "tplen" local to "argslen" (it's the length of the "args"
        argument; I suppose "tp" was for "Tim Peters should rename me
        someday <wink>).
      28bf7a97
    • Tim Peters's avatar
      PyArg_ParseTupleAndKeywords: return false on internal error, not -1 (I · f8cd3e86
      Tim Peters authored
      introduced this bug just a little while ago, when *adding* internal error
      checks).
      
      vgetargskeywords:  Rewrote the section that crawls over the format string.
      + Added block comment so it won't take the next person 15 minutes to
        reverse-engineer what it's doing.
      + Lined up the "else" clauses.
      + Rearranged the ifs in decreasing order of likelihood (for speed).
      f8cd3e86
    • Tim Peters's avatar
      PyArg_ParseTupleAndKeywords: do basic sanity checks on the arguments, · 45772cde
      Tim Peters authored
      and raise an error if they're insane.
      vgetargskeywords:  the same, except that since this is an internal routine,
      just assert that the arguments are sane.
      45772cde
    • Tim Peters's avatar
      tuple(3,4,5,x=2) dumped core on my box. vgetargskeywords() overindexed · a9f4739a
      Tim Peters authored
      the kwlist vector whenever there was a mix of positional and keyword
      arguments, and the number of positional arguments exceeded the length
      of the kwlist vector.  If there was just one more positional arg than
      keyword, the kwlist-terminating NULL got passed to PyMapping_HasKeyString,
      which set an internal error that vgetargskeywords() then squashed (but
      it's impossible to say whether it knew it was masking an error).  If
      more than one more positional argument, it went on to pass random trash
      to PyMapping_HasKeyString, which is why the example at the start
      happened to kill the process.
      
      Pure bugfix candidate.
      a9f4739a
    • Tim Peters's avatar
      vgetargskeywords(): remove test that can't succeed. Not a bugfix, just · f4331c1c
      Tim Peters authored
      removing useless obfuscation.
      f4331c1c
  2. 26 Oct, 2001 22 commits