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
Fix TypeError for fsoids #351
Conversation
Fix ``TypeError: can't concat str to bytes`` when running fsoids.py script with Python 3. Closes #350
I made the patch in such a way that the shorten function can handle bytes as well as text. ZODB/src/ZODB/FileStorage/fsoids.py Lines 24 to 32 in 1fb097b
One other possibility is to enforce the shorten function to refuse any output that is not a native string or to convert it to a native string, but this appears to me that increases the change of breaking some other stuff... Suggestions are welcome. Once it is clear what to do I can even add some more tests. |
@@ -5,6 +5,9 @@ | |||
5.6.1 (unreleased) | |||
================== | |||
|
|||
- Fix ``TypeError: can't concat str to bytes`` when running fsoids.py script with Python 3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
It seems that we could simply write: return s[:nleading] + b" ... " + s[-ntrailing:] because if I read the code correctly, |
@jmuchemb I also never found that the function argument is text. Anyway the comment says With this patch, the output of this script is something like:
Note the I think that this is an error that should be fixed as well, there is no reason print the str representation of those bytes instances. In short this patch does not solve the misuse of bytes and text, it just wants to make the script work again. |
Is this PR ready to be merged or is there still something to be done to make it ready? |
@icemac I would say this is good to be merged, I had to merge master because of a conflict |
Thank you for this PR and reviewing it. 😃 |
to resolve trivial conflict on CHANGES.rst * origin/master: (22 commits) Fix TypeError for fsoids (zopefoundation#351) Fix deprecation warnings occurring on Python 3.10. fix more PY3 incompatibilities in `fsstats` fix Python 3 incompatibility for `fsstats` add `fsdump/fsstats` test fsdump/fsstats improvements - add coverage combine step - first cut moving tests from Travis CI to GitHub Actions - ignore virtualenv artifacts [ci skip] tests: Run race-related tests with high frequency of switches between threads tests: Add test for load vs external invalidation race tests: Add test for open vs invalidation race fixup! doc/requirements: Require pygments < 2.6 on py2 doc/requirements: Require pygments < 2.6 on py2 fixup! buildout: Fix Sphinx install on Python2 buildout: Fix Sphinx install on Python2 Update README.rst Security fix documentation dependencies (zopefoundation#342) changes: Correct link to UnboundLocalError fsoids.py fix fsrefs: Optimize IO (take 2) (zopefoundation#340) ...
* y/loadAt.8: (35 commits) Make lint happy Let the year float. Configuring for pure-python Specify a PyPy2 version. Lint the code. Configuring for pure-python Fix TypeError for fsoids (zopefoundation#351) Fix deprecation warnings occurring on Python 3.10. fix more PY3 incompatibilities in `fsstats` fix Python 3 incompatibility for `fsstats` add `fsdump/fsstats` test fsdump/fsstats improvements Undeprecate loadBefore fixup! changes: Add draft entry for loadAt/loadBeforeEx/DemoStorage fix changes: Add draft entry for loadAt/loadBeforeEx/DemoStorage fix fixup! Handle NotImplementedError raised by loadBefore/loadBeforeEx as "interface not provided" *: Don't emit warnings on loadBefore Handle NotImplementedError raised by loadBefore/loadBeforeEx as "interface not provided" loadAt -> loadBeforeEx - add coverage combine step ...
Fix
TypeError: can't concat str to bytes
when running fsoids.py script with Python 3.Closes #350