[pypy-commit] pypy py3.3: Add _ssl.RAND_bytes

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82016:9a47d88b9973
Date: 2016-01-31 22:29 +0100
http://bitbucket.org/pypy/pypy/changeset/9a47d88b9973/

Log:Add _ssl.RAND_bytes

diff --git a/pypy/module/_ssl/__init__.py b/pypy/module/_ssl/__init__.py
--- a/pypy/module/_ssl/__init__.py
+++ b/pypy/module/_ssl/__init__.py
@@ -43,8 +43,8 @@
 
 if HAVE_OPENSSL_RAND:
 Module.interpleveldefs['RAND_add'] = "interp_ssl.RAND_add"
-Module.interpleveldefs['RAND_bytes'] = "space.w_None"  # so far
-Module.interpleveldefs['RAND_pseudo_bytes'] = "space.w_None"  # so 
far
+Module.interpleveldefs['RAND_bytes'] = "interp_ssl.RAND_bytes"
+Module.interpleveldefs['RAND_pseudo_bytes'] = 
"interp_ssl.RAND_pseudo_bytes"
 Module.interpleveldefs['RAND_status'] = "interp_ssl.RAND_status"
 Module.interpleveldefs['RAND_egd'] = "interp_ssl.RAND_egd"
 
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -237,6 +237,43 @@
 with rffi.scoped_str2charp(string) as buf:
 libssl_RAND_add(buf, len(string), entropy)
 
+def _RAND_bytes(space, n, pseudo):
+if n < 0:
+raise OperationError(space.w_ValueError, space.wrap(
+"num must be positive"))
+
+with rffi.scoped_alloc_buffer(n) as buf:
+if pseudo:
+ok = libssl_RAND_pseudo_bytes(
+rffi.cast(rffi.UCHARP, buf.raw), n)
+if ok == 0 or ok == 1:
+return space.newtuple([
+space.wrapbytes(buf.str(n)),
+space.wrap(ok == 1),
+])
+else:
+ok = libssl_RAND_bytes(
+rffi.cast(rffi.UCHARP, buf.raw), n)
+if ok == 1:
+return space.wrapbytes(buf.str(n))
+
+raise ssl_error(space, "", errcode=libssl_ERR_get_error())
+
+@unwrap_spec(n=int)
+def RAND_bytes(space, n):
+"""RAND_bytes(n) -> bytes
+
+Generate n cryptographically strong pseudo-random bytes."""
+return _RAND_bytes(space, n, pseudo=False)
+
+@unwrap_spec(n=int)
+def RAND_pseudo_bytes(space, n):
+"""RAND_pseudo_bytes(n) -> (bytes, is_cryptographic)
+
+Generate n pseudo-random bytes. is_cryptographic is True if the bytes
+generated are cryptographically strong."""
+return _RAND_bytes(space, n, pseudo=True)
+
 def RAND_status(space):
 """RAND_status() -> 0 or 1
 
diff --git a/pypy/module/_ssl/test/test_ssl.py 
b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -48,6 +48,16 @@
 raises(TypeError, _ssl.RAND_add, "xyz", "zyx")
 _ssl.RAND_add("xyz", 1.2345)
 
+def test_RAND_bytes(self):
+import _ssl
+b = _ssl.RAND_bytes(3)
+assert type(b) is bytes
+assert len(b) == 3
+b, ok = _ssl.RAND_pseudo_bytes(3)
+assert type(b) is bytes
+assert len(b) == 3
+assert ok is True or ok is False
+
 def test_RAND_status(self):
 import _ssl
 if not hasattr(_ssl, "RAND_status"):
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -311,6 +311,8 @@
 
 if HAVE_OPENSSL_RAND:
 ssl_external('RAND_add', [rffi.CCHARP, rffi.INT, rffi.DOUBLE], lltype.Void)
+ssl_external('RAND_bytes', [rffi.UCHARP, rffi.INT], rffi.INT)
+ssl_external('RAND_pseudo_bytes', [rffi.UCHARP, rffi.INT], rffi.INT)
 ssl_external('RAND_status', [], rffi.INT)
 if HAVE_OPENSSL_RAND_EGD:
 ssl_external('RAND_egd', [rffi.CCHARP], rffi.INT)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: For some reason this chunk was not copied from CPython 3.3

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82015:b28c0f7ae8f3
Date: 2016-01-31 21:27 +0100
http://bitbucket.org/pypy/pypy/changeset/b28c0f7ae8f3/

Log:For some reason this chunk was not copied from CPython 3.3

diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/_codecs_tw.c 
b/pypy/module/_multibytecodec/src/cjkcodecs/_codecs_tw.c
--- a/pypy/module/_multibytecodec/src/cjkcodecs/_codecs_tw.c
+++ b/pypy/module/_multibytecodec/src/cjkcodecs/_codecs_tw.c
@@ -55,7 +55,7 @@
 TRYMAP_DEC(big5, **outbuf, c, IN2) {
 NEXT(2, 1)
 }
-else return 2;
+else return 1;
 }
 
 return 0;
@@ -109,7 +109,7 @@
 
 TRYMAP_DEC(cp950ext, **outbuf, c, IN2);
 else TRYMAP_DEC(big5, **outbuf, c, IN2);
-else return 2;
+else return 1;
 
 NEXT(2, 1)
 }
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: Pickle support for itertools.islice

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82013:a5416d54ea4e
Date: 2016-01-31 21:11 +0100
http://bitbucket.org/pypy/pypy/changeset/a5416d54ea4e/

Log:Pickle support for itertools.islice

diff --git a/pypy/module/itertools/interp_itertools.py 
b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -404,6 +404,15 @@
 if num <= 0:
 break
 
+def descr_reduce(self, space):
+return space.newtuple([
+space.type(self),
+space.newtuple([self.iterable,
+space.wrap(self.start),
+space.wrap(self.stop),
+space.wrap(self.ignore + 1)]),
+])
+
 def W_ISlice___new__(space, w_subtype, w_iterable, w_startstop, args_w):
 r = space.allocate_instance(W_ISlice, w_subtype)
 r.__init__(space, w_iterable, w_startstop, args_w)
@@ -414,6 +423,7 @@
 __new__  = interp2app(W_ISlice___new__),
 __iter__ = interp2app(W_ISlice.iter_w),
 __next__ = interp2app(W_ISlice.next_w),
+__reduce__ = interp2app(W_ISlice.descr_reduce),
 __doc__  = """Make an iterator that returns selected elements from the
 iterable.  If start is non-zero, then elements from the iterable
 are skipped until start is reached. Afterward, elements are
