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

mac always a string under python3 #19

Closed
jlec opened this issue Aug 26, 2015 · 3 comments
Closed

mac always a string under python3 #19

jlec opened this issue Aug 26, 2015 · 3 comments

Comments

@jlec
Copy link

jlec commented Aug 26, 2015

Under python3 I see the following although I have set MACADDRESS_DEFAULT_DIALECT = 'netaddr.mac_eui48'

In [1]: from infrabrowser.models import Unit
In [2]: Unit.objects.first().mac
Out[2]: '207369326246'

Following patch (suggested by 2to3) fixes this issue

--- /usr/local/lib/python2.7/site-packages/macaddress/fields.py (original)
+++ /usr/local/lib/python2.7/site-packages/macaddress/fields.py (refactored)
@@ -9,10 +9,9 @@

 import warnings

-class MACAddressField(models.Field):
+class MACAddressField(models.Field, metaclass=models.SubfieldBase):
     description = "A MAC address validated by netaddr.EUI"
     empty_strings_allowed = False
-    __metaclass__ = models.SubfieldBase
     dialect = None

     def __init__(self, *args, **kwargs):
@kra3
Copy link
Member

kra3 commented Sep 5, 2015

Hmm, this is new syntax. let me find a workaround for python 2.x series as well.

@kra3
Copy link
Member

kra3 commented Sep 5, 2015

Have to use with_metaclass from six or future.utils to maintain backward compatibility.

Thanks @jlec for pointing out this bug.

@kra3
Copy link
Member

kra3 commented Nov 19, 2015

Fix has been submitted with pull request #21. Therefor Closing. @jlec please try the latest repo checkout.

@kra3 kra3 closed this as completed Nov 19, 2015
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

No branches or pull requests

2 participants