Re: non descriptive error

Discussion in 'Python' started by Timothy Smith, Oct 12, 2005.

  1. Fredrik Lundh wrote:

    >Timothy Smith wrote:
    >
    >
    >>i have reproduced the error in this code block
    >>
    >>#save values in edit
    >>self.FinaliseTill.SaveEditControlValue()
    >>if
    >>Decimal(self.parent.TillDetails[self.TillSelection.GetStringSelection()]['ChangeTinBalance']))
    >>== Decimal('0'):
    >>#box must be checked before continuing
    >>if self.PlacedInSafe.GetValue() != 1:
    >>self.parent.Popup("You must place the till draw back in the
    >>safe","Till draw")
    >>else:
    >>#finalise the till draw
    >>if Decimal(self.TillFloat.GetLabel().split('$')[1]) != Decimal('0'):
    >>Prompt = wx.MessageDialog(self,"""The correct amount has not been
    >>returned from the till draw float to the main float!
    >>If you proceed please contact your manager""","Change tin doesn't
    >>balance!",wx.YES_NO)
    >>if Prompt.ShowModal() == wx.ID_YES:
    >>self.Submit()
    >>else:
    >>self.parent.Popup('You have an outstanding change tin balance on this
    >>till','Change tin')
    >>
    >>i have NO idea what in there could be making it have such a strange
    >>error. it just says "error" when you try run it. there nothing terribly
    >>strange being done.
    >>
    >>

    >
    >the snippet you posted gives
    >
    >$ python script.py
    > File "script.py", line 2
    > self.FinaliseTill.SaveEditControlValue()
    > ^
    >SyntaxError: invalid syntax
    >
    >on my python 2.3 install.
    >
    >are you sure you don't have some weird sitecustomize file on your
    >machine? (more likely, it's a wxPython issue. can you reproduce
    >this without using wxPython ?)
    >
    ></F>
    >
    >
    >
    >
    >

    i am still coming across this error it's driving me nuts. usually i can
    find what's wrong, but it is becoming an increasingly annoying problem.
    i also get the same problem on a windows machine with the same
    installed. this time it's nothing to do with the decimal module. help!
    Timothy Smith, Oct 12, 2005
    #1
    1. Advertising

  2. Timothy Smith wrote:

    >>> i have NO idea what in there could be making it have such a strange
    >>> error. it just says "error" when you try run it. there nothing terribly
    >>> strange being done.


    > i am still coming across this error it's driving me nuts. usually i can
    > find what's wrong, but it is becoming an increasingly annoying problem.
    > i also get the same problem on a windows machine with the same
    > installed. this time it's nothing to do with the decimal module. help!


    Go back to first principles. Can you grab all the
    modules being used, and search them for the string
    "error"? Ignore any hits which are in a comment. One of
    the others is almost certainly responsible.

    You can test that by changing the string to "this is a
    PITA" and see if your mysterious error message changes
    or not.



    --
    Steven.
    Steven D'Aprano, Oct 12, 2005
    #2
    1. Advertising

  3. Timothy Smith

    Ron Adam Guest

    Steven D'Aprano wrote:
    > Timothy Smith wrote:
    >
    >>>> i have NO idea what in there could be making it have such a strange
    >>>> error. it just says "error" when you try run it. there nothing terribly
    >>>> strange being done.

    >
    >
    >> i am still coming across this error it's driving me nuts. usually i
    >> can find what's wrong, but it is becoming an increasingly annoying
    >> problem. i also get the same problem on a windows machine with the
    >> same installed. this time it's nothing to do with the decimal module.
    >> help!

    >
    >
    > Go back to first principles. Can you grab all the modules being used,
    > and search them for the string "error"? Ignore any hits which are in a
    > comment. One of the others is almost certainly responsible.
    >
    > You can test that by changing the string to "this is a PITA" and see if
    > your mysterious error message changes or not.


    Maybe there's a way he can examine the traceback to find it.

    I think there's probably a better way, but it may be a start.


    ####
    def seetrace():
    import inspect
    print inspect.trace()
    print ''.join(inspect.trace(5)[0][4])

    try:
    try:
    #### suspect code block
    a = 15+'c'
    print 'hello'
    for x in range(10):
    a = x
    ####
    except:
    seetrace()
    raise "my error" # you never see this

    # This is why bare excepts are not a good idea.
    except:
    raise "Error: your error"
    ####

    In this example you never see "my error" because the outer try over
    rides it. but the prints's still print and give you information about
    the actual error in this case.


    [(<frame object at 0x009A5628>, 'gen.py', 17, '?', [" a =
    15+'c'\n"], 0)]
    try:
    #### suspect code block
    a = 15+'c'
    print 'hello'
    for x in range(10):

    Traceback (most recent call last):
    File "gen.py", line 26, in ?
    raise "your error"
    Error: your error


    Hope this helps,
    Ron
    Ron Adam, Oct 12, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amir Pashazadeh

    .net and descriptive concepts!

    Amir Pashazadeh, Jul 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,039
    Amir Pashazadeh
    Jul 18, 2003
  2. Anupam
    Replies:
    3
    Views:
    284
    Anupam
    Oct 31, 2003
  3. Timothy Smith

    non descriptive error

    Timothy Smith, Oct 7, 2005, in forum: Python
    Replies:
    2
    Views:
    254
    Tomasz Lisowski
    Oct 7, 2005
  4. Timothy Smith

    Re: non descriptive error

    Timothy Smith, Oct 10, 2005, in forum: Python
    Replies:
    4
    Views:
    263
    Fredrik Lundh
    Oct 10, 2005
  5. Replies:
    0
    Views:
    89
Loading...

Share This Page