diff --git a/pypy/module/itertools/test/test_itertools.py 
b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -988,6 +988,11 @@
 assert list(op(testIntermediate)) == [
 (0,1,3), (0,2,3), (1,2,3)]
 
+def test_islice_pickle(self):
+import itertools, pickle
+it = itertools.islice(range(100), 10, 20, 3)
+assert list(pickle.loads(pickle.dumps(it))) == 
list(range(100)[10:20:3])
+
 def test_cycle_pickle(self):
 import itertools, pickle
 c = itertools.cycle('abc')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: unicodedata: add tables for special_casing.

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82020:c9f92e754efd
Date: 2016-02-01 00:26 +0100
http://bitbucket.org/pypy/pypy/changeset/c9f92e754efd/

Log:unicodedata: add tables for special_casing.

diff --git a/rpython/rlib/unicodedata/SpecialCasing-5.2.0.txt 
b/rpython/rlib/unicodedata/SpecialCasing-5.2.0.txt
new file mode 100644
--- /dev/null
+++ b/rpython/rlib/unicodedata/SpecialCasing-5.2.0.txt
@@ -0,0 +1,273 @@
+# SpecialCasing-5.2.0.txt
+# Date: 2009-09-22, 23:25:59 GMT [MD]
+#
+# Unicode Character Database
+# Copyright (c) 1991-2009 Unicode, Inc.
+# For terms of use, see http://www.unicode.org/terms_of_use.html
+# For documentation, see http://www.unicode.org/reports/tr44/
+#
+# Special Casing Properties
+#
+# This file is a supplement to the UnicodeData file.
+# It contains additional information about the casing of Unicode characters.
+# (For compatibility, the UnicodeData.txt file only contains case mappings for
+# characters where they are 1-1, and independent of context and language.
+# For more information, see the discussion of Case Mappings in the Unicode 
Standard.
+#
+# All code points not listed in this file that do not have a simple case 
mappings
+# in UnicodeData.txt map to themselves.
+# 

+# Format
+# 

