vstinner / hachoir

Hachoir is a Python library to view and edit a binary stream field by field
http://hachoir.readthedocs.io/
GNU General Public License v2.0
604 stars 70 forks source link

Add missing characters in pdf.py #60

Closed Yash-Garg closed 3 years ago

Yash-Garg commented 3 years ago

Fixes - SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? On - Python Version > 3.6

vstinner commented 3 years ago

Fixes - SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?

Where does this error come from? flake8 doesn't complain, PYTHONPATH=$PWD python3 -Wdefault hachoir/parser/misc/pdf.py neither. The code is valid. Which kind of issue are you trying to solve?

vstinner commented 3 years ago

Oops, I closed the PR by mistake.

Yash-Garg commented 3 years ago

I am using this module in a telegram bot for the extractMetadata and createParser methods. When I run the bot it shows me the warning, logs given below:

2021-02-15T08:10:23.283979+00:00 app[worker.1]: Starting process with command `python3 -m bot`
2021-02-15T08:10:23.947239+00:00 app[worker.1]: State changed from starting to up
2021-02-15T08:10:33.007021+00:00 app[worker.1]: /app/.heroku/python/lib/python3.8/site-packages/hachoir/parser/misc/pdf.py:395: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
2021-02-15T08:10:33.007037+00:00 app[worker.1]:   raise ParserError("Can't find '%s' starting at %u"
2021-02-15T08:10:33.743532+00:00 app[worker.1]: 2021-02-15 08:10:33,738 - apscheduler.scheduler - INFO - Scheduler started
2021-02-15T08:10:34.184556+00:00 app[worker.1]: 2021-02-15 08:10:34,184 - bot - INFO - Bot Started!
vstinner commented 3 years ago

You are running an outdated version of the code. Your bug was already fixed by commit fa5fc556066851d2247b7f651d7f0e317437fc45:

commit fa5fc556066851d2247b7f651d7f0e317437fc45
Author: penn5 <penn5@users.noreply.github.com>
Date:   Mon Jun 1 14:46:50 2020 +0100

    Fix SyntaxWarning in 3.8

    It would be an error, but this case only happens inside another error condition so it's not particularly problematic
vstinner commented 3 years ago

I released Hachoir 3.1.2 which contains the fix.