suurjaak / Skyperious

Skype chat history tool
Other
350 stars 36 forks source link

IndexError: string index out of range #108

Closed 1337-537h closed 2 years ago

1337-537h commented 2 years ago

Traceback (most recent call last): File "skyperious\workers.py", line 276, in run File "skyperious\skypedata.py", line 1849, in parse File "skyperious\skypedata.py", line 2341, in dom_to_html File "skyperious\workers.py", line 143, in File "wx\lib\wordwrap.py", line 36, in wordwrap IndexError: string index out of range

suurjaak commented 2 years ago

Few questions:

  1. Does this happen for any text you enter in the search box?
  2. And in every chat you search in?
  3. How was Skyperious installed?
1337-537h commented 2 years ago
  1. No
  2. Νο
  3. I installed the latest Skyperious 5.1 x64 (not the portable).
suurjaak commented 2 years ago

What was the search query that produced the error?

1337-537h commented 2 years ago

Greek letters/words But in previous versions the problem wasn't there.

suurjaak commented 2 years ago

Can you give a specific instance of a query that raises error? Trying with Greek or Cyrillic or Kanji letters myself works successfully.

1337-537h commented 2 years ago

First example: "νομιζω ειχα πεθάνει"

suurjaak commented 2 years ago

Does the message itself display fine in chat history, the message that contains this text?

Can you give the contents of the matching message?

1337-537h commented 2 years ago

The message appears itself fine in the history but not when im trying to search the keywords.

suurjaak commented 2 years ago

Can you give the contents of the matching message?

1337-537h commented 2 years ago

no, can i help you differently?

suurjaak commented 2 years ago

A round of 20 questions, then :)

  1. What happens when you search for any of those words individually?
  2. Where in the message text do these words occur? Beginning, end, in between?
  3. How long is the message itself? Is it an ordinary message? Are there some unusual characters in the message, neither Latin nor Greek alphabet? Is there some very long string of characters in the text?
  4. What happens when you search for something else that this message contains?
1337-537h commented 2 years ago

everything is normal no big text in every line nothing special.. But the log (main.db) are big 200MB 300MB.. characters are greek and english (latin) some searches return results some return the error i post above.

suurjaak commented 2 years ago

Can you respond to questions 1 and 4?

1337-537h commented 2 years ago
  1. If i search ειχα the error come up, but if i search "είχα" then no problem appears. its not the same im just saying.. 4.I thing always error again.
suurjaak commented 2 years ago

Difficult to track this problem down without specific information..

Can you try the following:

dc.SetFont(wx.Font(8, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, faceName=conf.HistoryFontName))

width = page.html_searchall.Size.width * 5 // 9

from wx.lib.wordwrap import wordwrap

And then see what are the results when you try invoking the following statement with different texts:
```python
wordwrap("YOURTEXT", width, dc)
1337-537h commented 2 years ago

Is that correct? error still there.

suurjaak commented 2 years ago

And now replace YOURTEXT with the contents of the message, whole and different parts of it, to see when and how the error occurs.

1337-537h commented 2 years ago

Im not sure if i did it correctly.

`2022-05-03 21:51:32.914 An unexpected error has occurred:

        Traceback (most recent call last):
          File "code.py", line 90, in runcode
          File "<input>", line 1, in <module>
        NameError: name 'ειχα' is not defined