+# The entries in this file are in the following machine-readable format:
+#
+# ;  ;  ;  ; ( ;)? # 
+#
+# , , , and  provide character values in hex. If 
there is more
+# than one character, they are separated by spaces. Other than as used to 
separate 
+# elements, spaces are to be ignored.
+#
+# The  is optional. Where present, it consists of one or more 
language IDs
+# or contexts, separated by spaces. In these conditions:
+# - A condition list overrides the normal behavior if all of the listed 
conditions are true.
+# - The context is always the context of the characters in the original string,
+#   NOT in the resulting string.
+# - Case distinctions in the condition list are not significant.
+# - Conditions preceded by "Not_" represent the negation of the condition.
+# The condition list is not represented in the UCD as a formal property.
+#
+# A language ID is defined by BCP 47, with '-' and '_' treated equivalently.
+#
+# A context for a character C is defined by Section 3.13 Default Case 
+# Operations, of The Unicode Standard, Version 5.0.
+# (This is identical to the context defined by Unicode 4.1.0,
+#  as specified in http://www.unicode.org/versions/Unicode4.1.0/)
+#
+# Parsers of this file must be prepared to deal with future additions to this 
format:
+#  * Additional contexts
+#  * Additional fields
+# 

+# @missing ..10; ; ; 
+# 

+# Unconditional mappings
+# 

+
+# The German es-zed is special--the normal mapping is to SS.
+# Note: the titlecase should never occur in practice. It is equal to 
titlecase(uppercase())
+
+00DF; 00DF; 0053 0073; 0053 0053; # LATIN SMALL LETTER SHARP S
+
+# Preserve canonical equivalence for I with dot. Turkic is handled below.
+
+0130; 0069 0307; 0130; 0130; # LATIN CAPITAL LETTER I WITH DOT ABOVE
+
+# Ligatures
+
+FB00; FB00; 0046 0066; 0046 0046; # LATIN SMALL LIGATURE FF
+FB01; FB01; 0046 0069; 0046 0049; # LATIN SMALL LIGATURE FI
+FB02; FB02; 0046 006C; 0046 004C; # LATIN SMALL LIGATURE FL
+FB03; FB03; 0046 0066 0069; 0046 0046 0049; # LATIN SMALL LIGATURE FFI
+FB04; FB04; 0046 0066 006C; 0046 0046 004C; # LATIN SMALL LIGATURE FFL
+FB05; FB05; 0053 0074; 0053 0054; # LATIN SMALL LIGATURE LONG S T
+FB06; FB06; 0053 0074; 0053 0054; # LATIN SMALL LIGATURE ST
+
+0587; 0587; 0535 0582; 0535 0552; # ARMENIAN SMALL LIGATURE ECH YIWN
+FB13; FB13; 0544 0576; 0544 0546; # ARMENIAN SMALL LIGATURE MEN NOW
+FB14; FB14; 0544 0565; 0544 0535; # ARMENIAN SMALL LIGATURE MEN ECH
+FB15; FB15; 0544 056B; 0544 053B; # ARMENIAN SMALL LIGATURE MEN INI
+FB16; FB16; 054E 0576; 054E 0546; # ARMENIAN SMALL LIGATURE VEW NOW
+FB17; FB17; 0544 056D; 0544 053D; # ARMENIAN SMALL LIGATURE MEN XEH
+
+# No corresponding uppercase precomposed character
+
+0149; 0149; 02BC 004E; 02BC 004E; # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE
+0390; 0390; 0399 0308 0301; 0399 0308 0301; # GREEK SMALL LETTER IOTA WITH 
DIALYTIKA AND TONOS
+03B0; 03B0; 03A5 0308 0301; 03A5 0308 0301; # GREEK SMALL LETTER UPSILON WITH 
DIALYTIKA AND TONOS
+01F0; 01F0; 004A 030C; 004A 030C; # LATIN SMALL LETTER J WITH CARON
+1E96; 1E96; 0048 0331; 0048 0331; # LATIN SMALL LETTER H WITH LINE BELOW
+1E97; 1E97; 0054 0308; 0054 0308; # LATIN SMALL LETTER T WITH DIAERESIS
+1E98; 1E98; 0057 030A; 0057 030A; # LATIN SMALL LETTER W WITH RING ABOVE
+1E99; 1E99; 0059 

[pypy-commit] pypy py3.3: Fix class name.

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82012:250569a438a0
Date: 2016-01-28 21:27 +0100
http://bitbucket.org/pypy/pypy/changeset/250569a438a0/

Log:Fix class name.

diff --git a/pypy/module/itertools/interp_itertools.py 
b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -275,7 +275,7 @@
 return space.wrap(r)
 
 W_FilterFalse.typedef = TypeDef(
-'itertools.ifilterfalse',
+'itertools.filterfalse',
 __new__  = interp2app(W_FilterFalse___new__),
 __iter__ = interp2app(W_FilterFalse.iter_w),
 __next__ = interp2app(W_FilterFalse.next_w),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: pickle support for itertools.takewhile and dropwhile.

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82011:6e3ddc38f7c0
Date: 2016-01-28 21:21 +0100
http://bitbucket.org/pypy/pypy/changeset/6e3ddc38f7c0/

Log:pickle support for itertools.takewhile and dropwhile.

diff --git a/pypy/module/itertools/interp_itertools.py 
b/pypy/module/itertools/interp_itertools.py
--- a/pypy/module/itertools/interp_itertools.py
+++ b/pypy/module/itertools/interp_itertools.py
@@ -148,7 +148,7 @@
 def __init__(self, space, w_predicate, w_iterable):
 self.space = space
 self.w_predicate = w_predicate
-self.iterable = space.iter(w_iterable)
+self.w_iterable = space.iter(w_iterable)
 self.stopped = False
 
 def iter_w(self):
@@ -158,7 +158,7 @@
 if self.stopped:
 raise OperationError(self.space.w_StopIteration, self.space.w_None)
 
-w_obj = self.space.next(self.iterable)  # may raise a w_StopIteration
+w_obj = self.space.next(self.w_iterable)  # may raise a w_StopIteration
 w_bool = self.space.call_function(self.w_predicate, w_obj)
 if not self.space.is_true(w_bool):
 self.stopped = True
@@ -166,6 +166,16 @@
 
 return w_obj
 
+def descr_reduce(self, space):
+return space.newtuple([
+space.type(self),
+space.newtuple([self.w_predicate, self.w_iterable]),
+space.wrap(self.stopped)
+])
+
+def descr_setstate(self, space, w_state):
+self.stopped = space.bool_w(w_state)
+
 def W_TakeWhile___new__(space, w_subtype, w_predicate, w_iterable):
 r = space.allocate_instance(W_TakeWhile, w_subtype)
 r.__init__(space, w_predicate, w_iterable)
@@ -177,6 +187,8 @@
 __new__  = interp2app(W_TakeWhile___new__),
 __iter__ = interp2app(W_TakeWhile.iter_w),
 __next__ = interp2app(W_TakeWhile.next_w),
+__reduce__ = interp2app(W_TakeWhile.descr_reduce),
+__setstate__ = interp2app(W_TakeWhile.descr_setstate),
 __doc__  = """Make an iterator that returns elements from the iterable 
as
 long as the predicate is true.
 
@@ -195,7 +207,7 @@
 def __init__(self, space, w_predicate, w_iterable):
 self.space = space
 self.w_predicate = w_predicate
-self.iterable = space.iter(w_iterable)
+self.w_iterable = space.iter(w_iterable)
 self.started = False
 
 def iter_w(self):
@@ -203,10 +215,10 @@
 
 def next_w(self):
 if self.started:
-w_obj = self.space.next(self.iterable)  # may raise w_StopIteration
+w_obj = self.space.next(self.w_iterable)  # may raise w_StopIter
 else:
 while True:
-w_obj = self.space.next(self.iterable)  # may raise w_StopIter
+w_obj = self.space.next(self.w_iterable)  # may raise 
w_StopIter
 w_bool = self.space.call_function(self.w_predicate, w_obj)
 if not self.space.is_true(w_bool):
 self.started = True
@@ -214,6 +226,16 @@
 
 return w_obj
 
+def descr_reduce(self, space):
+return space.newtuple([
+space.type(self),
+space.newtuple([self.w_predicate, self.w_iterable]),
+space.wrap(self.started)
+])
+
+def descr_setstate(self, space, w_state):
+self.started = space.bool_w(w_state)
+
 def W_DropWhile___new__(space, w_subtype, w_predicate, w_iterable):
 r = space.allocate_instance(W_DropWhile, w_subtype)
 r.__init__(space, w_predicate, w_iterable)
@@ -225,6 +247,8 @@
 __new__  = interp2app(W_DropWhile___new__),
 __iter__ = interp2app(W_DropWhile.iter_w),
 __next__ = interp2app(W_DropWhile.next_w),
+__reduce__ = interp2app(W_DropWhile.descr_reduce),
+__setstate__ = interp2app(W_DropWhile.descr_setstate),
 __doc__  = """Make an iterator that drops elements from the iterable 
as long
 as the predicate is true; afterwards, returns every
 element. Note, the iterator does not produce any output until the
diff --git a/pypy/module/itertools/test/test_itertools.py 
b/pypy/module/itertools/test/test_itertools.py
--- a/pypy/module/itertools/test/test_itertools.py
+++ b/pypy/module/itertools/test/test_itertools.py
@@ -836,12 +836,6 @@
 "usemodules": ['itertools', 'struct', 'binascii'],
 }
 
-def setup_class(cls):
-if cls.space.is_true(cls.space.appexec([], """():
-import sys; return sys.version_info < (2, 7)
-""")):
-py.test.skip("Requires Python 2.7")
-
 def test_compress(self):
 import itertools
 it = itertools.compress(['a', 'b', 'c'], [0, 1, 0])
@@ -1001,6 +995,16 @@
 assert list(itertools.islice(
 pickle.loads(pickle.dumps(c)), 10)) == list('bcabcabcab')
 
+def test_takewhile_pickle(self):
+data = [1, 2, 3, 0, 4, 5, 6]
+import itertools, pickle
+t = itertools.takewhile(bool, data)

[pypy-commit] pypy default: fix typo

2016-01-31 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r82017:8a7217a547e2
Date: 2016-01-31 18:37 +0100
http://bitbucket.org/pypy/pypy/changeset/8a7217a547e2/

Log:fix typo

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -942,7 +942,7 @@
 return False
 if w_set.length() == 0:
 return True
-# it's possible to have 0-lenght strategy that's not empty
+# it's possible to have 0-length strategy that's not empty
 if w_set.strategy is w_other.strategy:
 return self._issubset_unwrapped(w_set, w_other)
 if not self.may_contain_equal_elements(w_other.strategy):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: skip for msvc

2016-01-31 Thread mattip
Author: mattip 
Branch: 
Changeset: r82014:aa367ba93c8a
Date: 2016-01-31 23:03 +0200
http://bitbucket.org/pypy/pypy/changeset/aa367ba93c8a/

Log:skip for msvc

diff --git a/rpython/rtyper/tool/test/test_rffi_platform.py 
b/rpython/rtyper/tool/test/test_rffi_platform.py
--- a/rpython/rtyper/tool/test/test_rffi_platform.py
+++ b/rpython/rtyper/tool/test/test_rffi_platform.py
@@ -277,10 +277,14 @@
 assert not rffi_platform.has("x", "#include 
")
 
 def test_has_0002():
+if platform.name == 'msvc':
+py.test.skip('no m.lib in msvc')
 assert rffi_platform.has("pow", "#include ", libraries=["m"])
 
 def test_has_0003():
 """multiple libraries"""
+if platform.name == 'msvc':
+py.test.skip('no m.lib in msvc')
 assert rffi_platform.has("pow", "#include ", libraries=["m", "c"])
 
 def test_has_0004():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: Another test that needed a change for CPython3.3

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82022:f41f8a7c1fb8
Date: 2016-02-01 00:40 +0100
http://bitbucket.org/pypy/pypy/changeset/f41f8a7c1fb8/

Log:Another test that needed a change for CPython3.3

diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -729,7 +729,7 @@
 assert 'ababa'.count('aba') == 1
 
 def test_swapcase(self):
-assert '\xe4\xc4\xdf'.swapcase() == '\xc4\xe4\xdf'
+assert '\xe4\xc4\xdf'.swapcase() == '\xc4\xe4SS'
 
 def test_call_special_methods(self):
 # xxx not completely clear if these are implementation details or not
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.3: Fix unicode.capitalize() test to pass with CPython3.3,

2016-01-31 Thread amauryfa
Author: Amaury Forgeot d'Arc 
Branch: py3.3
Changeset: r82021:44aa48e4d16a
Date: 2016-02-01 00:31 +0100
http://bitbucket.org/pypy/pypy/changeset/44aa48e4d16a/

Log:Fix unicode.capitalize() test to pass with CPython3.3, and implement
it for PyPy. Probably not the fastest implementation...

diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -217,7 +217,7 @@
 # check that titlecased chars are lowered correctly
 # \u1ffc is the titlecased char
 assert ('\u1ff3\u1ff3\u1ffc\u1ffc'.capitalize() ==
-'\u1ffc\u1ff3\u1ff3\u1ff3')
+'\u03a9\u0399\u1ff3\u1ff3\u1ff3')
 # check with cased non-letter chars
 assert ('\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3'.capitalize() ==
 '\u24c5\u24e8\u24e3\u24d7\u24de\u24dd')
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -155,13 +155,16 @@
 return unicodedb.islinebreak(ord(ch))
 
 def _upper(self, ch):
