Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: string index out of range #108

Closed
1337-537h opened this issue May 1, 2022 · 47 comments
Closed

IndexError: string index out of range #108

1337-537h opened this issue May 1, 2022 · 47 comments

Comments

@1337-537h
Copy link

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
Copy link
Owner

suurjaak commented May 1, 2022

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
Copy link
Author

  1. No
  2. Νο
  3. I installed the latest Skyperious 5.1 x64 (not the portable).

@suurjaak
Copy link
Owner

suurjaak commented May 1, 2022

What was the search query that produced the error?

@1337-537h
Copy link
Author

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

@suurjaak
Copy link
Owner

suurjaak commented May 1, 2022

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
Copy link
Author

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

@suurjaak
Copy link
Owner

suurjaak commented May 1, 2022

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
Copy link
Author

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

@suurjaak
Copy link
Owner

suurjaak commented May 1, 2022

Can you give the contents of the matching message?

@1337-537h
Copy link
Author

1337-537h commented May 1, 2022

no, can i help you differently?

@suurjaak
Copy link
Owner

suurjaak commented May 1, 2022

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
Copy link
Author

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
Copy link
Owner

suurjaak commented May 2, 2022

Can you respond to questions 1 and 4?

@1337-537h
Copy link
Author

  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
Copy link
Owner

suurjaak commented May 3, 2022

Difficult to track this problem down without specific information..

Can you try the following:

  • open a database in Skyperious
  • open the Python console (menu Help -> Show Python console)
  • in the console, execute the following statements one by one:
dc = wx.MemoryDC()

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:

wordwrap("YOURTEXT", width, dc)

@1337-537h
Copy link
Author

Is that correct?
error still there.

@suurjaak
Copy link
Owner

suurjaak commented May 3, 2022

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
Copy link
Author

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
Copy link
Owner

suurjaak commented May 3, 2022

You need to put the text in quotes, like

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

@suurjaak
Copy link
Owner

suurjaak commented Jun 6, 2022

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

@1337-537h
Copy link
Author

sure but i can do nothing.

@suurjaak
Copy link
Owner

suurjaak commented Jun 8, 2022

Well, what were the results of trying #108 (comment) ?

@1337-537h
Copy link
Author

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

@suurjaak
Copy link
Owner

In #108 (comment) I gave further guidance on how to test the different parts of the problematic text.

@1337-537h
Copy link
Author

@suurjaak
Copy link
Owner

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

@1337-537h
Copy link
Author

1337-537h commented Jun 13, 2022

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
Copy link
Owner

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
Copy link
Author

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

@suurjaak
Copy link
Owner

Ok, how about you try this:

  • open a database in Skyperious
  • open the Python console (menu Help -> Show Python console)
  • in the console, execute the following statements one by one:
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
Copy link
Author

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

@suurjaak
Copy link
Owner

You seemed to have missed pasting the last line:

wx.lib.wordwrap.wordwrap = wordwrap_logged

@1337-537h
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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

@suurjaak
Copy link
Owner

suurjaak commented Jun 16, 2022

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
Copy link
Author

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
Copy link
Owner

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

@1337-537h
Copy link
Author

@suurjaak
Copy link
Owner

Ok, so the error information gets logged now.

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

@1337-537h
Copy link
Author

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

@suurjaak
Copy link
Owner

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

@1337-537h
Copy link
Author

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
Copy link
Owner

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

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

@1337-537h
Copy link
Author

Good news finally.

@suurjaak
Copy link
Owner

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

@suurjaak
Copy link
Owner

suurjaak commented Jul 3, 2022

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

@suurjaak suurjaak closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants