Coder Social home page Coder Social logo

Comments (4)

d6bels avatar d6bels commented on July 21, 2024 2

Thanks, the infinite loop probIem does not occur anymore, but the issue is still not completely solved.
I now have a problem unpickling packets because of :

File "/home/kbleniat/Lab/spymoon/spypy/lib/python2.7/site-packages/pyshark-0.3.4-py2.7.egg/pyshark/packet/layer.py", line 86, in new
print callable(getattr(main_field, "get_default_value"))
AttributeError: 'str' object has no attribute 'get_default_value'

It seems that in LayerFieldsContainer.__new__, the parameter main_field is not always an object having the get_default_value method.

I was able to bypass the problem by checking that it has the method before calling it but it is not a fix in any way.

packet/layer.py

def __new__(cls, main_field, *args, **kwargs):
    if hasattr(main_field, "get_default_value"):  # FIXME
        obj = str.__new__(cls, main_field.get_default_value(), *args, **kwargs)
    else:
        obj = str.__new__(cls, main_field, *args, **kwargs)
    obj.fields = [main_field]
    return obj

from pyshark.

he2ss avatar he2ss commented on July 21, 2024 1

Hello,

I had the same issue as @d6bels and i also patched it in my own code:

from pyshark.packet import layer
class LayerFieldsContainer(layer.LayerFieldsContainer):
    def __new__(cls, main_field, *args, **kwargs):
        if hasattr(main_field, 'get_default_value'):
            obj = str.__new__(cls, main_field.get_default_value(), *args, **kwargs)
        else:
            obj = str.__new__(cls, main_field, *args, **kwargs)
        obj.fields = [main_field]
        return obj
layer.LayerFieldsContainer = LayerFieldsContainer

from pyshark.

KimiNewt avatar KimiNewt commented on July 21, 2024

This is caused by the fact that some of the classes packet uses override getattr. Fixed in 541fc52

from pyshark.

leonisawesome avatar leonisawesome commented on July 21, 2024

I am running into this new now myself.

Latest Mac OS (10.13.6)
Latest Anaconda (4.5.11) with all patches installed

from pyshark.

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.