Skip to content

geodist command float casting bug #938

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

Closed
fengshenyuan opened this issue Dec 19, 2017 · 0 comments
Closed

geodist command float casting bug #938

fengshenyuan opened this issue Dec 19, 2017 · 0 comments

Comments

@fengshenyuan
Copy link

fengshenyuan commented Dec 19, 2017

I got an exception when test with geodist command.
The traceback of this exception is here:

Traceback (most recent call last):
      File "/home/diyidan_backstage/api_pre/master/user.py", line 628, in get_user_and_me_distance_for_user_profile
        user_and_me_distance = REDIS_CLIENT_GEO.geodist(name=name, place1=current_user_id, place2=check_user_id, unit='m')
      File "/usr/lib/python2.7/site-packages/redis/client.py", line 2135, in geodist
        return self.execute_command('GEODIST', *pieces)
      File "/usr/lib/python2.7/site-packages/redis/client.py", line 668, in execute_command
        return self.parse_response(connection, command_name, **options)
      File "/usr/lib/python2.7/site-packages/redis/client.py", line 682, in parse_response
        return self.response_callbacks[command_name](response, **options)
    TypeError: float() argument must be a string or a number

I checked the current implement of GEODIST command in redis-py.
In source file client.py, line 373, I find code:

  string_keys_to_dict(
            'INCRBYFLOAT HINCRBYFLOAT GEODIST',
            float
        ),

Then I checked official document of GEODIST. It says:

If one or both the members are missing, the command returns NULL.

I think we can get the bug now: the RESPONSE_CALLBACKS setting for command GEODIST cannot just be float.
And I found test items of command GEODIST in test_commands.py is lack of this situation.
I'll try to fix this bug with a pull request.

@fengshenyuan fengshenyuan changed the title geo geodist command float casting bug Dec 19, 2017
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

1 participant