Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 218389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:44:46+00:00 2026-05-11T18:44:46+00:00

Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some

  • 0

Edit: You can get the full source here: http://pastebin.com/m26693

Edit again: I added some highlights to the pastebin page. http://pastebin.com/m10f8d239

I’m probably going to regret asking such a long question, but I’m stumped with this bug and I could use some guidance. You’re going to have to run this code (edit: not anymore. I couldn’t include all of the code — it was truncated) to help in order to really see what’s going on, unless you’re God or something, then by all means figure it out without running it. Actually I kind of hope that I can explain it well enough so that’s not necessary, and I do apologize if I don’t accomplish that.

First I’ll give you some output. (Edit: There’s new output below)

argc 1 [<__main__.RESULT instance at 0x94f91ec>]
(<__main__.RESULT instance at 0x9371f8c>, <__main__.RESULT instance at 0x94f91ec>)
None
bar
internal error: unknown result type 0
argc 1 [<__main__.RESULT instance at 0x94f92ac>]
(<__main__.RESULT instance at 0x94f91ac>, <__main__.RESULT instance at 0x94f92ac>)
None
bar
internal error: unknown result type 0
argc 1 [<__main__.RESULT instance at 0x94f91ec>]
(<__main__.RESULT instance at 0x94f91ec>,)
String: 'bar'

We have 3 divisions in the output. Notice that argc is always 1. At the point where that is printed, an argument list has been built to be passed to a plugin (Plugins are simply commands in the expression interpreter. Most of this code is the expression interpreter.) The list of a single RESULT instance representation that follows argc is the argument list. The next line is the argument list once it reaches the Python method being called. Notice it has two arguments at this point. The first of these two is trash. The second one is what I wanted. However, as you can see on the lines starting “argc 1” that argument list is always 1 RESULT wide. Where’s the stray argument coming from?

Like I said, there are 3 divisions in the output. The first division is a class by itself. The second division is a subclassed class. And the third division is no class/instance at all. The only division that outputs what I expected is the 3rd. Notice it has 1 argument member both before the call and within the call, and the last line is the intended output. It simply echoes/returns the argument “bar”.

Are there any peculiarities with variable argument lists that I should be aware of? What I mean is the following:

def foo(result, *argv):
    print argv[0]

I really think the bug has something to do with this, because that is where the trash seems to come from — in between the call and the execution arrival in the method.

Edit: Ok, so they limit the size of these questions. 🙂 I’ll try my best to show what’s going on. Here’s the relevant part of EvalTree. Note that there’s only 2 divisions in this code. I messed up that other file and deleted it.

def EvalTree(self, Root):
    type = -1
    number = 0.0
    freeme = 0


    if Root.Token == T_NUMBER or Root.Token == T_STRING:
        return 0

    elif Root.Token == T_VARIABLE:
        self.CopyResult(Root.Result, Root.Variable.value)
        return 0

    elif Root.Token == T_FUNCTION:
        argc = Root.Children
        param = resizeList([], argc, RESULT)
        print "argc", argc
        for i in range(argc):
            self.EvalTree(Root.Child[i])
            param[i] = Root.Child[i].Result

        self.DelResult(Root.Result)
        Root.Function.func(Root.Result, *param) # I should have never ever programmed Lua ever.
        return 0

Here’s the Plugin’s class.

class Foo:
    def __init__(self, visitor):
        visitor.AddFunction("foo", -1, self.foo)
    def foo(self, result, *argv):
        print argv

Here’s where it’s all executed.

if __name__ == "__main__":
    evaluator = Evaluator()

    expression = "foo2('bar')"
    #expression = "uptime('test')"
    evaluator.SetVariableString("test", "Foo")
    def func(self, result, *arg1):
        print arg1
        evaluator.SetResult(result, R_STRING, evaluator.R2S(arg1[0]))

    evaluator.AddFunction('foo2', -1, func)

    result = RESULT(0, 0, 0, None)
    tree = evaluator.Compile(expression)
    if tree != -1:
        evaluator.Eval(tree, result)
        if result.type == R_NUMBER:
            print "Number: %g" % (evaluator.R2N(result))
        elif result.type == R_STRING:
            print "String: '%s'" % (result.string) #(evaluator.R2S(result))
        elif result.type == (R_NUMBER | R_STRING):
            print "String: '%s' Number: (%g)" % (evaluator.R2S(result), evaluator.R2N(result))
        else:
            print "internal error: unknown result type %d" % (result.type)

    expression = "foo('test')"
        result = RESULT(0, 0, 0, None)
        tree = evaluator.Compile(expression)
        if tree != -1:
                evaluator.Eval(tree, result)
                if result.type == R_NUMBER:
                        print "Number: %g" % (evaluator.R2N(result))
                elif result.type == R_STRING:
                        print "String: '%s'" % (result.string) #(evaluator.R2S(result))
                elif result.type == (R_NUMBER | R_STRING):
                        print "String: '%s' Number: (%g)" % (evaluator.R2S(result), evaluator.R2N(result))
                else:
                        print "internal error: unknown result type %d" % (result.type)

This is the new output:

argc 1
(<__main__.RESULT instance at 0x9ffcf4c>,)
String: 'bar'
argc 1
(<__main__.RESULT instance at 0xa0030cc>, <__main__.RESULT instance at 0xa0030ec>)
internal error: unknown result type 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:44:46+00:00Added an answer on May 11, 2026 at 6:44 pm

    It appears that your code was truncated, so I can’t look through it.

    Given that you only get the extra argument on methods defined in a class, though, might it be the self variable? Every method on a Python class receives self as the first parameter, and if you don’t account for it, you’ll get things wrong.

    In other words, should this:

    def foo(result, *argv):
        print argv[0]
    

    actually be this:

    def foo(self, result, *argv):
        print argv[0]
    

    If so, then the value traditionally held by self will be assigned to result, and your result value will be in the first position of argv.

    If that’s not it, you’ll need to give more code. At the very least, the code that actually runs the tests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 128k
  • Answers 128k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I did actually find out there is a semi-standard way… May 12, 2026 at 5:46 am
  • Editorial Team
    Editorial Team added an answer Try two $("li[title=tha\\'t]").animate({ 'top': '+=40px' }, 'slow'); May 12, 2026 at 5:46 am
  • Editorial Team
    Editorial Team added an answer To answer your question: Yes! For reference: http://docs.heroku.com/rack#sinatra May 12, 2026 at 5:46 am

Related Questions

We get this error in Visual Studio 2005 and TFS very often. Can anyone
I realize this comes at an enormous risk of being branded subjective and discussion-based,
I've been doing PHP/MySQL websites with shared hosting providers for the last couple years.
In Crystal reports, you can define default values for the report parameters. For example,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.