Hi Iwase-san,

On Tue, 7 Jun 2016 09:35:27 +0900
Iwase Yusuke <[email protected]> wrote:

> Hi Kakuma-San,
> 
> Thank you for reviewing my patch.
> 
> 
> On 2016年06月07日 08:30, fumihiko kakuma wrote:
> > On Fri,  3 Jun 2016 13:20:05 +0900
> > IWASE Yusuke <[email protected]> wrote:
> >
> >> diff --git a/ryu/services/protocols/bgp/api/base.py 
> >> b/ryu/services/protocols/bgp/api/base.py
> >> index 489e318..d0c0d79 100644
> >> --- a/ryu/services/protocols/bgp/api/base.py
> >> +++ b/ryu/services/protocols/bgp/api/base.py
> >> @@ -208,7 +208,7 @@ def call(symbol, **kwargs):
> >>       LOG.info("API method %s called with args: %s", symbol, str(kwargs))
> >>
> >>       # TODO(PH, JK) improve the way api function modules are loaded
> >> -    import all  # noqa
> >> +    from . import all  # noqa
> >>       if not is_call_registered(symbol):
> >>           message = 'Did not find any method registered by symbol %s' % 
> >> symbol
> >>           raise MethodNotFound(message)
> >
> > It may be better to add "from __future__ import absolute_import" statement
> > to enforce explicit relative imports.
> 
> Yes, I think it's better.
> But this statement takes effect only the module which is defined,
> so, in the other module without this statement, it has no effect.
> 
> Does anyone know how to globally enforce the explicit relative imports?
> 

Unfortunately it seems that there is not such a way to me.
But the following tool may be usuful.

$ sudo pip install future
$ futurize -f libfuturize.fixes.fix_absolute_import ryu/

This will add "absolute_import" statement to all files under the specified 
directory


> >
> >> diff --git a/ryu/services/protocols/bgp/utils/circlist.py 
> >> b/ryu/services/protocols/bgp/utils/circlist.py
> >> index d22ec21..4a04f4f 100644
> >> --- a/ryu/services/protocols/bgp/utils/circlist.py
> >> +++ b/ryu/services/protocols/bgp/utils/circlist.py
> >> @@ -13,7 +13,9 @@
> >>   # See the License for the specific language governing permissions and
> >>   # limitations under the License.
> >>
> >> -from six.moves import intern
> >> +import six
> >> +if six.PY3:
> >> +    from sys import intern
> >
> > Is this intended to work with six>=1.4.0 ?
> 
> Sorry, I mistook.
> The existing code works correctly.
> 
> (py35) $ pip show six
> ---
> Metadata-Version: 2.0
> Name: six
> Version: 1.10.0
> Summary: Python 2 and 3 compatibility utilities
> Home-page: http://pypi.python.org/pypi/six/
> ...
> (py35) $
> (py35) $ python
> Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
> [GCC 5.3.1 20160330] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from six.moves import intern
> 

six.moves for intern seems to be supported by 1.8.0 and later version
of six from the following.
(sorry, I don't check about a minor version.)

$ pip freeze | grep six
six==1.7.0
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import intern
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name intern
>>>


$ pip freeze | grep six
six==1.8.0
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from six.moves import intern
>>>


And ryu has the following requirement for six.

$ grep six tools/pip-requires
six>=1.4.0
$

On the other hand, a six package version in ubuntu 14.04 lts is 1.5.2-1.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.2 LTS
Release:        14.04
Codename:       trusty
$ dpkg -l python-six
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name              Version       Architecture  Description
+++-=================-=============-=============-========================================
ii  python-six        1.5.2-1       all           Python 2 and 3 compatibility 
library (Py
$

If we use 1.8.0 and later version of six installed from pip, it will be ok.
And tools/pip-requires should be updated.


> I fixed this because PyCharm code inspection said:
>    Cannot find reference 'moves' in 'six.py' (at line 16)
> but this was due to the dynamic dispatch of 'six.moves'.
> 
> 
> I'll update my patches!
> 
> Thanks,
> Iwase

-- 
fumihiko kakuma <[email protected]>



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to