Giter Club home page Giter Club logo

Comments (4)

zhuyifei1999 avatar zhuyifei1999 commented on July 18, 2024

hmm. Is this how to reproduce this?

$ python
Python 3.9.9 (main, Nov 17 2021, 14:19:07) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import weakref
>>> key1 = lambda: None
>>> key2 = lambda: None
>>> obj = object()
>>> dct = {weakref.ref(key1): obj, weakref.ref(key2): obj}
>>> import guppy
>>> iso = guppy.hpy().iso(obj)
>>> del obj
>>> iso.shpaths
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 386, in reprfunc
    return self.printer.get_str_of_top()
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 272, in get_str_of_top
    return self.get_str(self, True)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 339, in get_str
    return self.mod.View.enter(lambda: f())
  File "/home/zhuyifei1999/guppy3/guppy/heapy/View.py", line 256, in enter
    retval = func()
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 339, in <lambda>
    return self.mod.View.enter(lambda: f())
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 307, in f
    nxt = next(it)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 232, in lines_from
    yield self.line_at(idx)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/OutputHandling.py", line 212, in line_at
    li = next(self.line_iter)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 368, in _oh_get_line_iter
    for el in self:
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 289, in __iter__
    return self.iter()
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 292, in iter
    return PathsIter(self, start, stop)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 176, in __init__
    self.reset(start)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 209, in reset
    sr = self.mod.sortedrels(self.paths.IG, src)
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 462, in sortedrels
    t.sort(key=lambda x: x[0])
  File "/home/zhuyifei1999/guppy3/guppy/heapy/Path.py", line 94, in __lt__
    return self.r < other.r
TypeError: '<' not supported between instances of 'weakref' and 'weakref'

I think among all the relations, only dict keys can be weakrefs. I guess I could change it so that if a comparison fails, compare its id(). The problem is that in that case, say, id(1) > id('foo') and id(2) < id('foo'), it implies id(2) < id('foo') < id(1), but that would conflict with 1 < 2. I could say compare type(1) and type('foo') when the types are different, and when types are the same, try to compare directly, and if that fails with typeerror, compare id... that should work right?

from guppy3.

pi-no avatar pi-no commented on July 18, 2024

That's at least how I patched it here, and I think it was okay, but you probably know better what consequences that can have. But maybe it's not worse than crashing. :)

from guppy3.

zhuyifei1999 avatar zhuyifei1999 commented on July 18, 2024

Yep. 5542d9c should fix it. If dict keys have same-type-but-sometimes-compariable says, say (None,) and (1,), it might fail to have total ordering but there's not much I can do about it.

from guppy3.

pi-no avatar pi-no commented on July 18, 2024

Thanks a lot!

from guppy3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.