Comments (9)
Thanks for the input! I looked into this issue when it was first opened. Here's where I got:
It's totally possible to print a stack trace for the first SyntaxError in each module. Those are silenced by essentially deleting the offending source line. That usually creates more syntax errors which weren't present in the original code, and we don't want to see those.
For runtime errors, I unfortunately couldn't find a satisfactory solution. The problem is that once you use fuckit(fuckit('module'))
(a.k.a. "double-fucking"), the module code that is executed isn't the original code at all. It's dynamically generated code that doesn't have any file information associated with it, and with a call stack that is completely different from the original. So for most errors, I could print the type of error, but no traceback.
I tried a few different ways to retain the original traceback, but I haven't found one that works in all cases.
I welcome any suggestions.
from fuckitpy.
this thread is great. this module is so funny.
@Hnasar if you actually want to do this easily, without using a funny module, give funcy
decorators a shot. You can use the debug decorators such as @log_errors
, plus @silent
or @ignore
. These are very useful during development, especially with weird code. Strongly advised to remove them before going to production though 😅
Update:
Oh, I recommend anyone stumbling upon this funny thread... to legitimately check out
PySnooper
- it is not for steamrolling errors, but it is related to the general question of WTF IS THIS CODE DOING. :) basically traces what's going on
from fuckitpy.
If it's not obvious, this module is satire. It works, but using it is almost certainly a bad idea.
Having said that, are you saying that you want stack traces printed out for errors that FuckIt steamrolls? Because I could totally do that.
from fuckitpy.
Yeah stack traces would be great.
Basically, I have an application where quitting is rather tricky, and I'd my application quit uncleanly than hang because I've overlooked something.
Still, I'd like to eventually fix the things I've overlooked, but that comes later.
from fuckitpy.
I'd love it to print stack traces too: sometimes you write a bunch of code and there's a few small errors -- expect a boolean and get a string, key errors, etc -- and running through the code once with fuckit and getting all the errors in the first pass would be faster than fixing one error at a time and rerunning it.
Finding a questionably legitimate use for fuckit.py would make my day.
from fuckitpy.
As predictable as this is, I suggest with regard to this problem, fuckit. :-)
from fuckitpy.
@Hnasar satire aside, your case is pretty much covered by monads.
from fuckitpy.
I had the greatest laugh reading the README and the FuckIt module. Steamroll errors. Fuck logging. Import some of whatever_shitty_module. I think I landed on this after spending 3 hours taking all of the Try/Except/Pass's out of my code and implementing logging.
For any poor soul that lands on this in the vein of logging; here you go.
from datetime import datetime
import sys
import inspect
def log(exception, function_name_string, arg3=''):
callerframerecord = inspect.stack()[1]
frame = callerframerecord[0]
info = inspect.getframeinfo(frame)
f=open("T:\\ype\\your\\fucking\\log\\path\\here\\and\\dont\\forget\\the.txt","a")
t = datetime.now().strftime('%D %r')
n = str(sys.argv[0])
l = str(info.lineno)
func = str(function_name_string)
e = str(exception)
a3 = str(arg3)
log_entry = str('\n'+t+' | '+n+' | '+func+' | Line '+l+' | '+e+' | '+a3)
f.write(log_entry)
f.close
Example integrated into an except:
except Exception as e:
log(e,'insert_into_database', pipe.return_query())
pass
Go fix your fucking code.
from fuckitpy.
Oh, I recommend anyone stumbling upon this funny thread... to legitimately check out PySnooper
- it is not for steamrolling errors, but it is related to the general question of WTF IS THIS CODE DOING. :) basically traces what's going on
https://github.com/cool-RR/PySnooper
from fuckitpy.
Related Issues (20)
- Python 3 compatibility HOT 11
- AttributeError: 'NoneType' object has no attribute 'read'. HOT 2
- fuckit is amazing HOT 1
- No promises<sup id="a0">[0](#f0)</sup>
- doesn't fucking put out HOT 1
- fuckit.py screws up function calls within a namespace, hides errors HOT 3
- Fails to import packages HOT 3
- Fucked code catches breakpoints in wrong locations. HOT 2
- Doesn't catch BaseException HOT 1
- tag versions in git HOT 3
- Context manager behaves differently than function decorator HOT 2
- Division by zero should be 0 HOT 1
- [Issue] Fuckit does not execute remaining entries in a tuple upon error.
- Version number is incorrect
- This module could be a better suppress from contextlib, maybe
- does it support 'edit and resume'?
- does it support 'edit and resume'?
- What about async fuckit? HOT 1
- setup.py relies on README.md, but README.md isn't available in the sdist on pypi HOT 3
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 fuckitpy.