Comments (25)
from pysnooper.
from pysnooper.
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.
Which version of PySnooper?
from pysnooper.
Downloaded from Github 4 days ago.
from pysnooper.
from pysnooper.
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.
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.
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.
@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.
True, I will just clone it :)
Thank you very much already for looking into this crude edge cases!
from pysnooper.
@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.
from pysnooper.
Like put a print statement just before the line that fails?
LOL 🤣
from pysnooper.
from pysnooper.
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.
@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.
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.
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.
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.
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.
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.
from pysnooper.
Works gracefully!
Thank you so much :)
from pysnooper.
from pysnooper.
Related Issues (20)
- pypi has 1.0.0 has there is no tag in the repo HOT 3
- bug: python3.9/site-packages/pysnooper/tracer.py", line 263, in simple_wrapper HOT 2
- Output to logging HOT 1
- Snoop recursively, but only in my code. HOT 2
- print value of a claas var HOT 1
- [feature request] Add command line color output for Windows HOT 7
- SOURCE IS UNAVAILABLE HOT 8
- Feature request: python -m pysnooper user_script.py HOT 1
- Compatibility issue with Debugger in Visual Studio Code HOT 2
- Print("come") HOT 1
- compatiblity with python 3.12 HOT 7
- No variable output from the last line HOT 3
- Can not install it in Kaggle platform HOT 1
- `return` event line missing when exception occurred HOT 9
- new features request/discussion HOT 2
- Add Callback HOT 1
- Fix the CI HOT 4
- Deactivate all snooping except explicitly specified "watch"es HOT 3
- snoop entire file or program HOT 3
- Evaluate using `sys.monitoring` to make PySnooper faster
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysnooper.