GithubHelp home page GithubHelp logo

Comments (5)

gaogaotiantian avatar gaogaotiantian commented on May 16, 2024 1

This is a valid bug.

The problem is that when a class has a class method like __new__ or sometimes _create, it will create the self variable in the method. CodeSnap check against class name via self to match the name of entry and exit.

This bug is fixed in master by ignoring the unmatch when the only difference is class name. This test case will also cause a segfault with c tracer, which is fixed in the same commit.

A regression test is added.

from viztracer.

hfudev avatar hfudev commented on May 16, 2024

Another mistake. last line exception. .format(x, y) or f''

from viztracer.

gaogaotiantian avatar gaogaotiantian commented on May 16, 2024

Hi,

Could you make a minimum script that can reproduce this error? Also what interpreter are you using? Is it CPython or something less common? Did you use Cython? I have never tested the module with Cython.

The Exception string is a valid mistake, thanks!

from viztracer.

hfudev avatar hfudev commented on May 16, 2024

Sorry here's a late reply. Just back to the office.

I‘m using CPython 3.8.5 and here's the simplest reproducible script.

# test.py
from datetime import timedelta

a = timedelta(hours=5)

reproduce steps:

  1. python -m codesnap test.py
  2. Traceback:
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "xxx/lib/python3.8/site-packages/codesnap/__main__.py", line 21, in <module>
    snap.save()
  File "xxx/lib/python3.8/site-packages/codesnap/codesnap.py", line 20, in save
    self.parse()
  File "xxx/lib/python3.8/site-packages/codesnap/tracer.py", line 50, in parse
    self.snaptree.add_exit(data[1], data[2])
  File "xxx/lib/python3.8/site-packages/codesnap/snaptree.py", line 38, in add_exit
    raise Exception("Function Entry/Exit did not match.{} vs {}", name, self.curr.function_name)
Exception: ('Function Entry/Exit did not match.{} vs {}', 'datetime.timedelta.__new__', 'datetime.__new__')

I didn't look into your code, but I guess the datetime library is using some trick. Maybe you can take a look at it?

from viztracer.

hfudev avatar hfudev commented on May 16, 2024

I‘ve tested with pip install -U git+https://github.com/gaogaotiantian/codesnap, the fix seems worked! Thanks for your effort. I'm closing this issue

from viztracer.

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.