Skip to content

PrettyPrinter is invoked one object at a time #159

@shartse

Description

@shartse

In the process of looking at turning stacks into a PrettyPrinter, I found that PrettyPrinter invokes the print function one object at a time:

for obj in objs:
    if type_canonical_name(obj.type_) != type_name:
        raise CommandError(
             self.name,
             f'exepected input of type {self.input_type}, but received '
             f'type {obj.type_}')
        self.pretty_print([obj])

This seems to be at odds with the signature of pretty_print, which is: pretty_print(self, objs: Iterable[drgn.Object]) and prevents writing a pretty_print function that takes into accounts all the objects being printed.

I tried out a code change that drops the error checking and calls self.pretty_print([obj]) directly and that seemed to work in simple cases, but I'm not sure if there is other command functionality built on the one-at-a-time processing. Assuming there's not, I need to figure out how to build error checking into a solution.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions