[pypy-commit] pypy unicode-utf8: hg merge default
arigo
pypy.commits at gmail.com
Thu Aug 24 05:44:54 EDT 2017
Author: Armin Rigo <arigo at tunes.org>
Branch: unicode-utf8
Changeset: r92242:367afaf4ad3a
Date: 2017-08-24 11:43 +0200
http://bitbucket.org/pypy/pypy/changeset/367afaf4ad3a/
Log: hg merge default
Manual merges may go wrong
diff too long, truncating to 2000 out of 88216 lines
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,6 +1,6 @@
syntax: glob
*.py[co]
-*.sw[po]
+*.sw[pon]
*~
.*.swp
.idea
@@ -8,6 +8,8 @@
.pydevproject
__pycache__
+.cache/
+.gdb_history
syntax: regexp
^testresult$
^site-packages$
@@ -23,16 +25,17 @@
^pypy/module/cpyext/test/.+\.manifest$
^pypy/module/test_lib_pypy/ctypes_tests/.+\.o$
^pypy/module/test_lib_pypy/ctypes_tests/_ctypes_test\.o$
-^pypy/module/cppyy/src/.+\.o$
-^pypy/module/cppyy/bench/.+\.so$
-^pypy/module/cppyy/bench/.+\.root$
-^pypy/module/cppyy/bench/.+\.d$
-^pypy/module/cppyy/src/.+\.errors$
-^pypy/module/cppyy/test/.+_rflx\.cpp$
-^pypy/module/cppyy/test/.+\.so$
-^pypy/module/cppyy/test/.+\.rootmap$
-^pypy/module/cppyy/test/.+\.exe$
-^pypy/module/cppyy/test/.+_cint.h$
+^pypy/module/_cppyy/src/.+\.o$
+^pypy/module/_cppyy/bench/.+\.so$
+^pypy/module/_cppyy/bench/.+\.root$
+^pypy/module/_cppyy/bench/.+\.d$
+^pypy/module/_cppyy/src/.+\.errors$
+^pypy/module/_cppyy/test/.+_rflx\.cpp$
+^pypy/module/_cppyy/test/.+\.so$
+^pypy/module/_cppyy/test/.+\.rootmap$
+^pypy/module/_cppyy/test/.+\.exe$
+^pypy/module/_cppyy/test/.+_cint.h$
+^pypy/module/_cppyy/.+/*\.pcm$
^pypy/module/test_lib_pypy/cffi_tests/__pycache__.+$
^pypy/doc/.+\.html$
^pypy/doc/config/.+\.rst$
@@ -49,6 +52,11 @@
^rpython/translator/goal/target.+-c$
^rpython/translator/goal/.+\.exe$
^rpython/translator/goal/.+\.dll$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/Makefile$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/config.guess$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/config.h$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/config.log$
+^rpython/rlib/rvmprof/src/shared/libbacktrace/config.status$
^pypy/goal/pypy-translation-snapshot$
^pypy/goal/pypy-c
^pypy/goal/.+\.exe$
@@ -60,6 +68,9 @@
^lib_pypy/ctypes_config_cache/_.+_cache\.py$
^lib_pypy/ctypes_config_cache/_.+_.+_\.py$
^lib_pypy/_libmpdec/.+.o$
+^lib_pypy/.+.c$
+^lib_pypy/.+.o$
+^lib_pypy/.+.so$
^pypy/doc/discussion/.+\.html$
^include/.+\.h$
^include/.+\.inl$
@@ -74,8 +85,7 @@
^rpython/doc/_build/.*$
^compiled
^.git/
-^.hypothesis/
+.hypothesis/
^release/
^rpython/_cache$
-pypy/module/cppyy/.+/*\.pcm
diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -34,3 +34,9 @@
050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1
0e2d9a73f5a1818d0245d75daccdbe21b2d5c3ef release-pypy2.7-v5.4.1
aff251e543859ce4508159dd9f1a82a2f553de00 release-pypy2.7-v5.6.0
+fa3249d55d15b9829e1be69cdf45b5a44cec902d release-pypy2.7-v5.7.0
+b16a4363e930f6401bceb499b9520955504c6cb0 release-pypy3.5-v5.7.0
+1aa2d8e03cdfab54b7121e93fda7e98ea88a30bf release-pypy2.7-v5.7.1
+2875f328eae2216a87f3d6f335092832eb031f56 release-pypy3.5-v5.7.1
+c925e73810367cd960a32592dd7f728f436c125c release-pypy2.7-v5.8.0
+a37ecfe5f142bc971a86d17305cc5d1d70abec64 release-pypy3.5-v5.8.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,5 @@
+#encoding utf-8
+
License
=======
@@ -37,14 +39,14 @@
Armin Rigo
Maciej Fijalkowski
- Carl Friedrich Bolz
+ Carl Friedrich Bolz-Tereick
Amaury Forgeot d'Arc
Antonio Cuni
+ Matti Picus
Samuele Pedroni
- Matti Picus
+ Ronan Lamy
Alex Gaynor
Philip Jenvey
- Ronan Lamy
Brian Kearns
Richard Plangger
Michael Hudson
@@ -55,12 +57,12 @@
Hakan Ardo
Benjamin Peterson
Anders Chrigstrom
+ Wim Lavrijsen
Eric van Riet Paap
- Wim Lavrijsen
Richard Emslie
Alexander Schremmer
+ Remi Meier
Dan Villiom Podlaski Christiansen
- Remi Meier
Lukas Diekmann
Sven Hager
Anders Lehmann
@@ -83,8 +85,8 @@
Lawrence Oluyede
Bartosz Skowron
Daniel Roberts
+ Adrien Di Mascio
Niko Matsakis
- Adrien Di Mascio
Alexander Hesse
Ludovic Aubry
Jacob Hallen
@@ -99,278 +101,288 @@
Vincent Legoll
Michael Foord
Stephan Diehl
+ Stefano Rivera
Stefan Schwarzer
+ Tomek Meka
Valentino Volonghi
- Tomek Meka
- Stefano Rivera
Patrick Maupin
Devin Jeanpierre
Bob Ippolito
Bruno Gola
David Malcolm
Jean-Paul Calderone
+ Squeaky
+ Edd Barrett
Timo Paulssen
- Edd Barrett
- Squeaky
Marius Gedminas
Alexandre Fayolle
Simon Burton
+ Nicolas Truessel
Martin Matusiak
- Nicolas Truessel
+ Laurence Tratt
+ Wenzhu Man
Konstantin Lopuhin
- Wenzhu Man
John Witulski
- Laurence Tratt
+ Greg Price
Ivan Sichmann Freitas
- Greg Price
Dario Bertini
+ Jeremy Thurgood
Mark Pearse
Simon Cross
- Jeremy Thurgood
+ Tobias Pape
Andreas Stührk
- Tobias Pape
Jean-Philippe St. Pierre
Guido van Rossum
Pavel Vinogradov
Paweł Piotr Przeradowski
+ William Leslie
+ marky1991
+ Ilya Osadchiy
+ Tobias Oberstein
Paul deGrandis
- Ilya Osadchiy
- marky1991
- Tobias Oberstein
+ Boris Feigin
+ Taavi Burns
Adrian Kuhn
- Boris Feigin
tav
- Taavi Burns
Georg Brandl
Bert Freudenberg
Stian Andreassen
Wanja Saatkamp
+ Mike Blume
+ Joannah Nanjekye
Gerald Klix
- Mike Blume
Oscar Nierstrasz
+ Rami Chowdhury
Stefan H. Muller
- Rami Chowdhury
+ Tim Felgentreff
Eugene Oden
+ Jeff Terrace
Henry Mason
Vasily Kuznetsov
Preston Timmons
David Ripton
- Jeff Terrace
- Tim Felgentreff
Dusty Phillips
Lukas Renggli
Guenter Jantzen
- William Leslie
+ Jasper Schulz
Ned Batchelder
+ Amit Regmi
Anton Gulenko
- Amit Regmi
- Ben Young
- Jasper Schulz
+ Sergey Matyunin
+ Andrew Chambers
Nicolas Chauvat
Andrew Durdin
- Andrew Chambers
- Sergey Matyunin
+ Ben Young
Michael Schneider
Nicholas Riley
Jason Chu
Igor Trindade Oliveira
Yichao Yu
+ Michael Twomey
Rocco Moretti
Gintautas Miliauskas
- Michael Twomey
Lucian Branescu Mihaila
anatoly techtonik
+ Dodan Mihai
+ Karl Bartel
Gabriel Lavoie
+ Jared Grubb
Olivier Dormond
- Jared Grubb
- Karl Bartel
Wouter van Heyst
+ Sebastian Pawluś
Brian Dorsey
Victor Stinner
Andrews Medina
- Sebastian Pawluś
- Stuart Williams
- Daniel Patrick
Aaron Iles
Toby Watson
+ Daniel Patrick
+ Stuart Williams
Antoine Pitrou
Christian Hudon
+ Justas Sadzevicius
+ Neil Shepperd
Michael Cheng
- Justas Sadzevicius
+ Mikael Schönenberg
+ Stanislaw Halik
+ Berkin Ilbeyi
Gasper Zejn
- Neil Shepperd
- Stanislaw Halik
- Mikael Schönenberg
- Berkin Ilbeyi
Faye Zhao
Elmo Mäntynen
- Jonathan David Riehl
Anders Qvist
Corbin Simpson
Chirag Jadwani
+ Jonathan David Riehl
Beatrice During
Alex Perry
+ p_zieschang at yahoo.de
+ Robert Zaremba
+ Alan McIntyre
+ Alexander Sedov
Vaibhav Sood
- Alan McIntyre
Reuben Cummings
- Alexander Sedov
- p_zieschang at yahoo.de
Attila Gobi
+ Alecsandru Patrascu
Christopher Pope
- Aaron Gallagher
+ Tristan Arthur
+ Christian Tismer
+ Dan Stromberg
+ Carl Meyer
Florin Papa
- Christian Tismer
- Marc Abramowitz
- Dan Stromberg
- Arjun Naik
+ Jens-Uwe Mager
Valentina Mukhamedzhanova
Stefano Parmesan
touilleMan
+ Marc Abramowitz
+ Arjun Naik
+ Aaron Gallagher
Alexis Daboville
- Jens-Uwe Mager
- Carl Meyer
+ Pieter Zieschang
Karl Ramm
- Pieter Zieschang
- Gabriel
Lukas Vacek
- Kunal Grover
- Andrew Dalke
+ Omer Katz
+ Jacek Generowicz
Sylvain Thenault
Jakub Stasiak
+ Stefan Beyer
+ Andrew Dalke
+ Alejandro J. Cura
+ Vladimir Kryachko
+ Gabriel
+ Mark Williams
+ Kunal Grover
Nathan Taylor
- Vladimir Kryachko
- Omer Katz
- Mark Williams
- Jacek Generowicz
- Alejandro J. Cura
+ Travis Francis Athougies
+ Yasir Suhail
+ Sergey Kishchenko
+ Martin Blais
+ Lutz Paelike
+ Ian Foote
+ Philipp Rustemeuer
+ Catalin Gabriel Manciu
Jacob Oscarson
- Travis Francis Athougies
Ryan Gonzalez
- Ian Foote
Kristjan Valur Jonsson
+ Lucio Torre
+ Richard Lancaster
+ Dan Buch
+ Lene Wagner
+ Tomo Cocoa
David Lievens
Neil Blakey-Milner
- Lutz Paelike
- Lucio Torre
+ Henrik Vendelbo
Lars Wassermann
- Philipp Rustemeuer
- Henrik Vendelbo
- Richard Lancaster
- Yasir Suhail
- Dan Buch
+ Ignas Mikalajunas
+ Christoph Gerum
Miguel de Val Borro
Artur Lisiecki
- Sergey Kishchenko
- Ignas Mikalajunas
- Alecsandru Patrascu
- Christoph Gerum
- Martin Blais
- Lene Wagner
- Catalin Gabriel Manciu
- Tomo Cocoa
- Kim Jin Su
- rafalgalczynski at gmail.com
Toni Mattis
- Amber Brown
+ Laurens Van Houtven
+ Bobby Impollonia
+ Roberto De Ioris
+ Jeong YunWon
+ Christopher Armstrong
+ Aaron Tubbs
+ Vasantha Ganesh K
+ Jason Michalski
+ Markus Holtermann
+ Andrew Thompson
+ Yusei Tahara
+ Ruochen Huang
+ Fabio Niephaus
+ Akira Li
+ Gustavo Niemeyer
+ Rafał Gałczyński
+ Logan Chien
Lucas Stadler
- Julian Berman
- Markus Holtermann
roberto at goyle
+ Matt Bogosian
Yury V. Zaytsev
- Anna Katrina Dominguez
- Bobby Impollonia
- Vasantha Ganesh K
- Andrew Thompson
florinpapa
- Yusei Tahara
- Aaron Tubbs
- Ben Darnell
- Roberto De Ioris
- Logan Chien
- Juan Francisco Cantero Hurtado
- Ruochen Huang
- Jeong YunWon
- Godefroid Chappelle
- Joshua Gilbert
- Dan Colish
- Christopher Armstrong
- Michael Hudson-Doyle
Anders Sigfridsson
Nikolay Zinov
- Jason Michalski
+ rafalgalczynski at gmail.com
+ Joshua Gilbert
+ Anna Katrina Dominguez
+ Kim Jin Su
+ Amber Brown
+ Nate Bragg
+ Ben Darnell
+ Juan Francisco Cantero Hurtado
+ Godefroid Chappelle
+ Julian Berman
+ Michael Hudson-Doyle
Floris Bruynooghe
- Laurens Van Houtven
- Akira Li
- Gustavo Niemeyer
Stephan Busemann
- Rafał Gałczyński
- Matt Bogosian
+ Dan Colish
timo
- Christian Muirhead
- Berker Peksag
- James Lan
Volodymyr Vladymyrov
- shoma hosaka
- Ben Mather
- Niclas Olofsson
- Matthew Miller
- Rodrigo Araújo
+ Daniel Neuhäuser
+ Flavio Percoco
halgari
- Boglarka Vezer
- Chris Pressey
- Buck Golemon
- Diana Popa
- Konrad Delong
- Dinu Gherman
+ Jim Baker
Chris Lambacher
coolbutuseless at gmail.com
+ Mike Bayer
+ Rodrigo Araújo
Daniil Yarancev
- Jim Baker
+ OlivierBlanvillain
+ Jonas Pfannschmidt
+ Zearin
+ Andrey Churin
Dan Crosta
- Nikolaos-Digenis Karagiannis
- James Robert
- Armin Ronacher
- Brett Cannon
- Donald Stufft
- yrttyr
- aliceinwire
- OlivierBlanvillain
- Dan Sanders
- Zooko Wilcox-O Hearn
+ reubano at gmail.com
+ Julien Phalip
+ Roman Podoliaka
+ Eli Stevens
+ Boglarka Vezer
+ PavloKapyshin
Tomer Chachamu
Christopher Groskopf
Asmo Soinio
- jiaaro
- Mads Kiilerich
Antony Lee
- Jason Madden
- Daniel Neuh�user
- reubano at gmail.com
- Yaroslav Fedevych
Jim Hunziker
- Markus Unterwaditzer
- Even Wiik Thomassen
- jbs
- squeaky
- soareschen
- Jonas Pfannschmidt
- Kurt Griffiths
- Mike Bayer
- Stefan Marr
- Flavio Percoco
- Kristoffer Kleine
+ shoma hosaka
+ Buck Golemon
+ Iraklis D.
+ JohnDoe
+ yrttyr
Michael Chermside
Anna Ravencroft
+ remarkablerocket
+ Petre Vijiac
+ Berker Peksag
+ Christian Muirhead
+ soareschen
+ Matthew Miller
+ Konrad Delong
+ Dinu Gherman
pizi
- remarkablerocket
- Andrey Churin
- Zearin
- Eli Stevens
- Tobias Diaz
- Julien Phalip
- Roman Podoliaka
+ James Robert
+ Armin Ronacher
+ Diana Popa
+ Mads Kiilerich
+ Brett Cannon
+ aliceinwire
+ Zooko Wilcox-O Hearn
+ James Lan
+ jiaaro
+ Markus Unterwaditzer
+ Kristoffer Kleine
+ Graham Markall
Dan Loewenherz
werat
+ Niclas Olofsson
+ Chris Pressey
+ Tobias Diaz
+ Nikolaos-Digenis Karagiannis
+ Kurt Griffiths
+ Ben Mather
+ Donald Stufft
+ Dan Sanders
+ Jason Madden
+ Yaroslav Fedevych
+ Even Wiik Thomassen
+ Stefan Marr
Heinrich-Heine University, Germany
Open End AB (formerly AB Strakt), Sweden
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,7 @@
RUNINTERP = $(PYPY_EXECUTABLE)
endif
-.PHONY: cffi_imports
+.PHONY: pypy-c cffi_imports
pypy-c:
@echo
@@ -32,7 +32,7 @@
@echo "===================================================================="
@echo
@sleep 5
- $(RUNINTERP) rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py
+ cd pypy/goal && $(RUNINTERP) ../../rpython/bin/rpython -Ojit targetpypystandalone.py
# Note: the -jN option, or MAKEFLAGS=-jN, are not usable. They are
# replaced with an opaque --jobserver option by the time this Makefile
@@ -40,4 +40,4 @@
# http://lists.gnu.org/archive/html/help-make/2010-08/msg00106.html
cffi_imports: pypy-c
- PYTHONPATH=. ./pypy-c pypy/tool/build_cffi_imports.py || /bin/true
+ PYTHONPATH=. pypy/goal/pypy-c pypy/tool/build_cffi_imports.py || /bin/true
diff --git a/README.rst b/README.rst
--- a/README.rst
+++ b/README.rst
@@ -27,14 +27,19 @@
Building
========
-build with:
+First switch to or download the correct branch. The basic choices are
+``default`` for Python 2.7 and, for Python 3.X, the corresponding py3.X
+branch (e.g. ``py3.5``).
+
+Build with:
.. code-block:: console
$ rpython/bin/rpython -Ojit pypy/goal/targetpypystandalone.py
-This ends up with ``pypy-c`` binary in the main pypy directory. We suggest
-to use virtualenv with the resulting pypy-c as the interpreter; you can
-find more details about various installation schemes here:
+This ends up with a ``pypy-c`` or ``pypy3-c`` binary in the main pypy
+directory. We suggest to use virtualenv with the resulting
+pypy-c/pypy3-c as the interpreter; you can find more details about
+various installation schemes here:
http://doc.pypy.org/en/latest/install.html
diff --git a/extra_tests/README.txt b/extra_tests/README.txt
new file mode 100644
--- /dev/null
+++ b/extra_tests/README.txt
@@ -0,0 +1,5 @@
+The tests in this directory are a complement to lib-python/3/test/.
+
+They are meant to run on top of a compiled pypy3 or CPython3.5 in an
+environment containing at least pytest and hypothesis, using a command like
+'pytest extra_tests/'.
diff --git a/extra_tests/pytest.ini b/extra_tests/pytest.ini
new file mode 100644
diff --git a/extra_tests/test_unicode.py b/extra_tests/test_unicode.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_unicode.py
@@ -0,0 +1,34 @@
+import pytest
+from hypothesis import strategies as st
+from hypothesis import given, settings, example
+
+from unicodedata import normalize
+
+# For every (n1, n2, n3) triple, applying n1 then n2 must be the same
+# as applying n3.
+# Reference: http://unicode.org/reports/tr15/#Design_Goals
+compositions = [
+ ('NFC', 'NFC', 'NFC'),
+ ('NFC', 'NFD', 'NFD'),
+ ('NFC', 'NFKC', 'NFKC'),
+ ('NFC', 'NFKD', 'NFKD'),
+ ('NFD', 'NFC', 'NFC'),
+ ('NFD', 'NFD', 'NFD'),
+ ('NFD', 'NFKC', 'NFKC'),
+ ('NFD', 'NFKD', 'NFKD'),
+ ('NFKC', 'NFC', 'NFKC'),
+ ('NFKC', 'NFD', 'NFKD'),
+ ('NFKC', 'NFKC', 'NFKC'),
+ ('NFKC', 'NFKD', 'NFKD'),
+ ('NFKD', 'NFC', 'NFKC'),
+ ('NFKD', 'NFD', 'NFKD'),
+ ('NFKD', 'NFKC', 'NFKC'),
+ ('NFKD', 'NFKD', 'NFKD'),
+]
+
+ at pytest.mark.parametrize('norm1, norm2, norm3', compositions)
+ at settings(max_examples=1000)
+ at example(s=u'---\uafb8\u11a7---') # issue 2289
+ at given(s=st.text())
+def test_composition(s, norm1, norm2, norm3):
+ assert normalize(norm2, normalize(norm1, s)) == normalize(norm3, s)
diff --git a/include/README b/include/README
--- a/include/README
+++ b/include/README
@@ -1,7 +1,11 @@
This directory contains all the include files needed to build cpython
extensions with PyPy. Note that these are just copies of the original headers
-that are in pypy/module/cpyext/include: they are automatically copied from
-there during translation.
+that are in pypy/module/cpyext/{include,parse}: they are automatically copied
+from there during translation.
-Moreover, pypy_decl.h and pypy_macros.h are automatically generated, also
-during translation.
+Moreover, some pypy-specific files are automatically generated, also during
+translation. Currently they are:
+* pypy_decl.h
+* pypy_macros.h
+* pypy_numpy.h
+* pypy_structmember_decl.h
diff --git a/lib-python/2.7/ctypes/__init__.py b/lib-python/2.7/ctypes/__init__.py
--- a/lib-python/2.7/ctypes/__init__.py
+++ b/lib-python/2.7/ctypes/__init__.py
@@ -361,17 +361,20 @@
if handle is None:
if flags & _FUNCFLAG_CDECL:
- self._handle = _ffi.CDLL(name, mode)
+ pypy_dll = _ffi.CDLL(name, mode)
else:
- self._handle = _ffi.WinDLL(name, mode)
- else:
- self._handle = handle
+ pypy_dll = _ffi.WinDLL(name, mode)
+ self.__pypy_dll__ = pypy_dll
+ handle = int(pypy_dll)
+ if _sys.maxint > 2 ** 32:
+ handle = int(handle) # long -> int
+ self._handle = handle
def __repr__(self):
- return "<%s '%s', handle %r at 0x%x>" % (
- self.__class__.__name__, self._name, self._handle,
- id(self) & (_sys.maxint * 2 + 1))
-
+ return "<%s '%s', handle %x at %x>" % \
+ (self.__class__.__name__, self._name,
+ (self._handle & (_sys.maxint*2 + 1)),
+ id(self) & (_sys.maxint*2 + 1))
def __getattr__(self, name):
if name.startswith('__') and name.endswith('__'):
diff --git a/lib-python/2.7/ctypes/test/test_unaligned_structures.py b/lib-python/2.7/ctypes/test/test_unaligned_structures.py
--- a/lib-python/2.7/ctypes/test/test_unaligned_structures.py
+++ b/lib-python/2.7/ctypes/test/test_unaligned_structures.py
@@ -37,7 +37,10 @@
for typ in byteswapped_structures:
## print >> sys.stderr, typ.value
self.assertEqual(typ.value.offset, 1)
- o = typ()
+ try:
+ o = typ()
+ except NotImplementedError as e:
+ self.skipTest(str(e)) # for PyPy
o.value = 4
self.assertEqual(o.value, 4)
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -61,12 +61,12 @@
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
g = {}
- g['CC'] = "gcc -pthread"
- g['CXX'] = "g++ -pthread"
+ g['CC'] = "cc -pthread"
+ g['CXX'] = "c++ -pthread"
g['OPT'] = "-DNDEBUG -O2"
g['CFLAGS'] = "-DNDEBUG -O2"
g['CCSHARED'] = "-fPIC"
- g['LDSHARED'] = "gcc -pthread -shared"
+ g['LDSHARED'] = "cc -pthread -shared"
g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
g['AR'] = "ar"
g['ARFLAGS'] = "rc"
@@ -218,6 +218,10 @@
compiler.shared_lib_extension = so_ext
+def get_config_h_filename():
+ """Returns the path of pyconfig.h."""
+ inc_dir = get_python_inc(plat_specific=1)
+ return os.path.join(inc_dir, 'pyconfig.h')
from sysconfig_cpython import (
parse_makefile, _variable_rx, expand_makefile_vars)
diff --git a/lib-python/2.7/distutils/unixccompiler.py b/lib-python/2.7/distutils/unixccompiler.py
--- a/lib-python/2.7/distutils/unixccompiler.py
+++ b/lib-python/2.7/distutils/unixccompiler.py
@@ -226,7 +226,19 @@
return "-L" + dir
def _is_gcc(self, compiler_name):
- return "gcc" in compiler_name or "g++" in compiler_name
+ # XXX PyPy workaround, look at the big comment below for more
+ # context. On CPython, the hack below works fine because
+ # `compiler_name` contains the name of the actual compiler which was
+ # used at compile time (e.g. 'x86_64-linux-gnu-gcc' on my machine).
+ # PyPy hardcodes it to 'cc', so the hack doesn't work, and the end
+ # result is that we pass the wrong option to the compiler.
+ #
+ # The workaround is to *always* pretend to be GCC if we are on Linux:
+ # this should cover the vast majority of real systems, including the
+ # ones which use clang (which understands the '-Wl,-rpath' syntax as
+ # well)
+ return (sys.platform == "linux2" or
+ "gcc" in compiler_name or "g++" in compiler_name)
def runtime_library_dir_option(self, dir):
# XXX Hackish, at the very least. See Python bug #445902:
diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -29,8 +29,8 @@
'pypy': {
'stdlib': '{base}/lib-{implementation_lower}/{py_version_short}',
'platstdlib': '{base}/lib-{implementation_lower}/{py_version_short}',
- 'purelib': '{base}/lib-{implementation_lower}/{py_version_short}',
- 'platlib': '{base}/lib-{implementation_lower}/{py_version_short}',
+ 'purelib': '{base}/site-packages',
+ 'platlib': '{base}/site-packages',
'include': '{base}/include',
'platinclude': '{base}/include',
'scripts': '{base}/bin',
@@ -369,11 +369,8 @@
def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
- # in cPython, _sysconfigdata is generated at build time, see _generate_posix_vars()
- # in PyPy no such module exists
- #from _sysconfigdata import build_time_vars
- #vars.update(build_time_vars)
- return
+ from _sysconfigdata import build_time_vars
+ vars.update(build_time_vars)
def _init_non_posix(vars):
"""Initialize the module as appropriate for NT"""
@@ -529,7 +526,9 @@
for suffix, mode, type_ in imp.get_suffixes():
if type_ == imp.C_EXTENSION:
_CONFIG_VARS['SOABI'] = suffix.split('.')[1]
- break
+ break
+ _CONFIG_VARS['INCLUDEPY'] = os.path.join(_CONFIG_VARS['prefix'],
+ 'include')
if args:
vals = []
diff --git a/lib-python/2.7/test/test_os.py b/lib-python/2.7/test/test_os.py
--- a/lib-python/2.7/test/test_os.py
+++ b/lib-python/2.7/test/test_os.py
@@ -580,6 +580,7 @@
"getentropy() does not use a file descriptor")
class URandomFDTests(unittest.TestCase):
@unittest.skipUnless(resource, "test requires the resource module")
+ @test_support.impl_detail(pypy=False) # on Linux, may use getrandom()
def test_urandom_failure(self):
# Check urandom() failing when it is not able to open /dev/random.
# We spawn a new process to make the test more robust (if getrlimit()
diff --git a/lib-python/2.7/warnings.py b/lib-python/2.7/warnings.py
--- a/lib-python/2.7/warnings.py
+++ b/lib-python/2.7/warnings.py
@@ -309,9 +309,12 @@
def __init__(self, message, category, filename, lineno, file=None,
line=None):
- local_values = locals()
- for attr in self._WARNING_DETAILS:
- setattr(self, attr, local_values[attr])
+ self.message = message
+ self.category = category
+ self.filename = filename
+ self.lineno = lineno
+ self.file = file
+ self.line = line
self._category_name = category.__name__ if category else None
def __str__(self):
diff --git a/lib-python/2.7/weakref.py b/lib-python/2.7/weakref.py
--- a/lib-python/2.7/weakref.py
+++ b/lib-python/2.7/weakref.py
@@ -36,9 +36,9 @@
except ImportError:
def _delitem_if_value_is(d, key, value):
try:
- if self.data[key] is value: # fall-back: there is a potential
+ if d[key] is value: # fall-back: there is a potential
# race condition in multithreaded programs HERE
- del self.data[key]
+ del d[key]
except KeyError:
pass
diff --git a/lib-python/2.7/zipfile.py b/lib-python/2.7/zipfile.py
--- a/lib-python/2.7/zipfile.py
+++ b/lib-python/2.7/zipfile.py
@@ -622,19 +622,23 @@
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
"""
- buf = ''
+ # PyPy modification: don't do repeated string concatenation
+ buf = []
+ lenbuf = 0
if n is None:
n = -1
while True:
if n < 0:
data = self.read1(n)
- elif n > len(buf):
- data = self.read1(n - len(buf))
+ elif n > lenbuf:
+ data = self.read1(n - lenbuf)
else:
- return buf
+ break
if len(data) == 0:
- return buf
- buf += data
+ break
+ lenbuf += len(data)
+ buf.append(data)
+ return "".join(buf)
def _update_crc(self, newdata, eof):
# Update the CRC using the given data.
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -76,17 +76,22 @@
return self._type_._alignmentofinstances()
def _CData_output(self, resarray, base=None, index=-1):
- # this seems to be a string if we're array of char, surprise!
- from ctypes import c_char, c_wchar
- if self._type_ is c_char:
- return _rawffi.charp2string(resarray.buffer, self._length_)
- if self._type_ is c_wchar:
- return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
+ from _rawffi.alt import types
+ # If a char_p or unichar_p is received, skip the string interpretation
+ if base._ffiargtype != types.Pointer(types.char_p) and \
+ base._ffiargtype != types.Pointer(types.unichar_p):
+ # this seems to be a string if we're array of char, surprise!
+ from ctypes import c_char, c_wchar
+ if self._type_ is c_char:
+ return _rawffi.charp2string(resarray.buffer, self._length_)
+ if self._type_ is c_wchar:
+ return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
res = self.__new__(self)
ffiarray = self._ffiarray.fromaddress(resarray.buffer, self._length_)
res._buffer = ffiarray
- res._base = base
- res._index = index
+ if base is not None:
+ res._base = base
+ res._index = index
return res
def _CData_retval(self, resbuffer):
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -64,8 +64,9 @@
res = object.__new__(self)
res.__class__ = self
res.__dict__['_buffer'] = resbuffer
- res.__dict__['_base'] = base
- res.__dict__['_index'] = index
+ if base is not None:
+ res.__dict__['_base'] = base
+ res.__dict__['_index'] = index
return res
def _CData_retval(self, resbuffer):
@@ -81,7 +82,7 @@
return False
def in_dll(self, dll, name):
- return self.from_address(dll._handle.getaddressindll(name))
+ return self.from_address(dll.__pypy_dll__.getaddressindll(name))
def from_buffer(self, obj, offset=0):
size = self._sizeofinstances()
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -1,4 +1,3 @@
-
from _ctypes.basics import _CData, _CDataMeta, cdata_from_address
from _ctypes.primitive import SimpleType, _SimpleCData
from _ctypes.basics import ArgumentError, keepalive_key
@@ -9,13 +8,16 @@
import sys
import traceback
-try: from __pypy__ import builtinify
-except ImportError: builtinify = lambda f: f
+
+try:
+ from __pypy__ import builtinify
+except ImportError:
+ builtinify = lambda f: f
# XXX this file needs huge refactoring I fear
-PARAMFLAG_FIN = 0x1
-PARAMFLAG_FOUT = 0x2
+PARAMFLAG_FIN = 0x1
+PARAMFLAG_FOUT = 0x2
PARAMFLAG_FLCID = 0x4
PARAMFLAG_COMBINED = PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID
@@ -24,9 +26,9 @@
PARAMFLAG_FIN,
PARAMFLAG_FIN | PARAMFLAG_FOUT,
PARAMFLAG_FIN | PARAMFLAG_FLCID
- )
+)
-WIN64 = sys.platform == 'win32' and sys.maxint == 2**63 - 1
+WIN64 = sys.platform == 'win32' and sys.maxint == 2 ** 63 - 1
def get_com_error(errcode, riid, pIunk):
@@ -35,6 +37,7 @@
from _ctypes import COMError
return COMError(errcode, None, None)
+
@builtinify
def call_function(func, args):
"Only for debugging so far: So that we can call CFunction instances"
@@ -94,14 +97,9 @@
"item %d in _argtypes_ has no from_param method" % (
i + 1,))
self._argtypes_ = list(argtypes)
- self._check_argtypes_for_fastpath()
+
argtypes = property(_getargtypes, _setargtypes)
- def _check_argtypes_for_fastpath(self):
- if all([hasattr(argtype, '_ffiargshape_') for argtype in self._argtypes_]):
- fastpath_cls = make_fastpath_subclass(self.__class__)
- fastpath_cls.enable_fastpath_maybe(self)
-
def _getparamflags(self):
return self._paramflags
@@ -126,27 +124,26 @@
raise TypeError(
"paramflags must be a sequence of (int [,string [,value]]) "
"tuples"
- )
+ )
if not isinstance(flag, int):
raise TypeError(
"paramflags must be a sequence of (int [,string [,value]]) "
"tuples"
- )
+ )
_flag = flag & PARAMFLAG_COMBINED
if _flag == PARAMFLAG_FOUT:
typ = self._argtypes_[idx]
if getattr(typ, '_ffiargshape_', None) not in ('P', 'z', 'Z'):
raise TypeError(
"'out' parameter %d must be a pointer type, not %s"
- % (idx+1, type(typ).__name__)
- )
+ % (idx + 1, type(typ).__name__)
+ )
elif _flag not in VALID_PARAMFLAGS:
raise TypeError("paramflag value %d not supported" % flag)
self._paramflags = paramflags
paramflags = property(_getparamflags, _setparamflags)
-
def _getrestype(self):
return self._restype_
@@ -156,7 +153,7 @@
from ctypes import c_int
restype = c_int
if not (isinstance(restype, _CDataMeta) or restype is None or
- callable(restype)):
+ callable(restype)):
raise TypeError("restype must be a type, a callable, or None")
self._restype_ = restype
@@ -168,15 +165,18 @@
def _geterrcheck(self):
return getattr(self, '_errcheck_', None)
+
def _seterrcheck(self, errcheck):
if not callable(errcheck):
raise TypeError("The errcheck attribute must be callable")
self._errcheck_ = errcheck
+
def _delerrcheck(self):
try:
del self._errcheck_
except AttributeError:
pass
+
errcheck = property(_geterrcheck, _seterrcheck, _delerrcheck)
def _ffishapes(self, args, restype):
@@ -188,7 +188,7 @@
raise TypeError("invalid result type for callback function")
restype = restype._ffiargshape_
else:
- restype = 'O' # void
+ restype = 'O' # void
return argtypes, restype
def _set_address(self, address):
@@ -201,7 +201,7 @@
def __init__(self, *args):
self.name = None
- self._objects = {keepalive_key(0):self}
+ self._objects = {keepalive_key(0): self}
self._needs_free = True
# Empty function object -- this is needed for casts
@@ -222,10 +222,8 @@
if self._argtypes_ is None:
self._argtypes_ = []
self._ptr = self._getfuncptr_fromaddress(self._argtypes_, restype)
- self._check_argtypes_for_fastpath()
return
-
# A callback into python
if callable(argument) and not argsl:
self.callable = argument
@@ -259,7 +257,7 @@
if (sys.platform == 'win32' and isinstance(argument, (int, long))
and argsl):
ffiargs, ffires = self._ffishapes(self._argtypes_, self._restype_)
- self._com_index = argument + 0x1000
+ self._com_index = argument + 0x1000
self.name = argsl.pop(0)
if argsl:
self.paramflags = argsl.pop(0)
@@ -281,6 +279,7 @@
except SystemExit as e:
handle_system_exit(e)
raise
+
return f
def __call__(self, *args, **kwargs):
@@ -317,7 +316,7 @@
except:
exc_info = sys.exc_info()
traceback.print_tb(exc_info[2], file=sys.stderr)
- print >>sys.stderr, "%s: %s" % (exc_info[0].__name__, exc_info[1])
+ print >> sys.stderr, "%s: %s" % (exc_info[0].__name__, exc_info[1])
return 0
if self._restype_ is not None:
return res
@@ -328,7 +327,7 @@
# really slow". Now we don't worry that much about slowness
# of ctypes, and it's strange to get warnings for perfectly-
# legal code.
- #warnings.warn('C function without declared arguments called',
+ # warnings.warn('C function without declared arguments called',
# RuntimeWarning, stacklevel=2)
argtypes = []
@@ -337,7 +336,7 @@
if not args:
raise ValueError(
"native COM method call without 'this' parameter"
- )
+ )
thisvalue = args[0]
thisarg = cast(thisvalue, POINTER(POINTER(c_void_p)))
keepalives, newargs, argtypes, outargs, errcheckargs = (
@@ -366,7 +365,6 @@
return tuple(outargs)
def _call_funcptr(self, funcptr, *newargs):
-
if self._flags_ & _rawffi.FUNCFLAG_USE_ERRNO:
tmp = _rawffi.get_errno()
_rawffi.set_errno(get_errno())
@@ -431,8 +429,8 @@
ffiargs = [argtype.get_ffi_argtype() for argtype in argtypes]
ffires = restype.get_ffi_argtype()
return _ffi.FuncPtr.fromaddr(ptr, '', ffiargs, ffires, self._flags_)
-
- cdll = self.dll._handle
+
+ cdll = self.dll.__pypy_dll__
try:
ffi_argtypes = [argtype.get_ffi_argtype() for argtype in argtypes]
ffi_restype = restype.get_ffi_argtype()
@@ -450,7 +448,7 @@
# funcname -> _funcname@<n>
# where n is 0, 4, 8, 12, ..., 128
for i in range(33):
- mangled_name = "_%s@%d" % (self.name, i*4)
+ mangled_name = "_%s@%d" % (self.name, i * 4)
try:
return cdll.getfunc(mangled_name,
ffi_argtypes, ffi_restype,
@@ -492,7 +490,7 @@
for argtype, arg in zip(argtypes, args):
param = argtype.from_param(arg)
_type_ = getattr(argtype, '_type_', None)
- if _type_ == 'P': # special-case for c_void_p
+ if _type_ == 'P': # special-case for c_void_p
param = param._get_buffer_value()
elif self._is_primitive(argtype):
param = param.value
@@ -668,69 +666,11 @@
self._needs_free = False
-def make_fastpath_subclass(CFuncPtr):
- if CFuncPtr._is_fastpath:
- return CFuncPtr
- #
- try:
- return make_fastpath_subclass.memo[CFuncPtr]
- except KeyError:
- pass
-
- class CFuncPtrFast(CFuncPtr):
-
- _is_fastpath = True
- _slowpath_allowed = True # set to False by tests
-
- @classmethod
- def enable_fastpath_maybe(cls, obj):
- if (obj.callable is None and
- obj._com_index is None):
- obj.__class__ = cls
-
- def __rollback(self):
- assert self._slowpath_allowed
- self.__class__ = CFuncPtr
-
- # disable the fast path if we reset argtypes
- def _setargtypes(self, argtypes):
- self.__rollback()
- self._setargtypes(argtypes)
- argtypes = property(CFuncPtr._getargtypes, _setargtypes)
-
- def _setcallable(self, func):
- self.__rollback()
- self.callable = func
- callable = property(lambda x: None, _setcallable)
-
- def _setcom_index(self, idx):
- self.__rollback()
- self._com_index = idx
- _com_index = property(lambda x: None, _setcom_index)
-
- def __call__(self, *args):
- thisarg = None
- argtypes = self._argtypes_
- restype = self._restype_
- funcptr = self._getfuncptr(argtypes, restype, thisarg)
- try:
- result = self._call_funcptr(funcptr, *args)
- result, _ = self._do_errcheck(result, args)
- except (TypeError, ArgumentError, UnicodeDecodeError):
- assert self._slowpath_allowed
- return CFuncPtr.__call__(self, *args)
- return result
-
- make_fastpath_subclass.memo[CFuncPtr] = CFuncPtrFast
- return CFuncPtrFast
-make_fastpath_subclass.memo = {}
-
-
def handle_system_exit(e):
# issue #1194: if we get SystemExit here, then exit the interpreter.
# Highly obscure imho but some people seem to depend on it.
if sys.flags.inspect:
- return # Don't exit if -i flag was given.
+ return # Don't exit if -i flag was given.
else:
code = e.code
if isinstance(code, int):
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -40,6 +40,22 @@
else:
rawfields.append((f[0], f[1]._ffishape_))
+ # hack for duplicate field names
+ already_seen = set()
+ names1 = names
+ names = []
+ for f in names1:
+ if f not in already_seen:
+ names.append(f)
+ already_seen.add(f)
+ already_seen = set()
+ for i in reversed(range(len(rawfields))):
+ if rawfields[i][0] in already_seen:
+ rawfields[i] = (('$DUP%d$%s' % (i, rawfields[i][0]),)
+ + rawfields[i][1:])
+ already_seen.add(rawfields[i][0])
+ # /hack
+
_set_shape(self, rawfields, self._is_union)
fields = {}
@@ -234,6 +250,9 @@
if ('_abstract_' in cls.__dict__ or cls is Structure
or cls is union.Union):
raise TypeError("abstract class")
+ if hasattr(cls, '_swappedbytes_'):
+ raise NotImplementedError("missing in PyPy: structure/union with "
+ "swapped (non-native) byte ordering")
if hasattr(cls, '_ffistruct_'):
self.__dict__['_buffer'] = self._ffistruct_(autofree=True)
return self
diff --git a/lib_pypy/_curses.py b/lib_pypy/_curses.py
--- a/lib_pypy/_curses.py
+++ b/lib_pypy/_curses.py
@@ -8,6 +8,9 @@
from _curses_cffi import ffi, lib
+version = b"2.2"
+__version__ = b"2.2"
+
def _copy_to_globals(name):
globals()[name] = getattr(lib, name)
@@ -60,10 +63,6 @@
_setup()
-# Do we want this?
-# version = "2.2"
-# __version__ = "2.2"
-
# ____________________________________________________________
@@ -913,101 +912,29 @@
return None
-# XXX: Do something about the following?
-# /* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
-# * and _curses.COLS */
-# #if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)
-# static int
-# update_lines_cols(void)
-# {
-# PyObject *o;
-# PyObject *m = PyImport_ImportModuleNoBlock("curses");
+# Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
+# and _curses.COLS
+def update_lines_cols():
+ globals()["LINES"] = lib.LINES
+ globals()["COLS"] = lib.COLS
+ try:
+ m = sys.modules["curses"]
+ m.LINES = lib.LINES
+ m.COLS = lib.COLS
+ except (KeyError, AttributeError):
+ pass
-# if (!m)
-# return 0;
-# o = PyInt_FromLong(LINES);
-# if (!o) {
-# Py_DECREF(m);
-# return 0;
-# }
-# if (PyObject_SetAttrString(m, "LINES", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# if (PyDict_SetItemString(ModDict, "LINES", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# Py_DECREF(o);
-# o = PyInt_FromLong(COLS);
-# if (!o) {
-# Py_DECREF(m);
-# return 0;
-# }
-# if (PyObject_SetAttrString(m, "COLS", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# if (PyDict_SetItemString(ModDict, "COLS", o)) {
-# Py_DECREF(m);
-# Py_DECREF(o);
-# return 0;
-# }
-# Py_DECREF(o);
-# Py_DECREF(m);
-# return 1;
-# }
-# #endif
+def resizeterm(lines, columns):
+ _ensure_initialised()
+ _check_ERR(lib.resizeterm(lines, columns), "resizeterm")
+ update_lines_cols()
-# #ifdef HAVE_CURSES_RESIZETERM
-# static PyObject *
-# PyCurses_ResizeTerm(PyObject *self, PyObject *args)
-# {
-# int lines;
-# int columns;
-# PyObject *result;
-# PyCursesInitialised;
-
-# if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns))
-# return NULL;
-
-# result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
-# if (!result)
-# return NULL;
-# if (!update_lines_cols())
-# return NULL;
-# return result;
-# }
-
-# #endif
-
-# #ifdef HAVE_CURSES_RESIZE_TERM
-# static PyObject *
-# PyCurses_Resize_Term(PyObject *self, PyObject *args)
-# {
-# int lines;
-# int columns;
-
-# PyObject *result;
-
-# PyCursesInitialised;
-
-# if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns))
-# return NULL;
-
-# result = PyCursesCheckERR(resize_term(lines, columns), "resize_term");
-# if (!result)
-# return NULL;
-# if (!update_lines_cols())
-# return NULL;
-# return result;
-# }
-# #endif /* HAVE_CURSES_RESIZE_TERM */
+def resize_term(lines, columns):
+ _ensure_initialised()
+ _check_ERR(lib.resize_term(lines, columns), "resize_term")
+ update_lines_cols()
def setsyx(y, x):
diff --git a/lib_pypy/_curses_build.py b/lib_pypy/_curses_build.py
--- a/lib_pypy/_curses_build.py
+++ b/lib_pypy/_curses_build.py
@@ -87,6 +87,13 @@
static const chtype A_CHARTEXT;
static const chtype A_COLOR;
+static const chtype A_HORIZONTAL;
+static const chtype A_LEFT;
+static const chtype A_LOW;
+static const chtype A_RIGHT;
+static const chtype A_TOP;
+static const chtype A_VERTICAL;
+
static const int BUTTON1_RELEASED;
static const int BUTTON1_PRESSED;
static const int BUTTON1_CLICKED;
@@ -202,6 +209,8 @@
int resetty(void);
int reset_prog_mode(void);
int reset_shell_mode(void);
+int resizeterm(int, int);
+int resize_term(int, int);
int savetty(void);
int scroll(WINDOW *);
int scrollok(WINDOW *, bool);
diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py
--- a/lib_pypy/_pypy_winbase_build.py
+++ b/lib_pypy/_pypy_winbase_build.py
@@ -79,10 +79,20 @@
BOOL WINAPI CreateProcessA(char *, char *, void *,
void *, BOOL, DWORD, char *,
char *, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+BOOL WINAPI CreateProcessW(wchar_t *, wchar_t *, void *,
+ void *, BOOL, DWORD, wchar_t *,
+ wchar_t *, LPSTARTUPINFO, LPPROCESS_INFORMATION);
DWORD WINAPI WaitForSingleObject(HANDLE, DWORD);
BOOL WINAPI GetExitCodeProcess(HANDLE, LPDWORD);
BOOL WINAPI TerminateProcess(HANDLE, UINT);
HANDLE WINAPI GetStdHandle(DWORD);
+DWORD WINAPI GetModuleFileNameW(HANDLE, wchar_t *, DWORD);
+
+UINT WINAPI SetErrorMode(UINT);
+#define SEM_FAILCRITICALERRORS 0x0001
+#define SEM_NOGPFAULTERRORBOX 0x0002
+#define SEM_NOALIGNMENTFAULTEXCEPT 0x0004
+#define SEM_NOOPENFILEERRORBOX 0x8000
""")
# --------------------
diff --git a/lib_pypy/_pypy_winbase_cffi.py b/lib_pypy/_pypy_winbase_cffi.py
--- a/lib_pypy/_pypy_winbase_cffi.py
+++ b/lib_pypy/_pypy_winbase_cffi.py
@@ -3,8 +3,8 @@
ffi = _cffi_backend.FFI('_pypy_winbase_cffi',
_version = 0x2601,
- _types = b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x09\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x19\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x50\x03\x00\x00\x13\x11\x00\x00\x53\x03\x00\x00\x15\x11\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x13\x11\x00\x00\x13\x11\x00\x00\x4F\x03\x00\x00\x4E\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x03\x00\x00\x1F\x11\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x18\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x1F\x11\x00\x00\x0A\x01\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x0D\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x02\x0F\x00\x00\x42\x0D\x00\x00\x06\x01\x00\x00\x00\x0F\x00\x00\x42\x0D\x00\x00\x00\x0F\x00\x00\x42\x0D\x00\x00\x10\x01\x00\x00\x00\x0F\x00\x00\x15\x0D\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x15\x0D\x00\x00\x02\x0F\x00\x00\x00\x09\x00\x00\x01\x09\x00\x00\x02\x01\x00\x00\x52\x03\x00\x00\x04\x01\x00\x00\x00\x01',
- _globals = (b'\x00\x00\x24\x23CloseHandle',0,b'\x00\x00\x1E\x23CreatePipe',0,b'\x00\x00\x12\x23CreateProcessA',0,b'\x00\x00\x2F\x23DuplicateHandle',0,b'\x00\x00\x4C\x23GetCurrentProcess',0,b'\x00\x00\x2B\x23GetExitCodeProcess',0,b'\x00\x00\x49\x23GetStdHandle',0,b'\x00\x00\x3F\x23GetVersion',0,b'\x00\x00\x27\x23TerminateProcess',0,b'\x00\x00\x3B\x23WaitForSingleObject',0,b'\x00\x00\x38\x23_get_osfhandle',0,b'\x00\x00\x10\x23_getch',0,b'\x00\x00\x10\x23_getche',0,b'\x00\x00\x44\x23_getwch',0,b'\x00\x00\x44\x23_getwche',0,b'\x00\x00\x10\x23_kbhit',0,b'\x00\x00\x07\x23_locking',0,b'\x00\x00\x0C\x23_open_osfhandle',0,b'\x00\x00\x00\x23_putch',0,b'\x00\x00\x46\x23_putwch',0,b'\x00\x00\x03\x23_setmode',0,b'\x00\x00\x00\x23_ungetch',0,b'\x00\x00\x41\x23_ungetwch',0),
- _struct_unions = ((b'\x00\x00\x00\x4E\x00\x00\x00\x02$PROCESS_INFORMATION',b'\x00\x00\x15\x11hProcess',b'\x00\x00\x15\x11hThread',b'\x00\x00\x18\x11dwProcessId',b'\x00\x00\x18\x11dwThreadId'),(b'\x00\x00\x00\x4F\x00\x00\x00\x02$STARTUPINFO',b'\x00\x00\x18\x11cb',b'\x00\x00\x13\x11lpReserved',b'\x00\x00\x13\x11lpDesktop',b'\x00\x00\x13\x11lpTitle',b'\x00\x00\x18\x11dwX',b'\x00\x00\x18\x11dwY',b'\x00\x00\x18\x11dwXSize',b'\x00\x00\x18\x11dwYSize',b'\x00\x00\x18\x11dwXCountChars',b'\x00\x00\x18\x11dwYCountChars',b'\x00\x00\x18\x11dwFillAttribute',b'\x00\x00\x18\x11dwFlags',b'\x00\x00\x42\x11wShowWindow',b'\x00\x00\x42\x11cbReserved2',b'\x00\x00\x51\x11lpReserved2',b'\x00\x00\x15\x11hStdInput',b'\x00\x00\x15\x11hStdOutput',b'\x00\x00\x15\x11hStdError')),
- _typenames = (b'\x00\x00\x00\x1CLPPROCESS_INFORMATION',b'\x00\x00\x00\x1BLPSTARTUPINFO',b'\x00\x00\x00\x4EPROCESS_INFORMATION',b'\x00\x00\x00\x4FSTARTUPINFO',b'\x00\x00\x00\x42wint_t'),
+ _types = b'\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x07\x01\x00\x00\x07\x01\x00\x00\x09\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x19\x01\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x00\x0F\x00\x00\x01\x0D\x00\x00\x64\x03\x00\x00\x13\x11\x00\x00\x67\x03\x00\x00\x15\x11\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x13\x11\x00\x00\x13\x11\x00\x00\x63\x03\x00\x00\x62\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x03\x00\x00\x1F\x11\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x18\x03\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x1F\x11\x00\x00\x0A\x01\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x01\x0D\x00\x00\x5B\x03\x00\x00\x39\x11\x00\x00\x15\x11\x00\x00\x15\x11\x00\x00\x07\x01\x00\x00\x0A\x01\x00\x00\x39\x11\x00\x00\x39\x11\x00\x00\x1B\x11\x00\x00\x1C\x11\x00\x00\x02\x0F\x00\x00\x0D\x0D\x00\x00\x07\x01\x00\x00\x00\x0F\x00\x00\x29\x0D\x00\x00\x08\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x15\x11\x00\x00\x39\x11\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x18\x0D\x00\x00\x02\x0F\x00\x00\x56\x0D\x00\x00\x06\x01\x00\x00\x00\x0F\x00\x00\x56\x0D\x00\x00\x00\x0F\x00\x00\x56\x0D\x00\x00\x10\x01\x00\x00\x00\x0F\x00\x00\x15\x0D\x00\x00\x0A\x01\x00\x00\x02\x0F\x00\x00\x15\x0D\x00\x00\x02\x0F\x00\x00\x00\x09\x00\x00\x01\x09\x00\x00\x02\x01\x00\x00\x66\x03\x00\x00\x04\x01\x00\x00\x00\x01',
+ _globals = (b'\x00\x00\x24\x23CloseHandle',0,b'\x00\x00\x1E\x23CreatePipe',0,b'\x00\x00\x12\x23CreateProcessA',0,b'\x00\x00\x38\x23CreateProcessW',0,b'\x00\x00\x2F\x23DuplicateHandle',0,b'\x00\x00\x60\x23GetCurrentProcess',0,b'\x00\x00\x2B\x23GetExitCodeProcess',0,b'\x00\x00\x4E\x23GetModuleFileNameW',0,b'\x00\x00\x5D\x23GetStdHandle',0,b'\x00\x00\x53\x23GetVersion',0,b'\xFF\xFF\xFF\x1FSEM_FAILCRITICALERRORS',1,b'\xFF\xFF\xFF\x1FSEM_NOALIGNMENTFAULTEXCEPT',4,b'\xFF\xFF\xFF\x1FSEM_NOGPFAULTERRORBOX',2,b'\xFF\xFF\xFF\x1FSEM_NOOPENFILEERRORBOX',32768,b'\x00\x00\x47\x23SetErrorMode',0,b'\x00\x00\x27\x23TerminateProcess',0,b'\x00\x00\x4A\x23WaitForSingleObject',0,b'\x00\x00\x44\x23_get_osfhandle',0,b'\x00\x00\x10\x23_getch',0,b'\x00\x00\x10\x23_getche',0,b'\x00\x00\x58\x23_getwch',0,b'\x00\x00\x58\x23_getwche',0,b'\x00\x00\x10\x23_kbhit',0,b'\x00\x00\x07\x23_locking',0,b'\x00\x00\x0C\x23_open_osfhandle',0,b'\x00\x00\x00\x23_putch',0,b'\x00\x00\x5A\x23_putwch',0,b'\x00\x00\x03\x23_setmode',0,b'\x00\x00\x00\x23_ungetch',0,b'\x00\x00\x55\x23_ungetwch',0),
+ _struct_unions = ((b'\x00\x00\x00\x62\x00\x00\x00\x02$PROCESS_INFORMATION',b'\x00\x00\x15\x11hProcess',b'\x00\x00\x15\x11hThread',b'\x00\x00\x18\x11dwProcessId',b'\x00\x00\x18\x11dwThreadId'),(b'\x00\x00\x00\x63\x00\x00\x00\x02$STARTUPINFO',b'\x00\x00\x18\x11cb',b'\x00\x00\x13\x11lpReserved',b'\x00\x00\x13\x11lpDesktop',b'\x00\x00\x13\x11lpTitle',b'\x00\x00\x18\x11dwX',b'\x00\x00\x18\x11dwY',b'\x00\x00\x18\x11dwXSize',b'\x00\x00\x18\x11dwYSize',b'\x00\x00\x18\x11dwXCountChars',b'\x00\x00\x18\x11dwYCountChars',b'\x00\x00\x18\x11dwFillAttribute',b'\x00\x00\x18\x11dwFlags',b'\x00\x00\x56\x11wShowWindow',b'\x00\x00\x56\x11cbReserved2',b'\x00\x00\x65\x11lpReserved2',b'\x00\x00\x15\x11hStdInput',b'\x00\x00\x15\x11hStdOutput',b'\x00\x00\x15\x11hStdError')),
+ _typenames = (b'\x00\x00\x00\x1CLPPROCESS_INFORMATION',b'\x00\x00\x00\x1BLPSTARTUPINFO',b'\x00\x00\x00\x62PROCESS_INFORMATION',b'\x00\x00\x00\x63STARTUPINFO',b'\x00\x00\x00\x56wint_t'),
)
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -31,10 +31,11 @@
import weakref
from threading import _get_ident as _thread_get_ident
try:
- from __pypy__ import newlist_hint
+ from __pypy__ import newlist_hint, add_memory_pressure
except ImportError:
assert '__pypy__' not in sys.builtin_module_names
newlist_hint = lambda sizehint: []
+ add_memory_pressure = lambda size: None
if sys.version_info[0] >= 3:
StandardError = Exception
@@ -150,6 +151,9 @@
def connect(database, timeout=5.0, detect_types=0, isolation_level="",
check_same_thread=True, factory=None, cached_statements=100):
factory = Connection if not factory else factory
+ # an sqlite3 db seems to be around 100 KiB at least (doesn't matter if
+ # backed by :memory: or a file)
+ add_memory_pressure(100 * 1024)
return factory(database, timeout, detect_types, isolation_level,
check_same_thread, factory, cached_statements)
diff --git a/lib_pypy/_sysconfigdata.py b/lib_pypy/_sysconfigdata.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_sysconfigdata.py
@@ -0,0 +1,5 @@
+import imp
+
+build_time_vars = {
+ "SO": [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
+}
diff --git a/lib_pypy/_tkinter/tklib_build.py b/lib_pypy/_tkinter/tklib_build.py
--- a/lib_pypy/_tkinter/tklib_build.py
+++ b/lib_pypy/_tkinter/tklib_build.py
@@ -22,12 +22,27 @@
linklibs = ['tcl', 'tk']
libdirs = []
else:
- for _ver in ['', '8.6', '8.5', '']:
+ # On some Linux distributions, the tcl and tk libraries are
+ # stored in /usr/include, so we must check this case also
+ libdirs = []
+ found = False
+ for _ver in ['', '8.6', '8.5']:
incdirs = ['/usr/include/tcl' + _ver]
linklibs = ['tcl' + _ver, 'tk' + _ver]
- libdirs = []
if os.path.isdir(incdirs[0]):
+ found = True
break
+ if not found:
+ for _ver in ['8.6', '8.5', '']:
+ incdirs = []
+ linklibs = ['tcl' + _ver, 'tk' + _ver]
+ if os.path.isfile(''.join(['/usr/lib/lib', linklibs[1], '.so'])):
+ found = True
+ break
+ if not found:
+ sys.stderr.write("*** TCL libraries not found! Falling back...\n")
+ incdirs = []
+ linklibs = ['tcl', 'tk']
config_ffi = FFI()
config_ffi.cdef("""
diff --git a/lib_pypy/cPickle.py b/lib_pypy/cPickle.py
--- a/lib_pypy/cPickle.py
+++ b/lib_pypy/cPickle.py
@@ -116,10 +116,20 @@
@builtinify
def dump(obj, file, protocol=None):
+ if protocol > HIGHEST_PROTOCOL:
+ # use cPickle error message, not pickle.py one
+ raise ValueError("pickle protocol %d asked for; "
+ "the highest available protocol is %d" % (
+ protocol, HIGHEST_PROTOCOL))
Pickler(file, protocol).dump(obj)
@builtinify
def dumps(obj, protocol=None):
+ if protocol > HIGHEST_PROTOCOL:
+ # use cPickle error message, not pickle.py one
+ raise ValueError("pickle protocol %d asked for; "
+ "the highest available protocol is %d" % (
+ protocol, HIGHEST_PROTOCOL))
file = StringIO()
Pickler(file, protocol).dump(obj)
return file.getvalue()
@@ -431,7 +441,14 @@
self.append(obj)
def find_class(self, module, name):
- # Subclasses may override this
+ if self.find_global is None:
+ raise UnpicklingError(
+ "Global and instance pickles are not supported.")
+ return self.find_global(module, name)
+
+ def find_global(self, module, name):
+ # This can officially be patched directly in the Unpickler
+ # instance, according to the docs
__import__(module)
mod = sys.modules[module]
klass = getattr(mod, name)
diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: cffi
-Version: 1.10.0
+Version: 1.11.0
Summary: Foreign Function Interface for Python calling C code.
Home-page: http://cffi.readthedocs.org
Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
from .api import FFI
from .error import CDefError, FFIError, VerificationError, VerificationMissing
-__version__ = "1.10.0"
-__version_info__ = (1, 10, 0)
+__version__ = "1.11.0"
+__version_info__ = (1, 11, 0)
# The verifier module file names are based on the CRC32 of a string that
# contains the following version number. It may be older than __version__
diff --git a/lib_pypy/cffi/_cffi_errors.h b/lib_pypy/cffi/_cffi_errors.h
new file mode 100644
--- /dev/null
+++ b/lib_pypy/cffi/_cffi_errors.h
@@ -0,0 +1,145 @@
+#ifndef CFFI_MESSAGEBOX
+# ifdef _MSC_VER
+# define CFFI_MESSAGEBOX 1
+# else
+# define CFFI_MESSAGEBOX 0
+# endif
+#endif
+
+
+#if CFFI_MESSAGEBOX
+/* Windows only: logic to take the Python-CFFI embedding logic
+ initialization errors and display them in a background thread
+ with MessageBox. The idea is that if the whole program closes
+ as a result of this problem, then likely it is already a console
+ program and you can read the stderr output in the console too.
+ If it is not a console program, then it will likely show its own
+ dialog to complain, or generally not abruptly close, and for this
+ case the background thread should stay alive.
+*/
+static void *volatile _cffi_bootstrap_text;
+
+static PyObject *_cffi_start_error_capture(void)
+{
+ PyObject *result = NULL;
+ PyObject *x, *m, *bi;
+
+ if (InterlockedCompareExchangePointer(&_cffi_bootstrap_text,
+ (void *)1, NULL) != NULL)
+ return (PyObject *)1;
+
+ m = PyImport_AddModule("_cffi_error_capture");
+ if (m == NULL)
+ goto error;
+
+ result = PyModule_GetDict(m);
+ if (result == NULL)
+ goto error;
+
+#if PY_MAJOR_VERSION >= 3
+ bi = PyImport_ImportModule("builtins");
+#else
+ bi = PyImport_ImportModule("__builtin__");
+#endif
+ if (bi == NULL)
+ goto error;
+ PyDict_SetItemString(result, "__builtins__", bi);
+ Py_DECREF(bi);
+
+ x = PyRun_String(
+ "import sys\n"
+ "class FileLike:\n"
+ " def write(self, x):\n"
+ " of.write(x)\n"
+ " self.buf += x\n"
+ "fl = FileLike()\n"
+ "fl.buf = ''\n"
+ "of = sys.stderr\n"
+ "sys.stderr = fl\n"
+ "def done():\n"
+ " sys.stderr = of\n"
+ " return fl.buf\n", /* make sure the returned value stays alive */
+ Py_file_input,
+ result, result);
+ Py_XDECREF(x);
+
+ error:
+ if (PyErr_Occurred())
+ {
+ PyErr_WriteUnraisable(Py_None);
+ PyErr_Clear();
+ }
+ return result;
+}
+
+#pragma comment(lib, "user32.lib")
+
+static DWORD WINAPI _cffi_bootstrap_dialog(LPVOID ignored)
+{
+ Sleep(666); /* may be interrupted if the whole process is closing */
+#if PY_MAJOR_VERSION >= 3
+ MessageBoxW(NULL, (wchar_t *)_cffi_bootstrap_text,
+ L"Python-CFFI error",
+ MB_OK | MB_ICONERROR);
+#else
+ MessageBoxA(NULL, (char *)_cffi_bootstrap_text,
+ "Python-CFFI error",
+ MB_OK | MB_ICONERROR);
+#endif
+ _cffi_bootstrap_text = NULL;
+ return 0;
+}
+
+static void _cffi_stop_error_capture(PyObject *ecap)
+{
+ PyObject *s;
+ void *text;
+
+ if (ecap == (PyObject *)1)
+ return;
+
+ if (ecap == NULL)
+ goto error;
+
+ s = PyRun_String("done()", Py_eval_input, ecap, ecap);
+ if (s == NULL)
+ goto error;
+
+ /* Show a dialog box, but in a background thread, and
+ never show multiple dialog boxes at once. */
+#if PY_MAJOR_VERSION >= 3
+ text = PyUnicode_AsWideCharString(s, NULL);
+#else
+ text = PyString_AsString(s);
+#endif
+
+ _cffi_bootstrap_text = text;
+
+ if (text != NULL)
+ {
+ HANDLE h;
+ h = CreateThread(NULL, 0, _cffi_bootstrap_dialog,
+ NULL, 0, NULL);
+ if (h != NULL)
+ CloseHandle(h);
+ }
+ /* decref the string, but it should stay alive as 'fl.buf'
+ in the small module above. It will really be freed only if
+ we later get another similar error. So it's a leak of at
+ most one copy of the small module. That's fine for this
+ situation which is usually a "fatal error" anyway. */
+ Py_DECREF(s);
+ PyErr_Clear();
+ return;
+
+ error:
+ _cffi_bootstrap_text = NULL;
+ PyErr_Clear();
+}
+
+#else
+
+static PyObject *_cffi_start_error_capture(void) { return NULL; }
+static void _cffi_stop_error_capture(PyObject *ecap) { }
+
+#endif
diff --git a/lib_pypy/cffi/_cffi_include.h b/lib_pypy/cffi/_cffi_include.h
--- a/lib_pypy/cffi/_cffi_include.h
+++ b/lib_pypy/cffi/_cffi_include.h
@@ -8,7 +8,7 @@
the same works for the other two macros. Py_DEBUG implies them,
but not the other way around.
*/
-#ifndef _CFFI_USE_EMBEDDING
+#if !defined(_CFFI_USE_EMBEDDING) && !defined(Py_LIMITED_API)
# include <pyconfig.h>
# if !defined(Py_DEBUG) && !defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
# define Py_LIMITED_API
@@ -95,6 +95,7 @@
#define _cffi_from_c_ulong PyLong_FromUnsignedLong
#define _cffi_from_c_longlong PyLong_FromLongLong
#define _cffi_from_c_ulonglong PyLong_FromUnsignedLongLong
+#define _cffi_from_c__Bool PyBool_FromLong
#define _cffi_to_c_double PyFloat_AsDouble
#define _cffi_to_c_float PyFloat_AsDouble
@@ -159,9 +160,9 @@
#define _cffi_from_c_struct \
((PyObject *(*)(char *, struct _cffi_ctypedescr *))_cffi_exports[18])
#define _cffi_to_c_wchar_t \
- ((wchar_t(*)(PyObject *))_cffi_exports[19])
+ ((_cffi_wchar_t(*)(PyObject *))_cffi_exports[19])
#define _cffi_from_c_wchar_t \
- ((PyObject *(*)(wchar_t))_cffi_exports[20])
+ ((PyObject *(*)(_cffi_wchar_t))_cffi_exports[20])
#define _cffi_to_c_long_double \
((long double(*)(PyObject *))_cffi_exports[21])
#define _cffi_to_c__Bool \
@@ -174,7 +175,11 @@
#define _CFFI_CPIDX 25
#define _cffi_call_python \
((void(*)(struct _cffi_externpy_s *, char *))_cffi_exports[_CFFI_CPIDX])
-#define _CFFI_NUM_EXPORTS 26
+#define _cffi_to_c_wchar3216_t \
+ ((int(*)(PyObject *))_cffi_exports[26])
+#define _cffi_from_c_wchar3216_t \
+ ((PyObject *(*)(int))_cffi_exports[27])
+#define _CFFI_NUM_EXPORTS 28
struct _cffi_ctypedescr;
@@ -215,6 +220,46 @@
return NULL;
}
+
+#ifdef HAVE_WCHAR_H
+typedef wchar_t _cffi_wchar_t;
+#else
+typedef uint16_t _cffi_wchar_t; /* same random pick as _cffi_backend.c */
+#endif
+
+_CFFI_UNUSED_FN static uint16_t _cffi_to_c_char16_t(PyObject *o)
+{
+ if (sizeof(_cffi_wchar_t) == 2)
+ return (uint16_t)_cffi_to_c_wchar_t(o);
+ else
+ return (uint16_t)_cffi_to_c_wchar3216_t(o);
+}
+
+_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char16_t(uint16_t x)
+{
+ if (sizeof(_cffi_wchar_t) == 2)
+ return _cffi_from_c_wchar_t(x);
+ else
+ return _cffi_from_c_wchar3216_t(x);
+}
+
+_CFFI_UNUSED_FN static int _cffi_to_c_char32_t(PyObject *o)
+{
+ if (sizeof(_cffi_wchar_t) == 4)
+ return (int)_cffi_to_c_wchar_t(o);
+ else
+ return (int)_cffi_to_c_wchar3216_t(o);
+}
+
+_CFFI_UNUSED_FN static PyObject *_cffi_from_c_char32_t(int x)
+{
+ if (sizeof(_cffi_wchar_t) == 4)
+ return _cffi_from_c_wchar_t(x);
+ else
+ return _cffi_from_c_wchar3216_t(x);
+}
+
+
/********** end CPython-specific section **********/
#else
_CFFI_UNUSED_FN
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -1,7 +1,12 @@
/***** Support code for embedding *****/
-#if defined(_MSC_VER)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if defined(_WIN32)
# define CFFI_DLLEXPORT __declspec(dllexport)
#elif defined(__GNUC__)
# define CFFI_DLLEXPORT __attribute__((visibility("default")))
@@ -109,6 +114,8 @@
/********** CPython-specific section **********/
#ifndef PYPY_VERSION
+#include "_cffi_errors.h"
+
#define _cffi_call_python_org _cffi_exports[_CFFI_CPIDX]
@@ -220,8 +227,16 @@
/* Print as much information as potentially useful.
Debugging load-time failures with embedding is not fun
*/
+ PyObject *ecap;
PyObject *exception, *v, *tb, *f, *modules, *mod;
PyErr_Fetch(&exception, &v, &tb);
+ ecap = _cffi_start_error_capture();
+ f = PySys_GetObject((char *)"stderr");
+ if (f != NULL && f != Py_None) {
+ PyFile_WriteString(
+ "Failed to initialize the Python-CFFI embedding logic:\n\n", f);
+ }
+
if (exception != NULL) {
PyErr_NormalizeException(&exception, &v, &tb);
PyErr_Display(exception, v, tb);
@@ -230,10 +245,9 @@
Py_XDECREF(v);
Py_XDECREF(tb);
- f = PySys_GetObject((char *)"stderr");
if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
- "\ncompiled with cffi version: 1.10.0"
+ "\ncompiled with cffi version: 1.11.0"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
@@ -249,6 +263,7 @@
PyFile_WriteObject(PySys_GetObject((char *)"path"), f, 0);
PyFile_WriteString("\n\n", f);
}
+ _cffi_stop_error_capture(ecap);
}
result = -1;
goto done;
@@ -515,3 +530,7 @@
#undef cffi_compare_and_swap
#undef cffi_write_barrier
#undef cffi_read_barrier
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -75,9 +75,10 @@
self._init_once_cache = {}
self._cdef_version = None
self._embedding = None
+ self._typecache = model.get_typecache(backend)
if hasattr(backend, 'set_ffi'):
backend.set_ffi(self)
- for name in backend.__dict__:
+ for name in list(backend.__dict__):
if name.startswith('RTLD_'):
setattr(self, name, getattr(backend, name))
#
@@ -393,12 +394,17 @@
More information about the pypy-commit
mailing list