Skip to content

Don't use getComponentByName on CHOICE type #193

Description

@tiran

pyasn1's getComponentByName() method modifies the internal data structure to materialize the component. This changes the value of a CHOICE data structure. The problem caused bug #192.

I talked Ilya about the issue. There are multiple ways to solve the problem:

  1. use the native encoder, which turns an ASN.1 data structure in a nice Python data structure, available since pyasn1 0.2.1
  2. for choices, replace c.getComponentByName("value") code with "value" in c, fully supported since pyasn1 0.3.4
  3. use c.getComponentByName("value", instantiate=False), available since pyasn1 0.4.1

I'd prefer to rewrite all pyasn1 handling to native encoder, but that's much more work. Most controls are not covered by proper unit and integration tests, too. Since we already require pyasn1 >= 0.3.7, option 2 is the simplest way to go.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions