Coder Social home page Coder Social logo

Runtime error (IronPython) about pysnooper HOT 25 CLOSED

cool-rr avatar cool-rr commented on May 19, 2024
Runtime error (IronPython)

from pysnooper.

Comments (25)

cool-RR avatar cool-RR commented on May 19, 2024 1

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

runxel avatar runxel commented on May 19, 2024

@cool-RR

2.7.8 (IronPython 2.7.8 (2.7.8.0) on .NET 4.0.30319.42000 (64-bit))

(And sadly switching versions is not an option, since this is tied to the program I use (Grasshopper))

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

Which version of PySnooper?

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Downloaded from Github 4 days ago.

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Ah, I didn't use pip. Basically because you can't use pip for that.
When using Grasshopper (part of the NURBS modeling software Rhino) you have to manually download and reference any third-party modules one would like to use.

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

I believe I fixed it. Try the new release and please report back.

@bittner It won't be easy to set up Travis to test on IronPython, right?

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Interestingly it now says illegal char in path.... 🤔

Runtime error (ArgumentException): Illegales Zeichen im Pfad.
Traceback:
  line 75, in inner, "pysnooper.py"
  line 110, in get_source_from_frame, "tracer.py"
  line 229, in trace, "tracer.py"
  line 2, in number_to_bits, "<decorator-gen-2>"
  line 19, in script

from pysnooper.

alexmojaki avatar alexmojaki commented on May 19, 2024

@cool-RR if you're going to chase this, it might save you time not to release a version at each iteration, since @runxel is installing from GitHub anyway. Maybe even make a separate branch.

from pysnooper.

runxel avatar runxel commented on May 19, 2024

True, I will just clone it :)

Thank you very much already for looking into this crude edge cases!

from pysnooper.

bittner avatar bittner commented on May 19, 2024

@bittner It won't be easy to set up Travis to test on IronPython, right?

IronPython is Windows, and Windows environments are not provided by Travis. We can do AppVeyor, though. Just like with PythonTurtle.

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

bittner avatar bittner commented on May 19, 2024

Like put a print statement just before the line that fails?

LOL 🤣

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

runxel avatar runxel commented on May 19, 2024

So, what baffles me is that I am completely lost what path it's talking about.
Also looking into your code gives me no hints to what to print.
(Or can I somehow insert something like print into your code, and get that output?)

@runxel could you fetch the path that includes the illegal path? Like put a print statement just before the line that fails?

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

@runxel See the line with open(file_name, 'rb') as fp: ? The file_name argument probably has an illegal character or something. Add a line just before that line to print file_name, or write it to a file.

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Ach, totally forgot I could write to a file – my bad!
So using file.write(file_name) I obtained this content:
<string><string>
This is literally the whole text file. 😨

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

I'm trying to reproduce this, but I'm not getting the ArgumentException that you're getting. I didn't even know it existed. Can you catch it as e and then print more information about it, especially e.mro()?

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Now that was a fun story:
To actually catch the ArgumentException I had to say

# line 109 ff. in tracer.py
try:
    # foo
except Exception as e:
    # pass

And by that alone the error was gone!
Which actually makes pretty much sense. You have 2 if source is None there. We are in the first if and in it there we get into the else condition – We can never reach the second if source is None.
It then tries to write to a file with a path which is nonexisting and the ArgumentException gets not handled, only OSError and IOError.
Maybe this section should be revised.

Since we can never save the actual Python script in Grasshopper but stuff it into a component (Grasshopper is a node-based visual scripting environment) there will be never a filename.

Of course the except Exception is not a smart thing to do in the real world. The culprit is already in file_name = frame.f_code.co_filename where it is assumed, that this will always give a valid file name. As mentioned above this is not always the case, since the user might run scripts in arbitrary environments.
I'm not sure if we can detect such cases correctly. The other fix would be checking file_name against <string> as content. (I had a mistake there above because I wrongly used a instead of w as the file open argument. So frame.f_code.co_filename interestingly gives this non-empty empty content.)

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

I think you're making a couple of mistakes there. Yes, I know we have to catch more than OSError and IOError, the question is what is that error, because ArgumentException is not a Python error.

Please try adding ValueError to the except clause at line 112 and tell me whether that solves your problem.

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Right, there is no ArgumentException; I guess it comes from C# since Rhino/Grasshopper boils down to this in the end.
Yes, ValueError will do the job!

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

runxel avatar runxel commented on May 19, 2024

Works gracefully!
Thank you so much :)

from pysnooper.

cool-RR avatar cool-RR commented on May 19, 2024

from pysnooper.

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.