-return unichr(unicodedb.toupper(ord(ch)))
+return u''.join([unichr(x) for x in
+ unicodedb.toupper_full(ord(ch))])
 
 def _lower(self, ch):
-return unichr(unicodedb.tolower(ord(ch)))
+return u''.join([unichr(x) for x in
+ unicodedb.tolower_full(ord(ch))])
 
 def _title(self, ch):
-return unichr(unicodedb.totitle(ord(ch)))
+return u''.join([unichr(x) for x in
+ unicodedb.totitle_full(ord(ch))])
 
 def _newlist_unwrapped(self, space, lst):
 return space.newlist_unicode(lst)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: duh, check the index first(!)

2016-01-31 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r82018:3fe07a7b1c13
Date: 2016-01-31 19:10 +0100
http://bitbucket.org/pypy/pypy/changeset/3fe07a7b1c13/

Log:duh, check the index first(!)

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -116,7 +116,7 @@
 
 def _find_map_attr(self, name, index):
 while isinstance(self, PlainAttribute):
-if name == self.name and index == self.index:
+if index == self.index and name == self.name:
 return self
 self = self.back
 return None
@@ -296,7 +296,7 @@
 new_obj._get_mapdict_map().add_attr(new_obj, self.name, self.index, 
w_value)
 
 def delete(self, obj, name, index):
-if name == self.name and index == self.index:
+if index == self.index and name == self.name:
 # ok, attribute is deleted
 if not self.ever_mutated:
 self.ever_mutated = True
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: this comment is outdated now

2016-01-31 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r82019:a71c1f3776a9
Date: 2016-01-31 19:11 +0100
http://bitbucket.org/pypy/pypy/changeset/a71c1f3776a9/

Log:this comment is outdated now

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -156,7 +156,6 @@
 jit.isconstant(name) and
 jit.isconstant(index))
 def add_attr(self, obj, name, index, w_value):
-# grumble, jit needs this
 attr = self._get_new_attr(name, index)
 oldattr = obj._get_mapdict_map()
 if not jit.we_are_jitted():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi embedding-pypy-win32: allow embedding tests to run on pypy win32

2016-01-31 Thread mattip
Author: mattip 
Branch: embedding-pypy-win32
Changeset: r2616:6b5048b944cf
Date: 2016-01-30 20:50 +0200
http://bitbucket.org/cffi/cffi/changeset/6b5048b944cf/

Log:allow embedding tests to run on pypy win32

diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -549,24 +549,25 @@
 if value not in lst:
 lst.append(value)
 #
-if '__pypy__' in sys.builtin_module_names:
-if hasattr(sys, 'prefix'):
-import os
-ensure('library_dirs', os.path.join(sys.prefix, 'bin'))
-pythonlib = "pypy-c"
+if sys.platform == "win32":
+# XXX pypy should not reuse the same import library name
+template = "python%d%d"
+if hasattr(sys, 'gettotalrefcount'):
+template += '_d'
 else:
-if sys.platform == "win32":
-template = "python%d%d"
-if hasattr(sys, 'gettotalrefcount'):
-template += '_d'
+if '__pypy__' in sys.builtin_module_names:
+if hasattr(sys, 'prefix'):
+import os
+ensure('library_dirs', os.path.join(sys.prefix, 'bin'))
+pythonlib = "pypy-c"
 else:
 template = "python%d.%d"
 if sysconfig.get_config_var('DEBUG_EXT'):
 template += sysconfig.get_config_var('DEBUG_EXT')
