Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111820

Re: Convert from unsigned long long to PyLong

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From INADA Naoki <songofacandy@gmail.com>
Newsgroups comp.lang.python
Subject Re: Convert from unsigned long long to PyLong
Date Mon, 25 Jul 2016 03:59:13 +0900
Lines 78
Message-ID <mailman.95.1469386781.22221.python-list@python.org> (permalink)
References <45db6d56-90a3-4e4f-958a-65ecb5da5ac6@googlegroups.com> <CAEfz+TzBGrQO9uqMJcaCoaQ-hM8pHzN3DCZeAHy4YthuWKK9RA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de 42+4aHzA7q+Ud8GTvXN/YAzEBVnmZ0pSHAPSIK+TszWA==
Return-Path <songofacandy@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'finally:': 0.05; 'cc:addr:python-list': 0.09; '22,': 0.09; 'cursor': 0.09; 'matched': 0.09; 'python:': 0.09; 'snippet': 0.09; 'underlying': 0.09; 'unsigned': 0.09; 'url:github': 0.09; 'python': 0.10; 'weird': 0.15; '*args)': 0.16; '*self,': 0.16; '2016': 0.16; 'pyobject': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'row': 0.16; 'subject:Convert': 0.16; 'used:': 0.16; 'wrote:': 0.16; 'library,': 0.18; 'try:': 0.18; 'versions': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'issue.': 0.20; 'fix': 0.21; '64-bit': 0.22; 'converted': 0.22; 'doc': 0.22; 'null;': 0.22; 'long,': 0.24; 'header:In-Reply-To:1': 0.24; 'skip:_ 20': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'function': 0.28; 'skip:( 20': 0.28; 'reporting': 0.29; "i'm": 0.30; 'connection': 0.30; 'system,': 0.30; 'url:mailman': 0.30; 'code': 0.30; 'query': 0.30; 'checked': 0.31; 'supposed': 0.31; 'anyone': 0.32; 'related': 0.32; 'problem': 0.33; 'source': 0.33; 'url:python': 0.33; 'skip:_ 30': 0.33; 'maintained': 0.33; "i'll": 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'next': 0.35; 'could': 0.35; 'library.': 0.35; 'url:dev': 0.35; 'sometimes': 0.35; 'supports': 0.35; 'should': 0.36; 'there': 0.36; 'url:org': 0.36; 'possible': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'there,': 0.37; 'thanks': 0.37; 'available.': 0.37; 'release': 0.37; 'skip:p 20': 0.38; 'thank': 0.38; 'means': 0.39; 'data': 0.39; 'url:en': 0.39; 'does': 0.39; 'subject:from': 0.39; 'url:mail': 0.40; 'some': 0.40; 'skip:u 10': 0.61; 'here': 0.66; 'jul': 0.72; 'subject:long': 0.84; 'url:master': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/EpR+dnYkTW9MmA9yUlN70HIt9zCOOA35Lr8ws+Rfp0=; b=ckJbLt8IC8rLCpEfr/9ge6IsOHTf4XA6u07odp4hp8+gfad/ZflqwASpwA8yNXGnyI 5urhQw6UlURsCrmctp+cHP23DIJ/7FiGz4mRWZlsC1ItZaTxUJV34c6yO76yky3cvInI iB9F4S8vCSs0rQVeeWoDvPp8BFMznwrusKv+mJSdeDhno1L2scX6L86J6C1fLmTap5Ph OUDFlPWY1IgLyRjA1+EiAbjGRXVstHl7RKQRm0zjioCtrzP6aJO/5O68YpiueS2KRB3r FQ3ujKP+o0JcTdwnXb+B7k9s7JgMdnhp8zn1D0GiGvEHQetYUQ4xCqZnqNbIHCdf0W0S 3wxw==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/EpR+dnYkTW9MmA9yUlN70HIt9zCOOA35Lr8ws+Rfp0=; b=T4BRPgZGA7RwKdj7SNeqgAE3LYzSt3WHb810OLa79Gcv701DVj3eQWM8XWeFKMBjz1 4s6eOigGoa13Q/svm2xTkQ6h6eD/M+AHSiBmGXdOKkR0K8v7SqozYe1PRd5PUSc/Pwhl djZDu9c2V8Gn0YYW88V0I+8DE+UbavaiqGhxlx4K6+XfzzAYtVN0BI4KqK2MLEFfOyLh EmTYlHVJDQTaF83FA/CXW8xcggSDXAqgzRlyJU5xqYGa3NOdsxHckyQzGmpdqc/EWr+R 8sAlnC2BeigdD5TMOvi7iCpai+HUn6eN2Og2MAKlv9Gnt3YkOetGHz0VNcDvjbzElvrP lYYg==
X-Gm-Message-State AEkooutHWmfmCiDEjL9xr/HN7NMCpJ/SNQq5cNFRtbSqVHTrial5vftYs8elBV1+ZAaYmALAhBGs8/s2li1CiA==
X-Received by 10.31.189.82 with SMTP id n79mr750094vkf.24.1469386772711; Sun, 24 Jul 2016 11:59:32 -0700 (PDT)
In-Reply-To <45db6d56-90a3-4e4f-958a-65ecb5da5ac6@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAEfz+TzBGrQO9uqMJcaCoaQ-hM8pHzN3DCZeAHy4YthuWKK9RA@mail.gmail.com>
X-Mailman-Original-References <45db6d56-90a3-4e4f-958a-65ecb5da5ac6@googlegroups.com>
Xref csiph.com comp.lang.python:111820

