awdeorio / mailmerge

A simple, command line mail merge tool.
MIT License
140 stars 41 forks source link

chardet error with python36 on CentOS with EPEL #46

Closed bexelbie closed 4 years ago

bexelbie commented 5 years ago

I've run a scratch EPEL build as part of working on #45

https://koji.fedoraproject.org/koji/taskinfo?taskID=35510263

This is very much NOT READY FOR PRIMETIME

Using the sample, I am getting a chardet error.

$ mailmerge
Traceback (most recent call last):
  File "/usr/bin/mailmerge", line 11, in <module>
    load_entry_point('mailmerge==1.9', 'console_scripts', 'mailmerge')()
  File "/usr/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/mailmerge/__main__.py", line 45, in cli
    config_filename=config_filename,
  File "/usr/lib/python3.6/site-packages/mailmerge/api.py", line 343, in main
    (message, sender, recipients) = parsemail(raw_message)
  File "/usr/lib/python3.6/site-packages/mailmerge/api.py", line 47, in parsemail
    detected = chardet.detect(bytearray(raw_message, "utf-8"))
  File "/usr/lib/python3.6/site-packages/chardet/__init__.py", line 25, in detect
    raise ValueError('Expected a bytes object, not a unicode object')
ValueError: Expected a bytes object, not a unicode object

Note: I have done only a minimal amount of debugging work so far - but figured I'd open this in case you just happened to know it (it's midnight here). I'll pick this up with or without response as I have time.

awdeorio commented 5 years ago

Thanks for taking a look at this. I tried taking a look and had trouble replicating the problem.

Bring up a Centos 7 box.

$ vagrant init centos/7
$ vagrant up
$ vagrant ssh

Install Python 3 from EPEL.

[vagrant@localhost ~]$ sudo yum install epel-release
[vagrant@localhost ~]$ $ sudo yum install python36 python36-setuptools python36-pip

Create a Python virtual virtual environment and install mailmerge. NOTE: I also tried installing globally with the same results.

[vagrant@localhost ~]$ $ python3 -m venv env
[vagrant@localhost ~]$ $ source env/bin/activate
(env) [vagrant@localhost ~]$ pip install mailmerge

Run mailmerge

(env) [vagrant@localhost ~]$ mailmerge --sample
Creating sample template email mailmerge_template.txt
Creating sample database mailmerge_database.csv
Creating sample config file mailmerge_server.conf
Edit these files, and then run mailmerge again
(env) [vagrant@localhost ~]$ mailmerge
>>> encoding ascii
>>> message 0
TO: myself@mydomain.com
...

My environment:

(env) [vagrant@localhost ~]$ which python3
~/env/bin/python3
(env) [vagrant@localhost ~]$ which pip
~/env/bin/pip
(env) [vagrant@localhost ~]$ python3 --version
Python 3.6.8
(env) [vagrant@localhost ~]$ pip --version
pip 18.1 from /home/vagrant/env/lib64/python3.6/site-packages/pip (python 3.6)
(env) [vagrant@localhost ~]$ mailmerge --version
mailmerge, version 1.9
bexelbie commented 5 years ago

It appears to be an issue in chardet related to the version. Currently EPEL7 ships with 2.3 and latest is 3.6. I am looking into whether we can get this updated and which version is the minimum.