-pythonlib = (template %
-(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
-if hasattr(sys, 'abiflags'):
-pythonlib += sys.abiflags
+pythonlib = (template %
+(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+if hasattr(sys, 'abiflags'):
+pythonlib += sys.abiflags
 ensure('libraries', pythonlib)
 if sys.platform == "win32":
 ensure('extra_link_args', '/MANIFEST')
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -118,12 +118,18 @@
 def execute(self, name):
 path = self.get_path()
 env_extra = {'PYTHONPATH': prefix_pythonpath()}
-libpath = os.environ.get('LD_LIBRARY_PATH')
-if libpath:
-libpath = path + ':' + libpath
+if sys.platform == 'win32':
+_path = os.environ.get('PATH')
+# for libpypy-c.dll or Python27.dll
+_path += ';' + os.path.split(sys.executable)[0]
+env_extra['PATH'] = _path
 else:
-libpath = path
-env_extra['LD_LIBRARY_PATH'] = libpath
+libpath = os.environ.get('LD_LIBRARY_PATH')
+if libpath:
+libpath = path + ':' + libpath
+else:
+libpath = path
+env_extra['LD_LIBRARY_PATH'] = libpath
 print('running %r in %r' % (name, path))
 executable_name = name
 if sys.platform == 'win32':
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Issue #244: parse_type() calls the Parser logic but self._options used

2016-01-31 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2615:6b198bbbad9f
Date: 2016-01-31 16:29 +0100
http://bitbucket.org/cffi/cffi/changeset/6b198bbbad9f/

Log:Issue #244: parse_type() calls the Parser logic but self._options
used to be None, crashing in corner cases

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -220,7 +220,7 @@
 self._included_declarations = set()
 self._anonymous_counter = 0
 self._structnode2type = weakref.WeakKeyDictionary()
-self._options = None
+self._options = {}
 self._int_constants = {}
 self._recomplete = []
 self._uses_new_feature = None
@@ -374,7 +374,7 @@
 
 def _declare_function(self, tp, quals, decl):
 tp = self._get_type_pointer(tp, quals)
-if self._options['dllexport']:
+if self._options.get('dllexport'):
 tag = 'dllexport_python '
 elif self._inside_extern_python:
 tag = 'extern_python '
@@ -450,7 +450,7 @@
 prevobj, prevquals = self._declarations[name]
 if prevobj is obj and prevquals == quals:
 return
-if not self._options['override']:
+if not self._options.get('override'):
 raise api.FFIError(
 "multiple declarations of %s (for interactive usage, "
 "try cdef(xx, override=True))" % (name,))
@@ -729,7 +729,7 @@
 if isinstance(tp, model.StructType) and tp.partial:
 raise NotImplementedError("%s: using both bitfields and '...;'"
   % (tp,))
-tp.packed = self._options['packed']
+tp.packed = self._options.get('packed')
 if tp.completed:# must be re-completed: it is not opaque any more
 tp.completed = 0
 self._recomplete.append(tp)
diff --git a/testing/cffi0/backend_tests.py b/testing/cffi0/backend_tests.py
--- a/testing/cffi0/backend_tests.py
+++ b/testing/cffi0/backend_tests.py
@@ -1846,3 +1846,8 @@
 thread.start_new_thread(f, ())
 time.sleep(1.5)
 assert seen == ['init!', 'init done'] + 6 * [7]
+
+def test_sizeof_struct_directly(self):
+# only works with the Python FFI instances
+ffi = FFI(backend=self.Backend())
+assert ffi.sizeof("struct{int a;}") == ffi.sizeof("int")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Cast to PyObject* in PyString_GET_SIZE/AS_STRING.

2016-01-31 Thread devin.jeanpierre
Author: Devin Jeanpierre 
Branch: 
Changeset: r82010:f1c5a5f9e0b8
Date: 2016-01-31 02:58 -0800
http://bitbucket.org/pypy/pypy/changeset/f1c5a5f9e0b8/

Log:Cast to PyObject* in PyString_GET_SIZE/AS_STRING.

This way we accept PyStringObject*, much like CPython casts to
PyStringObject* in order to accept PyObject*.

diff --git a/pypy/module/cpyext/include/stringobject.h 
b/pypy/module/cpyext/include/stringobject.h
--- a/pypy/module/cpyext/include/stringobject.h
+++ b/pypy/module/cpyext/include/stringobject.h
@@ -7,8 +7,8 @@
 extern "C" {
 #endif
 
-#define PyString_GET_SIZE(op) PyString_Size(op)
-#define PyString_AS_STRING(op) PyString_AsString(op)
+#define PyString_GET_SIZE(op) PyString_Size((PyObject*)(op))
+#define PyString_AS_STRING(op) PyString_AsString((PyObject*)(op))
 
 typedef struct {
 PyObject_HEAD
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit