bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24117: 25.1; url-http-create-request: Multibyte text in HTTP request


From: Sho Takemori
Subject: bug#24117: 25.1; url-http-create-request: Multibyte text in HTTP request
Date: Mon, 1 Aug 2016 08:21:39 +0900

It seems that anaconda-mode use two global variables (url-request-method and url-request-data)
to make generate the request.

https://github.com/proofit404/anaconda-mode/blob/master/anaconda-mode.el#L349

url-request-method is bound to an ASCII string "POST".
In my situation, url-request-data is bound to a unibyte string as below.

"{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"eldoc\",\"params\":{\"source\":\"# -*- coding: utf-8 -*-\\nimport itertools\\nfrom itertools import groupby\\n\\nfrom sage.all import mul\\nfrom sage.arith.all import kronecker_symbol\\nfrom sage.functions.all import ceil, floor, sgn\\nfrom sage.matrix.all import (block_diagonal_matrix, block_matrix,\\n                             diagonal_matrix, identity_matrix, matrix)\\nfrom sage.misc.all import cached_function\\nfrom sage.quadratic_forms.all import QuadraticForm, least_quadratic_nonresidue\\nfrom sage.rings.all import QQ, ZZ, CyclotomicField, FiniteField, PolynomialRing\\n\\n\\ndef _index_of_gamma_0_gl_n(alpha, p):\\n    '''\\n    Returns delta(a1, ..., an) defined in Shimura, Euler products and Eisenstein\\n    series, pp 118, (15.1.7).\\n    '''\\n    if p in ZZ:\\n        p = ZZ(p)\\n\\n    def _bn(n):\\n        return mul(1 - p ** (-i) for i in xrange(1, n + 1))\\n\\n    e_r_ls = [(k, len(list(v)))\\n              for k, v in groupby(sorted(alpha), lambda x: x)]\\n    res = _bn(len(alpha)) / mul(_bn(r) for _, r in e_r_ls)\\n    for i, (ei, ri) in enumerate(e_r_ls):\\n        for j, (ej, rj) in enumerate(e_r_ls):\\n            if i < j:\\n                res *= p ** ((ej - ei) * ri * rj)\\n    return res\\n\\n\\ndef _gl2_coset_gamma0(a, p):\\n    w = matrix([[0, -1],\\n                [1, 0]])\\n    for m12 in range(p ** a):\\n        yield matrix([[1, m12],\\n                      [0, 1]])\\n    for m21 in range(p ** (a - 1)):\\n        m = matrix([[1, 0],\\n                    [p * m21, 1]])\\n        yield w * m\\n\\n\\ndef _gl3_coset_gamma0(alpha, p):\\n    r'''\\n    Let alpha = [a0, a1, a2] with a0 <= a1 <= a2,\\n    g = diag([p^a0, p^a1, p^a2]), and Gamma0 = g^(-1) GL3(Z) g \342\210\247 GL3(Z).\\n    Return a complete set Gamma0 \\\\ GL3(Z).\\n    '''\\n    if p in ZZ:\\n        p = ZZ(p)\\n    a0, a1, a2 = alpha\\n    if a0 < a1 < a2:\\n        return list(__gl3_coset_gamma0_distinct(a0, a1, a2, p))\\n    elif a0 == a1 and a1 < a2:\\n        return list(__gl3_coset_gamma0_2_1(a0, a2, p))\\n    elif a0 < a1 and a1 == a2:\\n        return list(__gl3_coset_gamma0_1_2(a0, a2, p))\\n    elif a0 == a1 == a2:\\n        return [identity_matrix(ZZ, 3)]\\n    else:\\n        raise ValueError\\n\\n\\ndef __gl3_coset_gamma0_2_1(a1, a3, p):\\n    w23 = matrix([[1, 0, 0],\\n                  [0, 0, 1],\\n                  [0, 1, 0]])\\n    for m13 in range(p ** (a3 - a1 - 1)):\\n        for m23 in range(p ** (a3 - a1 - 1)):\\n            m = matrix([[1, 0, p * m13],\\n                        [0, 1, p * m23],\\n                        [0, 0, 1]])\\n            yield m\\n\\n    for m32 in range(p ** (a3 - a1)):\\n        m = matrix([[1, 0, 0],\\n                    [0, 1, 0],\\n                    [0, m32, 1]])\\n        for g in _gl2_coset_gamma0(a3 - a1, p):\\n            n = block_diagonal_matrix(g, matrix([[1]]))\\n            yield w23 * m * n\\n\\n\\ndef __gl3_coset_gamma0_1_2(a1, a2, p):\\n    w12 = matrix([[0, 1, 0],\\n                  [1, 0, 0],\\n                  [0, 0, 1]])\\n\\n    for m12 in range(p ** (a2 - a1 - 1)):\\n        for m13 in range(p ** (a2 - a1 - 1)):\\n            m = matrix([[1, p * m12, p * m13],\\n                        [0, 1, 0],\\n                        [0, 0, 1]])\\n            yield m\\n    for m21 in range(p ** (a2 - a1)):\\n        m = matrix([[1, 0, 0],\\n                    [m21, 1, 0],\\n                    [0, 0, 1]])\\n        for g in _gl2_coset_gamma0(a2 - a1, p):\\n            n = block_diagonal_matrix(matrix([[1]]), g)\\n            yield w12 * m * n\\n\\n\\ndef __gl3_coset_gamma0_distinct(a1, a2, a3, p):\\n\\n    w12 = matrix([[0, 1, 0],\\n                  [1, 0, 0],\\n                  [0, 0, 1]])\\n\\n    w23 = matrix([[1, 0, 0],\\n                  [0, 0, 1],\\n                  [0, 1, 0]])\\n\\n    w13 = matrix([[0, 0, 1],\\n                  [0, 1, 0],\\n                  [1, 0, 0]])\\n\\n    w123 = matrix([[0, 1, 0],\\n                   [0, 0, 1],\\n                   [1, 0, 0]])\\n\\n    w132 = matrix([[0, 0, 1],\\n                   [1, 0, 0],\\n                   [0, 1, 0]])\\n\\n    # w = 1\\n    for m12 in range(p ** (a2 - a1 - 1)):\\n        for m13 in range(p ** (a3 - a1 - 1)):\\n            for m23 in range(p ** (a3 - a2 - 1)):\\n                yield matrix([[1, p * m12, p * m13],\\n                              [0, 1, p * m23],\\n                              [0, 0, 1]])\\n    # w = (12)\\n    for m13 in range(p ** (a3 - a2 - 1)):\\n        for m21 in range(p ** (a2 - a1)):\\n            for m23 in range(p ** (a3 - a1 - 1)):\\n                m = matrix([[1, 0, p * m13],\\n                            [m21, 1, p * m23],\\n                            [0, 0, 1]])\\n                yield w12 * m\\n    # w = (23)\\n    for m12 in range(p ** (a3 - a1 - 1)):\\n        for m13 in range(p ** (a2 - a1 - 1)):\\n            for m32 in range(p ** (a3 - a2)):\\n                m = matrix([[1, p * m12, p * m13],\\n                            [0, 1, 0],\\n                            [0, m32, 1]])\\n                yield w23 * m\\n\\n    # w = (13)\\n    for m21 in range(p ** (a3 - a2)):\\n        for m31 in range(p ** (a3 - a1)):\\n            for m32 in range(p ** (a2 - a1)):\\n                m = matrix([[1, 0, 0],\\n                            [m21, 1, 0],\\n                            [m31, m32, 1]])\\n                yield w13 * m\\n\\n    # w = (123)\\n    for m21 in range(p ** (a3 - a1)):\\n        for m23 in range(p ** (a2 - a1 - 1)):\\n            for m31 in range(p ** (a3 - a2)):\\n                m = matrix([[1, 0, 0],\\n                            [m21, 1, p * m23],\\n                            [m31, 0, 1]])\\n                yield w123 * m\\n    # w = (132)\\n    for m12 in range(p ** (a3 - a2 - 1)):\\n        for m31 in range(p ** (a2 - a1)):\\n            for m32 in range(p ** (a3 - a1)):\\n                m = matrix([[1, p * m12, 0],\\n                            [0, 1, 0],\\n                            [m31, m32, 1]])\\n                yield w132 * m\\n\\n\\nclass HalfIntMatElement(object):\\n\\n    def __init__(self, T):\\n        '''\\n        :params T: half integral matrix of size 3 or a list\\n        '''\\n        if isinstance(T, list):\\n            a, b, c, d, e, f = [ZZ(x) for x in T]\\n            mat = matrix([[a, f / 2, e / 2],\\n                          [f / 2, b, d / 2],\\n                          [e / 2, d / 2, c]])\\n        else:\\n            mat = T\\n        self.__entries = tuple(mat.list())\\n\\n    def __eq__(self, other):\\n        if isinstance(other, HalfIntMatElement):\\n            return self.__entries == other.__entries\\n        else:\\n            raise NotImplementedError\\n\\n    def __repr__(self):\\n        return self.T.__repr__()\\n\\n    def __hash__(self):\\n        return hash(self.__entries)\\n\\n    @property\\n    def T(self):\\n        return matrix(3, self.__entries)\\n\\n    def right_action(self, g):\\n        '''\\n        :param g: matrix of size n\\n        return self[g] (Siegel's notation)\\n        '''\\n        S = g.transpose() * self.T * g\\n        return HalfIntMatElement(S)\\n\\n    def satisfy_cong_condition_tp(self, p, alpha):\\n        '''\\n        Test if sum_{B mod D} exp(2pi T B D^(-1)) is zero, where D = diag(p^a1, p^a2, a^a3),\\n        a1, a2, a3 = alpha.\\n        '''\\n        return (all(ZZ(self.T[i, i]) % p ** alpha[i] == 0 for i in range(3)) and\\n                all(ZZ(self.T[i, j] * 2) % p ** alpha[i] == 0\\n                    for i in range(3) for j in range(i + 1, 3)))\\n\\n    def is_divisible_by(self, m):\\n        '''\\n        Test if self is divisible by m\\n        :param m: integer\\n        '''\\n        return _half_int_mat_is_div_by(self.T, m)\\n\\n    def __floordiv__(self, other):\\n        S = matrix(QQ, 3)\\n        for i in range(3):\\n            S[i, i] = ZZ(self.T[i, i]) // other\\n        for i in range(3):\\n            for j in range(i + 1, 3):\\n                S[i, j] = S[j, i] = (ZZ(self.T[i, j] * 2) // other) / 2\\n        return HalfIntMatElement(S)\\n\\n\\ndef alpha_list(dl):\\n    '''\\n    Return a list of (a0, a1, a2) with 0 <= a0 <= a1 <= a2 <= dl\\n    '''\\n    return [(a0, a1, a2) for a0 in range(dl + 1)\\n            for a1 in range(a0, dl + 1) for a2 in range(a1, dl + 1)]\\n\\n\\ndef tp_action_fourier_coeff(p, T, F):\\n    '''\\n    Return the Tth Fourier coefficient of F|T(p), where F is a modular form.\\n    :param p: a prime number\\n    :param T: a half integral matrix or an instance of HalfIntMatElement\\n    :param F: a dictionary or a Siegel modular form of degree 3\\n    '''\\n    p = ZZ(p)\\n    return _action_fc_base(tp_action_fc_alist(p, T), F, T)\\n\\n\\ndef tp2_action_fourier_coeff(p, i, T, F):\\n    '''\\n    Similar to tp_action_fourier_coeff for T_i(p^2).\\n    '''\\n    p = ZZ(p)\\n    return _action_fc_base(tp2_action_fc_alist(p, T, i), F, T)\\n\\n\\ndef _action_fc_base(ls, F, T):\\n    if not isinstance(T, HalfIntMatElement):\\n        T = HalfIntMatElement(T)\\n    res = 0\\n    for s, a, g in ls:\\n        res = a * F[s].left_action(g) + res\\n    return res\\n\\n\\ndef hecke_eigenvalue_tp(p, F, T=None):\\n    '''\\n    p, F, T: same as aruments of tp_action_fourier_coeff.\\n    Assuming F is an eigenform, return the eigenvalue for T(p),\\n    T is used for the computation of Fourier coefficients.\\n    If T is omitted, T will be set to\\n    matrix([[1, 1/2, 1/2], [1/2, 1, 1/2], [1/2, 1/2, 1]]).\\n    '''\\n    return _hecke_eigenvalue_base(lambda s: tp_action_fourier_coeff(p, s, F), F, T=T)\\n\\n\\ndef hecke_eigenvalue_tp2(p, i, F, T=None):\\n    '''\\n    Similar to hecke_eigenvalue_tp for T(p^2).\\n    '''\\n    return _hecke_eigenvalue_base(lambda s: tp2_action_fourier_coeff(p, i, s, F), F, T=T)\\n\\n\\ndef spinor_l_euler_factor(p, F, t=None, T=None):\\n    '''\\n    F: a dict or Siegel modular form of degree 3.\\n    Return a polynomial G(t) of degree 8, s.t.\\n    G(p^(-s))^(-1) is the p-Euler factor of the spinor L function of F.\\n    '''\\n    p = ZZ(p)\\n    if t is None:\\n        t = PolynomialRing(QQ, 1, names='t', order=\\\"neglex\\\").gens()[0]\\n    c = {}\\n    tp = hecke_eigenvalue_tp(p, F, T=T)\\n    tpp1, tpp2, tpp3 = [hecke_eigenvalue_tp2(p, i, F, T=T) for i in [1, 2, 3]]\\n    c[0] = ZZ(1)\\n    c[1] = tp\\n    c[2] = p * (tpp1 + (p**2 + 1) * tpp2 + (p**2 + 1)**2 * tpp3)\\n    c[3] = p**3 * tp * (tpp2 + tpp3)\\n    c[4] = p**6 * (tp**2 * tpp3 + tpp2**2 - 2 * p * tpp1 * tpp3 -\\n                   2 * (p - 1) * tpp2 * tpp3 -\\n                   (p**6 + 2 * p**5 + 2 * p**3 + 2 * p - 1) * tpp3**2)\\n    c[5] = p**6 * tpp3 * c[3]\\n    c[6] = p**12 * tpp3 ** 2 * c[2]\\n    c[7] = p**18 * tpp3 ** 3 * c[1]\\n    c[8] = p**24 * tpp3 ** 4\\n    return sum((-1)**k * v * t**k for k, v in c.items())\\n\\n\\ndef rankin_convolution_degree1(f, g, p, name=None):\\n    u'''\\n    f, g: primitive forms of degree 1 and level 1.\\n    Return p-euler factor of the Rankin convolution of f and g as\\n    a polynomial.\\n    '''\\n    k1 = f.weight()\\n    k2 = g.weight()\\n    ap = f[p]\\n    bp = g[p]\\n    t = PolynomialRing(QQ, 1, names='t' if name is None else name,\\n                       order=\\\"neglex\\\").gens()[0]\\n    return (1 - ap * bp * t +\\n            (ap**2 * p**(k2 - 1) + bp**2 * p**(k1 - 1) - 2 * p**(k1 + k2 - 2)) * t**2 -\\n            ap * bp * p**(k1 + k2 - 2) * t**3 + p**(2 * (k1 + k2 - 2)) * t**4)\\n\\n\\ndef _hecke_eigenvalue_base(fc_func, F, T=None):\\n    if T is None:\\n        T = HalfIntMatElement(matrix([[ZZ(1), ZZ(1) / ZZ(2), ZZ(1) / ZZ(2)],\\n                                      [ZZ(1) / ZZ(2), ZZ(1), ZZ(1) / ZZ(2)],\\n                                      [ZZ(1) / ZZ(2), ZZ(1) / ZZ(2), ZZ(1)]]))\\n    if not isinstance(T, HalfIntMatElement):\\n        T = HalfIntMatElement(T)\\n    v1 = fc_func(T).vector\\n    v = F[T].vector\\n    if v == 0:\\n        raise ZeroDivisionError\\n    else:\\n        i = next(i for i in range(len(v)) if v[i] != 0)\\n        return v1[i] / v[i]\\n\\n\\n@cached_function\\ndef tp_action_fc_alist(p, T):\\n    '''\\n    return a list of tuples (S, a, g) s.t.\\n    S: an instance of HalfIntMatElement\\n    a: integer\\n    g: 3 by 3 matrix s.t.\\n    F|T(p) = sum(a rho(g) F[S] | (a, g, S)).\\n    '''\\n    res1 = []\\n    for alpha in alpha_list(1):\\n        D = diagonal_matrix([p ** a for a in alpha])\\n        for V in _gl3_coset_gamma0(alpha, p):\\n            M = D * V\\n            S = T.right_action(M.transpose())\\n            if S.is_divisible_by(p):\\n                S = S // p\\n                if S.satisfy_cong_condition_tp(p, alpha):\\n                    # p**(-6) and p in the third item are for normalization.\\n                    res1.append(\\n                        (S, p ** (-6) * mul(p ** alpha[i] for i in range(3) for j in range(i, 3)),\\n                         M ** (-1) * p))\\n    return __convert_reduced_nonisom_matrices(res1)\\n\\n\\ndef __convert_reduced_nonisom_matrices(alst):\\n    red_res = []\\n    for s, a, g in alst:\\n        u = _minkowski_reduction_transform_matrix(s.T)\\n        t = s.right_action(u)\\n        red_res.append((t, a, g * u.transpose() ** (-1)))\\n\\n    non_isoms = []\\n\\n    for s, a, g in red_res:\\n        q = QuadraticForm(ZZ, 2 * s.T)\\n        u = None\\n        for t, _, _ in non_isoms:\\n            q1 = QuadraticForm(ZZ, 2 * t.T)\\n            if q.det() == q1.det():\\n                u = q.is_globally_equivalent_to(q1, return_matrix=True)\\n                if u and u.transpose() * q.Gram_matrix_rational() * u == q1.Gram_matrix_rational():\\n                    break\\n        if u:\\n            non_isoms.append((s.right_action(u), a, g * u.transpose() ** (-1)))\\n        else:\\n            non_isoms.append((s, a, g))\\n    return non_isoms\\n\\n\\n@cached_function\\ndef tp2_action_fc_alist(p, T, i):\\n    '''\\n    similar to tp_action_fc_alist for T_i(p^2) for i = 0, 1, 2, 3.\\n    '''\\n    res1 = []\\n\\n    for alpha in alpha_list(2):\\n        D = diagonal_matrix([p ** a for a in alpha])\\n        for V in _gl3_coset_gamma0(alpha, p):\\n            M = D * V\\n            S = T.right_action(M.transpose())\\n            if S.is_divisible_by(p ** 2):\\n                S = S // (p ** 2)\\n                res1.append((S, p ** (-12) * _expt_sum(S, p, alpha, i),\\n                             M ** (-1) * p ** 2))\\n\\n    return __convert_reduced_nonisom_matrices([(a, b, c) for a, b, c in res1 if b != 0])\\n\\n\\ndef _nearest_integer(x):\\n    r = floor(x)\\n    if x - r > 0.5:\\n        return r + 1\\n    else:\\n        return r\\n\\n\\ndef _gaussian_reduction(b1, b2, S):\\n    '''\\n    b1, b2: vectors of length 3\\n    S: symmetric matrix of size 3\\n    '''\\n    while True:\\n        nb1 = b1 * S * b1\\n        nb2 = b2 * S * b2\\n        if nb2 < nb1:\\n            b1, b2 = b2, b1\\n        x = (b2 * S * b1) / (b1 * S * b1)\\n        r = _nearest_integer(x)\\n        a = b2 - r * b1\\n        if a * S * a >= b2 * S * b2:\\n            return (b1, b2)\\n        else:\\n            b1, b2 = a, b1\\n\\n\\ndef _sym_mat_gen(p, n):\\n    if n == 1:\\n        for a in range(p):\\n            yield matrix([[a]])\\n    else:\\n        for s in _sym_mat_gen(p, n - 1):\\n            ls = [range(p) for _ in range(n)]\\n            for a in itertools.product(*ls):\\n                v = matrix([a[:-1]])\\n                yield block_matrix([[s, v.transpose()], [v, matrix([[a[-1]]])]])\\n\\n\\ndef _gen_gauss_sum_direct_way(N, p, r):\\n    res = 0\\n    K = CyclotomicField(p)\\n    zeta = K.gen()\\n    for S in _sym_mat_gen(p, N.ncols()):\\n        if S.change_ring(FiniteField(p)).rank() == r:\\n            res += zeta ** ((N * S).trace())\\n    try:\\n        return QQ(res)\\n    except TypeError:\\n        return res\\n\\n\\ndef _generalized_gauss_sum(N, p, r):\\n    if r == 0:\\n        return 1\\n    if p == 2:\\n        return _gen_gauss_sum_direct_way(N, p, r)\\n    else:\\n        N_mp = N.change_ring(FiniteField(p))\\n        d, _, v = N_mp.smith_form()\\n        t = d.rank()\\n        N1 = (v.transpose() * N_mp *\\n              v).matrix_from_rows_and_columns(range(t), range(t))\\n        eps = kronecker_symbol(N1.det(), p)\\n        return _gen_gauss_sum_non_dyadic(p, eps, N.ncols(), t, r)\\n\\n\\ndef _half_int_mat_is_div_by(S, m):\\n    n = S.ncols()\\n    return (all(ZZ(S[i, i]) % m == 0 for i in range(n)) and\\n            all(ZZ(2 * S[i, j]) % m == 0 for i in range(n) for j in range(i + 1, n)))\\n\\n\\n@cached_function\\ndef _gen_gauss_sum_non_dyadic(p, eps, n, t, r):\\n    '''\\n    cf. H. Saito, a generalization of Gauss sums\\n    '''\\n\\n    def parenthesis_prod(a, b, m):\\n        if m == 0:\\n            return 1\\n        else:\\n            return mul(1 - a * b ** i for i in range(m))\\n\\n    if (n - t) % 2 == 0:\\n        m = (n - t) // 2\\n    else:\\n        m = (n - t + 1) // 2\\n\\n    if n == r:\\n        if n % 2 == 1:\\n            return ((-1) ** ((n - 2 * m + 1) // 2) * p ** ((n ** 2 + (2 * m) ** 2 - 1) // 4) *\\n                    parenthesis_prod(p ** (-1), p ** (-2), m))\\n        elif n % 2 == t % 2 == 0:\\n            return ((-kronecker_symbol(-1, p)) ** ((n - 2 * m) // 2) *\\n                    eps * p ** ((n ** 2 + (2 * m + 1) ** 2 - 1) // 4) *\\n                    parenthesis_prod(p ** (-1), p ** (-2), m))\\n        else:\\n            return 0\\n    else:\\n        diag = [1 for _ in range(t)]\\n        if eps == -1:\\n            diag[-1] = least_quadratic_nonresidue(p)\\n        diag = diag + [0 for _ in range(n - t)]\\n        N = diagonal_matrix(diag).change_ring(FiniteField(p))\\n        return _gen_gauss_sum_direct_way(N, p, r)\\n\\n\\ndef _expt_sum(S, p, alpha, i):\\n    '''\\n    Return the exponential sum in Miyawaki's paper, where alpha[-1] <= 2, for T_i(p^2).\\n    '''\\n    a, b, c = [alpha.count(_i) for _i in range(3)]\\n    S33 = S.T.matrix_from_rows_and_columns(range(a + b, 3), range(a + b, 3))\\n    S22 = S.T.matrix_from_rows_and_columns(range(a, a + b), range(a, a + b))\\n    S32 = S.T.matrix_from_rows_and_columns(range(a + b, 3), range(a))\\n\\n    if c > 0 and not _half_int_mat_is_div_by(S33, p ** 2):\\n        return 0\\n    if c > 0 and b > 0 and any(x % p != 0 for x in (S32 * ZZ(2)).change_ring(ZZ).list()):\\n        return 0\\n\\n    if b == 0 and a + c == 3 - i:\\n        return p ** (c * (c + 1))\\n    elif b == 0:\\n        return 0\\n    else:\\n        return p ** (c * (c + 1)) * p ** (b * c) * _generalized_gauss_sum(S22, p, b - i)\\n\\n\\ndef _minkowski_reduction(b1, b2, b3, S):\\n\\n    def inner_prod(x, y):\\n        return x * S * y\\n\\n    while True:\\n        b1, b2, b3 = sorted([b1, b2, b3], key=lambda b: b * S * b)\\n\\n        b1, b2 = _gaussian_reduction(b1, b2, S)\\n\\n        b11 = inner_prod(b1, b1)\\n        b12 = inner_prod(b1, b2)\\n        b13 = inner_prod(b1, b3)\\n        b22 = inner_prod(b2, b2)\\n        b23 = inner_prod(b2, b3)\\n        b33 = inner_prod(b3, b3)\\n\\n        y1 = - (b13 / b11 - b12 * b23 / (b11 * b22)) / \\\\\\n            (1 - b12 ** 2 / (b11 * b22))\\n        y2 = - (b23 / b22 - b12 * b13 / (b11 * b22)) / \\\\\\n            (1 - b12 ** 2 / (b11 * b22))\\n\\n        # Find integers x1, x2 so that norm(b3 + x2 * b2 + x1 * b1) is minimal.\\n        a_norms_alst = []\\n\\n        for x1 in [floor(y1), ceil(y1)]:\\n            for x2 in [floor(y2), ceil(y2)]:\\n                a = b3 + x2 * b2 + x1 * b1\\n                a_norms_alst.append((x1, x2, a, inner_prod(a, a)))\\n        _inner_prod_a = min(x[-1] for x in a_norms_alst)\\n        x1, x2, a, _ = next(x for x in a_norms_alst if x[-1] == _inner_prod_a)\\n\\n        if _inner_prod_a >= b33:\\n            # Change sings of b1, b2, b3 and terminate the alogrithm\\n            sngs = [sgn(b12), sgn(b13), sgn(b23)]\\n            bs = [b1, b2, b3]\\n            try:\\n                # If b12, b13 or b23 is zero, change sgns of b1, b2, b3 so that\\n                # b12, b13, b23 >= 0.\\n                zero_i = sngs.index(0)\\n                set_ls = [set([1, 2]), set([1, 3]), set([2, 3])]\\n                t = set_ls[zero_i]\\n                _other = [x for x in [1, 2, 3] if x not in t][0]\\n                for x in t:\\n                    i = set_ls.index(set([x, _other]))\\n                    if sngs[i] < 0:\\n                        bs[x - 1] *= -1\\n                b1, b2, b3 = bs\\n            except ValueError:\\n                # Else change sgns so that b12, b13 > 0\\n                if b12 < 0:\\n                    b2 = -b2\\n                if b13 < 0:\\n                    b3 = -b3\\n            return (b1, b2, b3)\\n        else:\\n            b3 = a\\n\\n\\ndef _minkowski_reduction_transform_matrix(S):\\n    '''\\n    Return a unimodular matrix u such that u^t * S * u is reduced in Minkowski's sense.\\n    '''\\n    b1, b2, b3 = identity_matrix(QQ, 3).columns()\\n    c1, c2, c3 = _minkowski_reduction(b1, b2, b3, S)\\n    return matrix([c1, c2, c3]).transpose()\\n\",\"line\":52,\"column\":41,\"path\":\"/home/sho/work/sage_packages/e8theta_degree3/hecke_module.py\"}}"

The file contains a multibyte string "∧" and anaconda-mode converts it to "\342\210\247".

Sho Takemori


2016-07-31 23:31 GMT+09:00 Eli Zaretskii <eliz@gnu.org>:
> From: Sho Takemori <stakemorii@gmail.com>
> Date: Sun, 31 Jul 2016 17:26:37 +0900
>
> I got an error "error in process sentinel: url-http-create-request: Multibyte text in HTTP request" when I visited a
> Python file which contains a multibyte character with `anaconda-eldoc-mode' turned on.

That file name should have been encoded by the time it is passed to
url-http.el, so the problem should not have happened, because encoded
strings are unibyte strings.

> At first, I thought this was a bug of anaconda-mode. So I opened an issue in github
> (https://github.com/proofit404/anaconda-mode/issues/189).
>
> I guess `(= (string-bytes request) (length request))` in `url-http-create-request' should be `(= (string-bytes
> url-http-data) (length url-http-data))`, because `(= (string-bytes request) (length request))` may be `nil' even if
> `(= (string-bytes url-http-data) (length url-http-data))` is `t'.

I don't think I agree in general: all the strings that are used by
url-http-create-request should be unibyte strings.  if they all are
unibyte strings, then I think the situation you describe should not
happen.  However, you didn't provide enough details to analyze the
situation, so perhaps I'm missing something.  Could you please show
all the details, specifically, what were the values of the various
variables used by url-http-create-request to generate the request?
For each value that is a string, please also tell whether it's a
unibyte or a multibyte string.

Thanks.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]