Skip to content

Argument type checking in classical_cipher.py is buggy #33658

@hoodmane

Description

@hoodmane
mannequin

Students often call these functions with strings. This results in an error like "str has no attribute parent":

    336         """
    337         dom = self.domain()  # = plaintext_space = ciphertext_space
--> 338         if not isinstance(M, StringMonoidElement) and M.parent() == dom:
    339             raise TypeError("Argument M (= %s) must be a string in the plaintext/ciphertext space." % M)
    340         from sage.rings.finite_rings.integer_mod import Mod

AttributeError: 'str' object has no attribute 'parent'

Note that it almost made it to raising a TypeError which would be tidier.

Component: cryptography

Branch: u/hoodmane/classical-ciper-typeerrors

Issue created by migration from https://trac.sagemath.org/ticket/33658

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions