Giter Club home page Giter Club logo

fuckitpy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fuckitpy's Issues

Fucked code catches breakpoints in wrong locations.

I'm actually using this library at work, and it's pretty great.

We have some old IronPython code, but nobody likes IronPython anymore, so instead of fixing mountains of old code to work with normal python, we just said fuck it.

It works for the most part, but there are a few pieces of code like:

import someIronPythonShit
someIronPythonShit.open.dialogNoOneWantsToSee("fml")

both of those lines would fail, and are satisfyingly steamrolled over with fuckit, but when I try to check breakpoints in thousands of lines of fucked IronPython code, PyCharm catches them in the wrong locations.

Looking at the code here though, it seems like it should be an easy fix. (No, it's not fuckit('fuckit')):

In line 138 in fuckit.py, we have del lines[lineno - 1].
If we change that to lines[lineno - 1] = '', it should work perfectly, hopefully...

...

...Actually, I just checked it with some of the code here. It did work perfectly! I might've even cried a few tears of 'I don't have to deal with this shit anymore'.

fuckit is amazing

I wasn't sure how to provide this feedback otherwise. I'm still trying to figure out how to use fuckit at work, but I just don't give a damn.

Doesn't catch BaseException

If I run some code with fuckit, then by God I expect the code to say fuck it. This does not happen.

Actual code:

>>> import fuckit
>>> with fuckit:
...     raise BaseException()
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
BaseException

[Issue] Fuckit does not execute remaining entries in a tuple upon error.

First of all, thank you for this great code, it is very useful. I wanted to point out a small bug however. Here's a MWE:

import fuckit
@fuckit
def tmp():
  (print(1), print(2), print(3))
  (print(1), print(a), print(3))
tmp()

1
2
3
1

The expected behavior is that the last 3 should have been printed.

This module could be a better suppress from contextlib, maybe

I really don't know how suppress or this code work and if I get the time I'll look into it. But, I want a suppress that doesn't stop execution of a block of code when an error it is supposed to suppress occurs. So instead of this which is an excerpt from a decorator I was making:

with suppress(AttributeError): f_wrapper.__defaults__ = f.__defaults__
with suppress(AttributeError): f_wrapper.__kwdefaults__ = f.__kwdefaults__
with suppress(AttributeError): f_wrapper.__annotations__ = f.__annotations__
with suppress(AttributeError): f_wrapper.__module__ = f.__module__
with suppress(AttributeError): f_wrapper.__dict__.update(f.__dict__)

I would like this:

with fuckit(AttributeError):
    f_wrapper.__defaults__ = f.__defaults__
    f_wrapper.__kwdefaults__ = f.__kwdefaults__
    f_wrapper.__annotations__ = f.__annotations__
    f_wrapper.__module__ = f.__module__
    f_wrapper.__dict__.update(f.__dict__)

Just an idea, and thanks for looking.
Also, maybe FUCET for a module rename if you want: fully unregulated context error trampler

fuckit.py screws up function calls within a namespace, hides errors

if you have to_be_fucked.py

def foo():
    print "flipit"

def bar():
    foo()
    print "frickit"

and do, in another file

import fuckit
fuckit(fuckit(a))
a.bar()

it only prints frickit.
Closer examination shows that the call to foo() inside bar() is throwing NameError: global name 'foo' is not defined, which is being (correctly) swallowed by fuckit.

I'm not good enough at the python ast stuff to figure out why on earth it would be doing it, but this issue is preventing me from using fuckit.py in production.

doesn't fucking put out

Really disapointed with this module, can't rely on it for fucking with my code at all. It can't even fuck it's own example anymore!

Run example.py and you get this:

 fuckit git:(master) ✗ python2 example.py
Traceback (most recent call last):
  File "example.py", line 3, in <module>
    fuckit(fuckit('broke'))
  File "/home/garrett/.local/lib/python2.7/site-packages/fuckit.py", line 118, in __call__
    sourcefile, pathname, _description = imp.find_module(victim)
ImportError: No module named broke

Fucking disapointed. Removing "broke" related stuff and python2 works like a charm. However, python3 is a total trainwreck:

 fuckit git:(master) ✗ python3 example.py 
Traceback (most recent call last):
  File "example.py", line 11, in <module>
    class BrokenClass(object):
  File "/home/garrett/.local/lib/python3.5/site-packages/fuckit.py", line 172, in __call__
    elif isinstance(victim, (types.ClassType, type)):
AttributeError: module 'types' has no attribute 'ClassType'

Python3 had other issues, like that it wouldn't modify the ast tree to skip name errors or zero-division-errors or anything. Seriously, the only thing it seemed to do was call the function multiple times without skipping any errors at all!

Until you can make this put out for all my pythons, I shall not be using it for any of my projects -- it's simply too unreliable.

fuckit with logging errors

I'd very much like to use fuckitpy in a project I'm working on, but I don't want to silence errors (just proceed past them).
I don't think the current API supports this use case, but this fact is preventing me from using it.

AttributeError: 'NoneType' object has no attribute 'read'.

Windows 7
Python 2.7.8
fuckit 4.8.0 (installed by pip2.7 install fuckit )

$ python2.7 webqq.py
Traceback (most recent call last):
  File "webqq.py", line 49, in <module>
    fuckit('config')
  File "d:\Python27\lib\site-packages\fuckit.py", line 119, in __call__
    source = sourcefile.read()
AttributeError: 'NoneType' object has no attribute 'read'

Fails to import packages

Example:

main.py
some_shitty_package/
    __init__.py
# main.py
import fuckit
module = fuckit('some_shitty_package')
print(module.x)
# __init__.py
x = 7
raise Exception('package failed to import!')

Expected:

$ python3 main.py
7

Actual:

$ python3 main.py
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    module = fuckit('some_shitty_package')
  File "/home/cjb7/anaconda3/lib/python3.6/site-packages/fuckit.py", line 119, in __call__
    source = sourcefile.read()
AttributeError: 'NoneType' object has no attribute 'read'

Chaining doesn't help! The problem is that imp.find_module returns None for the file when the module to be imported is a package.

Also I like to think I have a genuine use case for fuckit.py. Basically a lot of my projects import each other initially to look at each other's __version__ attribute, and cough exceptions if they are being used with incompatible versions of each other. Sometimes importing fails because the wrong version is being used, and it would be useful to be able to still read the version string and raise that exception first, because it can be completely opaque why the import is failing when really the problem is that you're using incompatible versions of things. So the program is going to fail anyway, and I would rather it fail with a more meaningful exception.

And whilst I could check versions using distutils and friends, actually importing the module and checking is more reliable, since if you have a poorly configured environment you might have dregs of old packages around reporting their version numbers to distutils even though a different version will be imported - and without getting the version exception it's hard to know that that's what the problem is.

But it's proved very difficult to get that version string out, even with fuckit.py! Something less violent would be fine, really all I want is the globals dict of the failed import, but this has proved extremely difficult and I probably won't bother. Nonetheless here's a bug report.

Version number is incorrect

Pypi says 4.8.1, the badge and the documentation say ה.ג.א, but that would be 5.3.1 assuming correct right-to-left reading for the Hebrew. 4.8.1 would be ד.ח.א.

No promises<sup id="a0">[0](#f0)</sup>

Everyone knows that a promise to fuckit when the code is done is worth more than fucking it now.1 The original JavaScript version does things that way. Surely Python should be better than JavaScript, so I can write:

async def stuff():
    await fuckit('real_stuff')
    return real_stuff.do_it()

And yes, I realize that's a future, not a promise, but fuckit('hoverboard'), you know what I mean.


0 ... but if you should fall...

1 An acquaintance of mine says "That sentence is exactly why I no longer date fellow programmers", but I don't understand what she means.

Python 3 compatibility

I've just started a python3 branch, which may be useful to some. If you are interested, watch it at https://github.com/admk/fuckitpy.

It was only a 10 minutes hack to make all tests pass in Python 3, I am hoping that maybe I will get a chance to allow it to be compatible with Python 2 and 3. The only difference is exec statements instead of function calls, and a minor difference between ast.{Try, TryExcept} as well as an inclusion of the line from __future__ import print_function, but in theory maybe we can bootstrap its own source file, that is, we fuckit fuckit itself. 😆

After this a pull request would be appropriate.

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.