2022-05-03 21:52:23.848 An unexpected error has occurred:

        Traceback (most recent call last):
          File "code.py", line 90, in runcode
          File "<input>", line 1, in <module>
        NameError: name 'test' is not defined`
suurjaak commented 2 years ago

You need to put the text in quotes, like

wordwrap("ειχα", width, dc)
suurjaak commented 2 years ago

@1337-537h Are you still interested in getting this resolved?

1337-537h commented 2 years ago

sure but i can do nothing.

suurjaak commented 2 years ago

Well, what were the results of trying https://github.com/suurjaak/Skyperious/issues/108#issuecomment-1116299215 ?

1337-537h commented 2 years ago

I think i did that when you told me and i reply you what happend.

suurjaak commented 2 years ago

In https://github.com/suurjaak/Skyperious/issues/108#issuecomment-1116556456 I gave further guidance on how to test the different parts of the problematic text.

1337-537h commented 2 years ago

https://imgur.com/6zLvVa0

suurjaak commented 2 years ago

Can you identify a minimal text that raises this error, and that you are willing to share?

1337-537h commented 2 years ago

I remember that happens when i search this word "ειχα" But that appears in so many entries. The main.db file is over 300mb. https://i.imgur.com/WjUGCTm.png https://i.imgur.com/85b9X2C.png

suurjaak commented 2 years ago

I think you misunderstood the guidance. After the from wx.lib.wordwrap import wordwrap, you should now write

wordwrap("ειχα", width, dc)

Replacing ειχα with the message text that is causing this error. Does it raise the error here also?

1337-537h commented 2 years ago

same thing after that too. https://i.imgur.com/BFtUP6h.png

suurjaak commented 2 years ago

Ok, how about you try this:


wordwrap_original = wx.lib.wordwrap.wordwrap

def wordwrap_logged(text, width, dc, breakLongWords=True, margin=0):
    try: return wordwrap_original(text, width, dc, breakLongWords, margin)
    except Exception as e:
        main.logger.info("ERROR WRAPPING %r: %s", text, e)
        raise

wx.lib.wordwrap.wordwrap = wordwrap_logged

And then try searching again with a text that raises error. This will print the exact problematic text to the Skyperious log window (menu Help -> Show log window).

1337-537h commented 2 years ago

I didn't spot any difference.. https://i.imgur.com/ahbA8w2.png

suurjaak commented 2 years ago

You seemed to have missed pasting the last line:

wx.lib.wordwrap.wordwrap = wordwrap_logged
1337-537h commented 2 years ago

What you mean? I did it, you can see it in the sreenshot. I did it and its the same as the above screen.

In Python console i put:

  1. wordwrap_original = wx.lib.wordwrap.wordwrap
  2. def wordwrap_logged(text, width, dc, breakLongWords=True, margin=0): try: return wordwrap_original(text, width, dc, breakLongWords, margin) except Exception as e: main.logger.info("ERROR WRAPPING %r: %s", text, e) raise
  3. wx.lib.wordwrap.wordwrap = wordwrap_logged
  4. search the keyword ειχα then the error come up and i open the log and take the screenshot.
suurjaak commented 2 years ago

Right, it's there, but it should be on a separate line - in the screenshot it has become part of the wordwrap_logged function definition.

1337-537h commented 2 years ago

How do to that? I don't know how..

suurjaak commented 2 years ago

Just copy-paste the blocks one by one, pressing Enter a few times in between. First:

wordwrap_original = wx.lib.wordwrap.wordwrap

Then:

def wordwrap_logged(text, width, dc, breakLongWords=True, margin=0):
    try: return wordwrap_original(text, width, dc, breakLongWords, margin)
    except Exception as e:
        main.logger.info("ERROR WRAPPING %r: %s", text, e)
        raise

And then:

wx.lib.wordwrap.wordwrap = wordwrap_logged
1337-537h commented 2 years ago

The trick was to press enter two times in the second command. But i didn't notice any diference.. https://i.imgur.com/lWyPvsF.png

suurjaak commented 2 years ago

Can you show a more complete screenshot of the log window?

1337-537h commented 2 years ago

https://i.imgur.com/CIz9ACo.png

suurjaak commented 2 years ago

Ok, so the error information gets logged now.

Can you show me the precise value that got ERROR WRAPPING?

1337-537h commented 2 years ago

nooo.. its just a greek text.. is there any other way that can i help you?

suurjaak commented 2 years ago

Is all of it Greek text? If not, you can replace Greek letters with X.

1337-537h commented 2 years ago

Thats another greek word that popup the same error that i can share the screenshot. https://i.imgur.com/9VmA6xx.png

I search for the word "τεστ" (test in greek)

suurjaak commented 2 years ago

Aha, got it. The problem comes up with text emoticons.

Thank you, this gives me enough information to try fixing it.

1337-537h commented 2 years ago

Good news finally.

suurjaak commented 2 years ago

Should be fixed in the newly released v5.2 - can you confirm?

suurjaak commented 2 years ago

Problem should be solved, no more feedback for 2 weeks - closing issue.