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

BGL: TypeError: a bytes-like object is required, not 'str' #54

Closed
VahidN opened this issue May 24, 2016 · 2 comments
Closed

BGL: TypeError: a bytes-like object is required, not 'str' #54

VahidN opened this issue May 24, 2016 · 2 comments
Assignees
Labels

Comments

@VahidN
Copy link

VahidN commented May 24, 2016

I'm testing the latest master branch to convert Iranian_Geologist.BGL file to .csv, using Python35-32 on Windows.
The program gives me this error:

Traceback (most recent call last):
  File "pyglossary\pyglossary\glossary.py", line 522, in read
    Reader = self.readerClasses[format]
KeyError: 'BabylonBgl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pyglossary\ui\ui_tk.py", line 86, in CallWrapper__call__
    return self.func(*args)
  File "pyglossary\ui\ui_tk.py", line 728, in load
    ex = self.glos.read(iPath, format=format)
  File "pyglossary\pyglossary\glossary.py", line 529, in read
    **options
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 2835, in read
    for index, (words, defis) in enumerate(reader):
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 1778, in __iter__
    yield self.readEntry()
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 1759, in readEntry
    [res, pos, defi, key_defi] = self.readEntry_defi(block, pos, raw_key)
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 1850, in readEntry_defi
    defi = self.processEntryDefinition(raw_defi, raw_key)
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 2277, in processEntryDefinition
    fields.utf8_defi = self.replace_html_entries(fields.utf8_defi)
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 1917, in replace_html_entries
    return re.sub(pat_entry, replace_html_entry, text)
  File "C:\Python35-32\lib\re.py", line 182, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "pyglossary\pyglossary\plugins\babylon_bgl.py", line 243, in replace_html_entry
    return xml_escape(res)
  File "pyglossary\pyglossary\xml_utils.py", line 15, in xml_escape
    data = data.replace("&", "&")
TypeError: a bytes-like object is required, not 'str'
@ilius ilius added the Bug label May 26, 2016
@ilius ilius self-assigned this May 26, 2016
@ilius
Copy link
Owner

ilius commented May 26, 2016

I suggest you use python2.7 branch until I fix the BGL plugin once for all
https://github.com/ilius/pyglossary/tree/python2.7

@ilius ilius changed the title TypeError: a bytes-like object is required, not 'str' BGL: TypeError: a bytes-like object is required, not 'str' May 26, 2016
@ilius ilius closed this as completed in a1ddfdf Jun 9, 2016
ilius added a commit that referenced this issue Jun 9, 2016
Split into a package with 8 files
Fix bytes/str bugs (fix #54)
Fix CRC check bug (fix #55) by shipping and modifying gzip module:
    https://hg.python.org/cpython/file/3.5/Lib/gzip.py
Migrate to Reader class
Rename bytes and str variables to b_* and u_*
Fix logic and a lot of cleanings
@ilius
Copy link
Owner

ilius commented Jun 9, 2016

Fixed in version 3.0.0

ilius added a commit that referenced this issue Jun 16, 2016
Split into a package with 8 files
Fix bytes/str bugs (fix #54)
Fix CRC check bug (fix #55) by shipping and modifying gzip module:
    https://hg.python.org/cpython/file/3.5/Lib/gzip.py
Migrate to Reader class
Rename bytes and str variables to b_* and u_*
Fix logic and a lot of cleanings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants