pydebug | Decorators for debugging Python | Code Inspection library

 by   benmezger Python Version: v0.6 License: MIT

kandi X-RAY | pydebug Summary

kandi X-RAY | pydebug Summary

pydebug is a Python library typically used in Code Quality, Code Inspection applications. pydebug has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can install using 'pip install pydebug' or download it from GitHub, PyPI.

This is a simple set of utilities which makes it easier to debug Python objects. Pydebug respects Django's config. It checks if the decorator is running within a Django project and DEBUG is set to True. If it's set to False, it simply returns the function.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pydebug has a low active ecosystem.
              It has 41 star(s) with 3 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 0 open issues and 2 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of pydebug is v0.6

            kandi-Quality Quality

              pydebug has 0 bugs and 0 code smells.

            kandi-Security Security

              pydebug has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pydebug code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              pydebug is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pydebug releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              pydebug saves you 87 person hours of effort in developing the same functionality from scratch.
              It has 224 lines of code, 29 functions and 7 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pydebug and discovered the below as its top functions. This is intended to give you an instant insight into pydebug implemented functionality, and help decide if they suit your requirements.
            • Initialize a function .
            • Calls the decorated function .
            • Calls the cleanup method .
            • Logs a debug message .
            • Sets up the setup .
            • Raise a TypeError if func is not callable .
            • Return True if self is a subclass of self . func .
            • Check if the function is a class .
            • Returns True if the function is a function .
            Get all kandi verified functions for this library.

            pydebug Key Features

            No Key Features are available at this moment for pydebug.

            pydebug Examples and Code Snippets

            Usage,Requirements,PDBDebugger
            Pythondot img1Lines of Code : 12dot img1License : Permissive (MIT)
            copy iconCopy
            from pydebug import PDBDebugger
            
            @PDBDebugger()
            def hello_world(a, b):
                x = a + b
                return (a, b)
            
            from pydebug import PDBDebugger
            
            @PDBDebugger(on_error=True)
            def hello_world(a, b):
                x = a + b
                return (a, b)
              
            Usage,Requirements,DisassembleDebug
            Pythondot img2Lines of Code : 6dot img2License : Permissive (MIT)
            copy iconCopy
            from pydebug import Disassembledebug
            
            @DisassembleDebug()
            def hello_world(a, b):
                x = a + b
                return (a, b)
              
            Usage,Requirements,Profilerdebug
            Pythondot img3Lines of Code : 6dot img3License : Permissive (MIT)
            copy iconCopy
            from pydebug import ProfilerDebug
            
            @ProfilerDebug()
            def hello_world(a, b):
                x = a + b
                return (a, b)
              

            Community Discussions

            QUESTION

            What flags to use for ./configure when building Python from source
            Asked 2021-Nov-14 at 17:36

            I am building Python 3.10 from source on Ubuntu 18.04, following instructions from several web links, primarily the Python website (https://devguide.python.org/setup) and RealPython (https://realpython.com/installing-python/#how-to-build-python-from-source-code). I extracted Python-3.10.0.tgz into /opt/Python3.10. I have three questions.

            First, the Python website says to use ./configure --with-pydebug and RealPython says to use ./configure --enable-optimizations --with-ensurepip=install. Another source says to include --enable-shared and --enable-unicode=ucs4. Which of these is best? Should I use all of those flags?

            Second, I currently have Python 3.6 and Python 3.8 installed. They are installed in several directories under /usr. Following the directions I have seen on the web I am building in /opt/Python3.10. I assume that make altinstall (the final build step) will take care of installing the build in the usual folders under /usr, but that's not clear. Should I use ./configure --prefix=directory although none of the web sources mention doing that?

            Finally, how much does --enable-optimizations slow down the install process?

            This is my first time building Python from source, and it will help to clear these things up. Thanks for any help.

            ...

            ANSWER

            Answered 2021-Nov-13 at 22:52

            Welcome to the world of Python build configuration! I'll go through the command line options to ./configure one by one.

            --with-pydebug is for core Python developers, not developers (like you and me) just using Python. It creates debugging symbols and slows down execution. You don't need it.

            --enable-optimizations is good for performance in the long run, at the expense of lengthening the compiling process, possibly by 3-fold (or more), depending on your system. However, it results in faster execution, so I would use it in your situation.

            --with-ensurepip=install is good. You want the most up-to-date version of pip.

            --enable-shared is maybe not a good idea in your case, so I'd recommend not using it here. Read Difference between static and shared libraries? to understand the difference. Basically, since you'll possibly be installing to a non-system path (/opt/local, see below) that almost certainly isn't on your system's search path for shared libraries, you'll very likely run into problems down the road. A static build has all the pieces in one place, so you can install and run it from wherever. This is at the expense of size - the python binary will be rather large - but is great for non-sys admins. Even if you end up installing to /usr/local, I would argue that static is better/easier than shared.

            --enable-unicode=ucs4 is optional, and may not be compatible with your system. You don't need it. ./configure is smart enough to figure out what Unicode settings are best. This option is left over from build instructions that are quite a few versions out of date.

            --prefix I would suggest you use --prefix=/opt/local if that directory already exists and is in your $PATH, or if you know how to edit your $PATH in ~/.bashrc. Otherwise, use /usr/local or $HOME. /usr/local is the designated system-wide location for local software installs (i.e., stuff that doesn't come with Ubuntu), and is likely already on your $PATH. $HOME is always an option that doesn't require the use of sudo, which is great from a security perspective. You'll need to add /home/your_username/bin to your $PATH if it isn't already present.

            Source https://stackoverflow.com/questions/69958768

            QUESTION

            python -X showrefcount reporting negative reference counts for extension
            Asked 2021-Jun-10 at 20:52

            When I run cpython with the -X showrefcount flag on an extension I'm writing, it reports a negative reference count (e.g. [-5538 refs, 13503 blocks]) when I return None from a function (using the Py-RETURN_NONE macro).

            Known facts:
            • The exact count varies between runs, but remains within the same order of magnitude.
            • Whatever is happening, it seems to happen slowly; I need to call the extension function approximately 50,000 times before the reference count goes negative.
            • If we replace Py_RETURN_NONE; with Py_INCREF(Py_None); return Py_None;, it changes nothing. Indeed, we can seemingly add an arbitrary number of Py_INCREF(Py_None)s without affecting the reference count at all.
            • If we replace Py_RETURN_NONE; with return Py_None; and don't increment the reference count, it segfaults (as expected).
            • If we replace the None return with another value, e.g. PyLong_FromLong(0);, the problem vanishes.

            What is the cause of this? Related question: why is the reference count not zero after running an empty script?

            Minimal Example: build command used for cpython debug build ...

            ANSWER

            Answered 2021-Jun-10 at 20:52

            The problem was due to the extension having been built using an older version of python, and run using a debug build compiled from the latest version of the source. Extensions not compiled using the stable ABI (and declared as doing so) are not binary compatible across python versions.

            [Credit to ead's comment for asking the question that led directly to this solution.]

            Source https://stackoverflow.com/questions/67878117

            QUESTION

            Add a new cpython keyword
            Asked 2020-Nov-05 at 18:09

            I'm currently on a cpython guide: https://realpython.com/products/cpython-internals-book/

            I will detail what i did and what the problem is. So as it says on the book, i cloned the github :

            ...

            ANSWER

            Answered 2020-Nov-05 at 18:09

            I don't have the book and this is my first time editing Python's grammar, but I got it to work.

            1. Build the "regular" Python 3.10 and install to some temporary directory, like cpython/build/INSTALL:

            Source https://stackoverflow.com/questions/64701784

            QUESTION

            Compiled python version: ModuleNotFoundError at import
            Asked 2020-Sep-27 at 17:54

            I have a project in a conda environment that runs with python 3.7.7 (on linux). When I recompile the same version of python (3.7.7) and put/replace the executable at the same location, I expect the program to run the same way, but the import fails.

            With the original version of python:

            ...

            ANSWER

            Answered 2020-Sep-27 at 01:16

            Where did you compiled the new Python? It could be that missing lib librt.so.1 is the culprit for the error message. Is there any chance to install the librt package (depends on your Linux flavor) and recompile Python.

            Source https://stackoverflow.com/questions/64049417

            QUESTION

            Dwarf DW_AT_location objdump and dwarfdump inconsistent
            Asked 2020-Apr-02 at 08:35

            I am playing around with CPython and trying to understand how a debugger works. Specifically, I am trying to get the location of the last PyFrameObject so that I can traverse that and get the Python backtrace.

            In the file ceval.c, line 689 has the definition of the function:

            PyObject * PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)

            What I am interested in getting is the location of f on the stack. When dumping the binary with dwarfdump I get that f is at $rbp-824, but if I dump the binary with objdump I get that the location is $rbp-808 - a discrepancy of 16. Also, when debugging with GDB, I get that the correct answer is $rbp-808 like objdump gives me. Why the discrepancy, and why is dwarfdump incorrect? What am I not understanding?

            How to technically recreate the problem: Download python-2.7.17.tgz from Python website. Extract.

            I compiled python-2.7.17 from source with debug symbols (./configure --enable-pydebug && make). Run the following commands on the resulting python binary:

            dwarfdump Python-2.7.17/python has the following output:

            ...

            ANSWER

            Answered 2020-Apr-02 at 01:50

            DW_OP_fbreg -824: Meaning $rbp-824

            It does not mean that. It means, offset -824 from frame base (virtual) register, which is not necessarily (nor usually) equal to $rbp.

            You need to look for DW_AT_frame_base to know what the frame base in the current function is.

            Most likely it's defined as DW_OP_call_frame_cfa, which is the value of $RSP just before current function was called, and is equal to $RBP-16 (8 bytes for return address saved by the CALL instruction, and 8 bytes for previous $RBP saved by the first instruction of your function).

            Source https://stackoverflow.com/questions/60967823

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pydebug

            You can install using 'pip install pydebug' or download it from GitHub, PyPI.
            You can use pydebug like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/benmezger/pydebug.git

          • CLI

            gh repo clone benmezger/pydebug

          • sshUrl

            git@github.com:benmezger/pydebug.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Code Inspection Libraries

            Try Top Libraries by benmezger

            dotfiles

            by benmezgerPython

            gjira

            by benmezgerPython

            dollar

            by benmezgerShell

            httmock

            by benmezgerGo

            strail

            by benmezgerC