Show key headers only | View raw


Thank you for reporting this issue.

I'll fix it in next release of mysqlclient

(MySQL-python has not been maintained for these years.  Please use mysqlclient.
It supports Python 3.)

On Fri, Jul 22, 2016 at 3:01 PM, Tian JiaLin <himurakenshin54@gmail.com> wrote:
> HI There,
>
> I'm using MySQLdb as the MySQL client. Recently I got a weird problem of this library. After looking into it, I suspect the problem may related to the conversion from unsigned long to PyLongObject.
>
> Here is the detail, If you are familiar with MySQLdb, the following snippet is a way to query the data from MySQL:
>
>
> connection = MySQLdb.connect(...)
>
> connection.autocommit(True)
> try:
>     cursor = connection.cursor()
>     if not cursor.execute(sql, values) > 0:
>             return None
>     row = cursor.fetchone()
> finally:
>     connection.close()
> return row[0]
>
>
> Sometimes the return value of execute method would be 18446744073709552000 even there is no matched data available. I checked the source code of the library, the underlying implementation is https://github.com/farcepest/MySQLdb1/blob/master/_mysql.c#L835,
>
> static PyObject *
> _mysql_ConnectionObject_affected_rows(
>         _mysql_ConnectionObject *self,
>         PyObject *args)
> {
>         if (!PyArg_ParseTuple(args, "")) return NULL;
>         check_connection(self);
>         return PyLong_FromUnsignedLongLong(mysql_affected_rows(&(self->connection)));
> }
>
> And here is the official doc for mysql_affected_rows http://dev.mysql.com/doc/refman/5.7/en/mysql-affected-rows.html.
>
> Let me give a superficial understanding, please correct me if I were wrong.
>
> In a 64-bit system, the mysql_affected_rows is supposed to return a number of unsigned long, which means the range should be 0 ~ 2^64 (18446744073709551616), How could it be possible the function PyLong_FromUnsignedLongLong return a converted value larger than 2^64, that's what I don't understand.
>
> Does anyone have some ideas of it?
>
>
> The versions of the components I used:
>
> Python: 2.7.6
> MySQL 5.7.11
> MySQLdb 1.2.5
>
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
INADA Naoki  <songofacandy@gmail.com>

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Convert from unsigned long long to PyLong Tian JiaLin <himurakenshin54@gmail.com> - 2016-07-21 23:01 -0700
  Re: Convert from unsigned long long to PyLong MRAB <python@mrabarnett.plus.com> - 2016-07-22 15:46 +0100
  Re: Convert from unsigned long long to PyLong INADA Naoki <songofacandy@gmail.com> - 2016-07-25 03:59 +0900

csiph-web