Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TNEF.__str__ is broken #94

Closed
petri opened this issue Nov 28, 2020 · 2 comments · Fixed by #97
Closed

TNEF.__str__ is broken #94

petri opened this issue Nov 28, 2020 · 2 comments · Fixed by #97

Comments

@petri
Copy link
Member

petri commented Nov 28, 2020

Traceback (most recent call last):
  File "/Users/petri/Code/koodaamo/tnefparse/tests/utest.py", line 5, in <module>
    print(TNEF(tf.read()))
  File "/Users/petri/Code/koodaamo/tnefparse/tnefparse/tnef.py", line 340, in __str__
    return f"<{self.__class__.__name__}:0x{self.key:2.2x}{atts}>"
ValueError: Precision not allowed in integer format specifier
@petri petri changed the title TNEF __str__ is broken TNEF.__str__ is broken Nov 28, 2020
@jugmac00
Copy link
Collaborator

I have no access to a PC right now, but I will have a look this evening.

I wonder whether this regression was introduced by my "f-strings" commit, which was autogenerated by pyupgrade or whether this was broken before. Either way. I should have tested the change at least manually.

Anyway, afair __str__ has no coverage. Yet another good reason to aim for 100% (#92 ).

@jugmac00
Copy link
Collaborator

Note
The str representation was broken for Python 3 from the beginning.

I checked out an older commit where Python 2.7 was still supported, so I had a chance to see what's a correct str representation should look like:

tnefparse on  HEAD (ae186c2) via 🐍 v2.7.17 (venv) 
❯ python
Python 2.7.17 (default, Sep 30 2020, 13:38:04) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tnefparse import TNEF
>>> t = TNEF(open("tests/examples/one-file.tnef", mode="rb").read())
>>> t
<tnefparse.tnef.TNEF object at 0x7f4a67ba9150>
>>> str(t)
'<TNEF:0x237, 1 attachments>'

@petri petri closed this as completed in #97 Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants