Giter Club home page Giter Club logo

Comments (9)

ajalt avatar ajalt commented on September 1, 2024 7

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.

floer32 avatar floer32 commented on September 1, 2024 3

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

https://github.com/cool-RR/PySnooper

from fuckitpy.

ajalt avatar ajalt commented on September 1, 2024

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.

Hnasar avatar Hnasar commented on September 1, 2024

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.

larkin avatar larkin commented on September 1, 2024

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.

pcurry avatar pcurry commented on September 1, 2024

As predictable as this is, I suggest with regard to this problem, fuckit. :-)

from fuckitpy.

grayfall avatar grayfall commented on September 1, 2024

@Hnasar satire aside, your case is pretty much covered by monads.

from fuckitpy.

GalenBusch avatar GalenBusch commented on September 1, 2024

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.

floer32 avatar floer32 commented on September 1, 2024

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)

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.