jakesylvestre / pychess

Automatically exported from code.google.com/p/pychess
GNU General Public License v3.0
1 stars 7 forks source link

pychess crashes in ldraw.py:repetitionCount #662

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start an adjourned game (maybe an existing PGN with moves in it would work 
too) that loads a game history into the GameModel

What is the expected output? What do you see instead?
PyChess crashes with
Traceback (most recent call last):
  File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
    self.run()
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/System/GtkWorker.py", line 171, in run
    self.result = self.func(self)
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/widgets/ionest.py", line 39, in <lambda>
    workfunc(w, gamemodel, player0tup, player1tup, loaddata))
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/widgets/ionest.py", line 175, in workfunc
    gamemodel.loadAndStart (uri, loader, gameno, position)
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/Utils/GameModel.py", line 330, in loadAndStart
    chessfile.loadToModel(gameno, position, self)
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/Savers/fen.py", line 37, in loadToModel
    model.status, model.reason = getStatus(model.boards[-1])
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/Utils/logic.py", line 55, in getStatus
    if ldraw.repetitionCount (lboard) >= 3:
  File "/home/gatto/code/hg/pychess-adjourned/lib/pychess/Utils/lutils/ldraw.py", line 8, in repetitionCount
    if board.history[-ply][4] == board.hash:
TypeError: 'NoneType' object is unsubscriptable

The full crash is attached.

Original issue reported on code.google.com by mattgatto on 3 Apr 2011 at 9:19

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by mattgatto on 3 Apr 2011 at 9:20

GoogleCodeExporter commented 9 years ago
Looks like it loads the game using 'fen'.
This means than board.ply can be much larger than len(board.history).

Original comment by lobais on 4 Apr 2011 at 10:30

GoogleCodeExporter commented 9 years ago
Good catch.
LBoard's applyFen() initializes:
        self.history = [None]*movenumber
We do this to store the game's ply-count as len(board.history) (no other 
reason).
I'm not a huge fan, but it's OK. I'll fix my own code and correct LBoard.py's 
comments about what history contains.

Original comment by Uncombed...@gmail.com on 4 Apr 2011 at 9:59

GoogleCodeExporter commented 9 years ago
Fixed in b68f1581e363
(I tried playing on from a game saved as FEN to test.)

Original comment by Uncombed...@gmail.com on 4 Apr 2011 at 10:13

GoogleCodeExporter commented 9 years ago
Ah right. That's how it is.
Yup, it isn't too nice a solution. But on the other hand, I don't think the 
obvious alternative is much better.
Good thinking putting that comment in the top.

Original comment by lobais on 5 Apr 2011 at 8:19