forked from pool/python-pybind11
Accepting request 930182 from devel:languages:python
OBS-URL: https://build.opensuse.org/request/show/930182 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pybind11?expand=0&rev=14
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:8ff2fff22df038f5cd02cea8af56622bc67f5b64534f1b83b9f133b8366acff2
|
|
||||||
size 647954
|
|
3
pybind11-2.8.0.tar.gz
Normal file
3
pybind11-2.8.0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:9ca7770fc5453b10b00a4a2f99754d7a29af8952330be5f5602e7c2635fa3e79
|
||||||
|
size 688544
|
@@ -1,3 +1,203 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Oct 16 20:47:43 UTC 2021 - Stefan Schubert <schubi@suse.de>
|
||||||
|
|
||||||
|
- Use libalternatives instead of update-alternatives.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Oct 16 19:47:43 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
||||||
|
|
||||||
|
- Update to v2.8.0
|
||||||
|
* Added py::raise_from to enable chaining exceptions. #3215
|
||||||
|
* Allow exception translators to be optionally registered local
|
||||||
|
to a module instead of applying globally across all pybind11
|
||||||
|
modules. Use
|
||||||
|
register_local_exception_translator(ExceptionTranslator&&
|
||||||
|
translator) instead of
|
||||||
|
register_exception_translator(ExceptionTranslator&& translator)
|
||||||
|
to keep your exception remapping code local to the module.
|
||||||
|
#2650
|
||||||
|
* Add make_simple_namespace function for instantiating Python
|
||||||
|
SimpleNamespace objects. #2840
|
||||||
|
* pybind11::scoped_interpreter and initialize_interpreter have
|
||||||
|
new arguments to allow sys.argv initialization. #2341
|
||||||
|
* Allow Python builtins to be used as callbacks in CPython. #1413
|
||||||
|
* Added view to view arrays with a different datatype. #987
|
||||||
|
* Implemented reshape on arrays. #984
|
||||||
|
* Enable defining custom __new__ methods on classes by fixing bug
|
||||||
|
preventing overriding methods if they have non-pybind11
|
||||||
|
siblings. #3265
|
||||||
|
* Add make_value_iterator(), and fix make_key_iterator() to
|
||||||
|
return references instead of copies. #3293
|
||||||
|
* Improve the classes generated by bind_map: #3310
|
||||||
|
* Change .items from an iterator to a dictionary view.
|
||||||
|
* Add .keys and .values (both dictionary views).
|
||||||
|
* Allow __contains__ to take any object.
|
||||||
|
* pybind11::custom_type_setup was added, for customizing the
|
||||||
|
PyHeapTypeObject corresponding to a class, which may be useful
|
||||||
|
for enabling garbage collection support, among other things.
|
||||||
|
#3287
|
||||||
|
* Set __file__ constant when running eval_file in an embedded
|
||||||
|
interpreter. #3233
|
||||||
|
* Python objects and (C++17) std::optional now accepted in
|
||||||
|
py::slice constructor. #1101
|
||||||
|
* The pybind11 proxy types str, bytes, bytearray, tuple, list now
|
||||||
|
consistently support passing ssize_t values for sizes and
|
||||||
|
indexes. Previously, only size_t was accepted in several
|
||||||
|
interfaces. #3219
|
||||||
|
* Avoid evaluating PYBIND11_TLS_REPLACE_VALUE arguments more than
|
||||||
|
once. #3290
|
||||||
|
* Bug fix: enum value's __int__ returning non-int when underlying
|
||||||
|
type is bool or of char type. #1334
|
||||||
|
* Fixes bug in setting error state in Capsule's pointer methods.
|
||||||
|
#3261
|
||||||
|
* A long-standing memory leak in py::cpp_function::initialize was
|
||||||
|
fixed. #3229
|
||||||
|
* Fixes thread safety for some pybind11::type_caster which
|
||||||
|
require lifetime extension, such as for std::string_view. #3237
|
||||||
|
* Restore compatibility with gcc 4.8.4 as distributed by
|
||||||
|
ubuntu-trusty, linuxmint-17. #3270
|
||||||
|
* Fix regression in CMake Python package config: improper use of
|
||||||
|
absolute path. #3144
|
||||||
|
* Cached Python version information could become stale when CMake
|
||||||
|
was re-run with a different Python version. The build system
|
||||||
|
now detects this and updates this information. #3299
|
||||||
|
* Specified UTF8-encoding in setup.py calls of open(). #3137
|
||||||
|
* Fix a harmless warning from CMake 3.21 with the classic Python
|
||||||
|
discovery. #3220
|
||||||
|
* Eigen repo and version can now be specified as cmake options.
|
||||||
|
#3324
|
||||||
|
* Reduced thread-local storage required for keeping alive
|
||||||
|
temporary data for type conversion to one key per ABI version,
|
||||||
|
rather than one key per extension module. This makes the total
|
||||||
|
thread-local storage required by pybind11 2 keys per ABI
|
||||||
|
version. #3275
|
||||||
|
* Optimize NumPy array construction with additional moves. #3183
|
||||||
|
* Conversion to std::string and std::string_view now avoids
|
||||||
|
making an extra copy of the data on Python >= 3.3. #3257
|
||||||
|
* Remove const modifier from certain C++ methods on Python
|
||||||
|
collections (list, set, dict) such as (clear(), append(),
|
||||||
|
insert(), etc...) and annotated them with py-non-const.
|
||||||
|
* Enable readability clang-tidy-const-return and remove useless
|
||||||
|
consts. #3254 #3194
|
||||||
|
* The clang-tidy google-explicit-constructor option was enabled.
|
||||||
|
#3250
|
||||||
|
* Mark a pytype move constructor as noexcept (perf). #3236
|
||||||
|
* Enable clang-tidy check to guard against inheritance slicing.
|
||||||
|
#3210
|
||||||
|
* Legacy warning suppression pragma were removed from eigen.h. On
|
||||||
|
Unix platforms, please use -isystem for Eigen include
|
||||||
|
directories, to suppress compiler warnings originating from
|
||||||
|
Eigen headers. Note that CMake does this by default. No
|
||||||
|
adjustments are needed for Windows. #3198
|
||||||
|
* Format pybind11 with isort consistent ordering of imports #3195
|
||||||
|
* The warnings-suppression "pragma clamp" at the top/bottom of
|
||||||
|
pybind11 was removed, clearing the path to refactoring and IWYU
|
||||||
|
cleanup. #3186
|
||||||
|
* Enable most bugprone checks in clang-tidy and fix the found
|
||||||
|
potential bugs and poor coding styles. #3166
|
||||||
|
* Add clang-tidy-readability rules to make boolean casts explicit
|
||||||
|
improving code readability. Also enabled other misc and
|
||||||
|
readability clang-tidy checks. #3148
|
||||||
|
* Move object in .pop() for list. #3116
|
||||||
|
- Release 2.7.1
|
||||||
|
* Allow Python builtins to be used as callbacks in CPython. #1413
|
||||||
|
* Fix regression in CMake Python package config: improper use of
|
||||||
|
absolute path. #3144
|
||||||
|
* Fix Mingw64 and add to the CI testing matrix. #3132
|
||||||
|
* Specified UTF8-encoding in setup.py calls of open(). #3137
|
||||||
|
* Add clang-tidy-readability rules to make boolean casts explicit
|
||||||
|
improving code readability. Also enabled other misc and
|
||||||
|
readability clang-tidy checks. #3148
|
||||||
|
* Move object in .pop() for list. #3116
|
||||||
|
* Removed and fixed warning suppressions. #3127 #3129 #3135 #3141
|
||||||
|
#3142 #3150 #3152 #3160 #3161
|
||||||
|
- Release 2.7.0
|
||||||
|
* Enable py::implicitly_convertible<py::none, ...> for
|
||||||
|
py::class_-wrapped types. #3059
|
||||||
|
* Allow function pointer extraction from overloaded functions.
|
||||||
|
#2944
|
||||||
|
* NumPy: added .char_() to type which gives the NumPy public char
|
||||||
|
result, which also distinguishes types by bit length (unlike
|
||||||
|
.kind()). #2864
|
||||||
|
* Add pybind11::bytearray to manipulate bytearray similar to
|
||||||
|
bytes. #2799
|
||||||
|
* pybind11/stl/filesystem.h registers a type caster that, on
|
||||||
|
C++17/Python 3.6+, converts std::filesystem::path to
|
||||||
|
pathlib.Path and any os.PathLike to std::filesystem::path.
|
||||||
|
#2730
|
||||||
|
* A PYBIND11_VERSION_HEX define was added, similar to
|
||||||
|
PY_VERSION_HEX. #3120
|
||||||
|
* py::str changed to exclusively hold PyUnicodeObject. Previously
|
||||||
|
py::str could also hold bytes, which is probably surprising,
|
||||||
|
was never documented, and can mask bugs (e.g. accidental use of
|
||||||
|
py::str instead of py::bytes). #2409
|
||||||
|
* Add a safety guard to ensure that the Python GIL is held when
|
||||||
|
C++ calls back into Python via object_api<>::operator() (e.g.
|
||||||
|
py::function __call__). (This feature is available for Python
|
||||||
|
3.6+ only.) #2919
|
||||||
|
* Catch a missing self argument in calls to __init__(). #2914
|
||||||
|
* Use std::string_view if available to avoid a copy when passing
|
||||||
|
an object to a std::ostream. #3042
|
||||||
|
* An important warning about thread safety was added to the
|
||||||
|
iostream.h documentation; attempts to make
|
||||||
|
py::scoped_ostream_redirect thread safe have been removed, as
|
||||||
|
it was only partially effective. #2995
|
||||||
|
* Performance: avoid unnecessary strlen calls. #3058
|
||||||
|
* Fix auto-generated documentation string when using const T in
|
||||||
|
pyarray_t. #3020
|
||||||
|
* Unify error messages thrown by
|
||||||
|
simple_collector/unpacking_collector. #3013
|
||||||
|
* pybind11::builtin_exception is now explicitly exported, which
|
||||||
|
means the types included/defined in different modules are
|
||||||
|
identical, and exceptions raised in different modules can be
|
||||||
|
caught correctly. The documentation was updated to explain that
|
||||||
|
custom exceptions that are used across module boundaries need
|
||||||
|
to be explicitly exported as well. #2999
|
||||||
|
* Fixed exception when printing UTF-8 to a
|
||||||
|
scoped_ostream_redirect. #2982
|
||||||
|
* Pickle support enhancement: setstate implementation will
|
||||||
|
attempt to setattr __dict__ only if the unpickled dict object
|
||||||
|
is not empty, to not force use of py::dynamic_attr()
|
||||||
|
unnecessarily. #2972
|
||||||
|
* Allow negative timedelta values to roundtrip. #2870
|
||||||
|
* Fix unchecked errors could potentially swallow signals/other
|
||||||
|
exceptions. #2863
|
||||||
|
* Add null pointer check with std::localtime. #2846
|
||||||
|
* Fix the weakref constructor from py::object to create a new
|
||||||
|
weakref on conversion. #2832
|
||||||
|
* Avoid relying on exceptions in C++17 when getting a shared_ptr
|
||||||
|
holder from a shared_from_this class. #2819
|
||||||
|
* Allow the codec's exception to be raised instead of
|
||||||
|
RuntimeError when casting from py::str to std::string. #2903
|
||||||
|
* In setup_helpers.py, test for platforms that have some
|
||||||
|
multiprocessing features but lack semaphores, which
|
||||||
|
ParallelCompile requires. #3043
|
||||||
|
* Fix pybind11_INCLUDE_DIR in case CMAKE_INSTALL_INCLUDEDIR is
|
||||||
|
absolute. #3005
|
||||||
|
* Fix bug not respecting WITH_SOABI or WITHOUT_SOABI to CMake.
|
||||||
|
#2938
|
||||||
|
* Fix the default Pybind11Extension compilation flags with a
|
||||||
|
Mingw64 python. #2921
|
||||||
|
* Clang on Windows: do not pass /MP (ignored flag). #2824
|
||||||
|
* pybind11.setup_helpers.intree_extensions can be used to
|
||||||
|
generate Pybind11Extension instances from cpp files placed in
|
||||||
|
the Python package source tree. #2831
|
||||||
|
* Enable clang-tidy performance, readability, and modernization
|
||||||
|
checks throughout the codebase to enforce best coding
|
||||||
|
practices. #3046, #3049, #3051, #3052, #3080, and #3094
|
||||||
|
* Checks for common misspellings were added to the pre-commit
|
||||||
|
hooks. #3076
|
||||||
|
* Changed Werror to stricter Werror-all for Intel compiler and
|
||||||
|
fixed minor issues. #2948
|
||||||
|
* Fixed compilation with GCC < 5 when the user defines
|
||||||
|
_GLIBCXX_USE_CXX11_ABI. #2956
|
||||||
|
* Added nox support for easier local testing and linting of
|
||||||
|
contributions. #3101 and #3121
|
||||||
|
* Avoid RTD style issue with docutils 0.17+. #3119
|
||||||
|
* Support pipx run, such as pipx run pybind11 --include for a
|
||||||
|
quick compile. #3117
|
||||||
|
- Drop unicode.patch merged upstream
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Jul 7 14:30:20 UTC 2021 - Markéta Machová <mmachova@suse.com>
|
Wed Jul 7 14:30:20 UTC 2021 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
@@ -16,24 +16,35 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
%if 0%{?suse_version} > 1500
|
||||||
|
%bcond_without libalternatives
|
||||||
|
%else
|
||||||
|
%bcond_with libalternatives
|
||||||
|
%endif
|
||||||
|
|
||||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||||
Name: python-pybind11
|
Name: python-pybind11
|
||||||
Version: 2.6.2
|
Version: 2.8.0
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: Module for operability between C++11 and Python
|
Summary: Module for operability between C++11 and Python
|
||||||
License: BSD-3-Clause
|
License: BSD-3-Clause
|
||||||
URL: https://github.com/pybind/pybind11
|
URL: https://github.com/pybind/pybind11
|
||||||
Source: https://github.com/pybind/pybind11/archive/v%{version}.tar.gz#/pybind11-%{version}.tar.gz
|
Source: https://github.com/pybind/pybind11/archive/v%{version}.tar.gz#/pybind11-%{version}.tar.gz
|
||||||
# PATCH-FIX-UPSTREAM https://github.com/pybind/pybind11/commit/0c93a0f3fcf6bf26be584558d7426564720cea6f Fix Unicode support for ostream redirects
|
|
||||||
Patch0: unicode.patch
|
|
||||||
BuildRequires: %{python_module devel}
|
BuildRequires: %{python_module devel}
|
||||||
BuildRequires: %{python_module pytest}
|
BuildRequires: %{python_module pytest}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: gcc-c++
|
BuildRequires: gcc-c++
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros >= 20210929
|
||||||
BuildRequires: %{python_module numpy if (%python-base without python36-base)}
|
BuildRequires: %{python_module numpy if (%python-base without python36-base)}
|
||||||
|
%if %{with libalternatives}
|
||||||
|
Requires: alts
|
||||||
|
BuildRequires: alts
|
||||||
|
%else
|
||||||
|
Requires(post): update-alternatives
|
||||||
|
Requires(postun):update-alternatives
|
||||||
|
%endif
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
%python_subpackages
|
%python_subpackages
|
||||||
|
|
||||||
@@ -61,7 +72,6 @@ This package contains files for developing applications using pybind11.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n pybind11-%{version}
|
%setup -q -n pybind11-%{version}
|
||||||
%autopatch -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
@@ -92,6 +102,10 @@ rm tests/test_embed/test_interpreter.py
|
|||||||
export PYTHONPATH=${PWD}/build/tests/
|
export PYTHONPATH=${PWD}/build/tests/
|
||||||
%pytest -k 'not (tests_build_wheel or tests_build_global_wheel)'
|
%pytest -k 'not (tests_build_wheel or tests_build_global_wheel)'
|
||||||
|
|
||||||
|
%pre
|
||||||
|
# If libalternatives is used: Removing old update-alternatives entries.
|
||||||
|
%python_libalternatives_reset_alternative pybind11-config
|
||||||
|
|
||||||
%post
|
%post
|
||||||
%python_install_alternative pybind11-config
|
%python_install_alternative pybind11-config
|
||||||
|
|
||||||
|
224
unicode.patch
224
unicode.patch
@@ -1,224 +0,0 @@
|
|||||||
From 0c93a0f3fcf6bf26be584558d7426564720cea6f Mon Sep 17 00:00:00 2001
|
|
||||||
From: Pieter P <pieter.pas@outlook.com>
|
|
||||||
Date: Tue, 4 May 2021 07:04:38 +0200
|
|
||||||
Subject: [PATCH] Fix Unicode support for ostream redirects (#2982)
|
|
||||||
|
|
||||||
* Crash when printing Unicode to redirected cout
|
|
||||||
Add failing tests
|
|
||||||
|
|
||||||
* Fix Unicode crashes redirected cout
|
|
||||||
|
|
||||||
* pythonbuf::utf8_remainder check end iterator
|
|
||||||
|
|
||||||
* Remove trailing whitespace and formatting iostream
|
|
||||||
|
|
||||||
* Avoid buffer overflow if ostream redirect races
|
|
||||||
This doesn't solve the actual race, but at least it now has a much lower
|
|
||||||
probability of reading past the end of the buffer even when data races
|
|
||||||
do occur.
|
|
||||||
---
|
|
||||||
include/pybind11/iostream.h | 75 ++++++++++++++++++++++++++-----
|
|
||||||
tests/test_iostream.py | 90 +++++++++++++++++++++++++++++++++++++
|
|
||||||
2 files changed, 153 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/pybind11/iostream.h b/include/pybind11/iostream.h
|
|
||||||
index 9dee755431..7c1c718b02 100644
|
|
||||||
--- a/include/pybind11/iostream.h
|
|
||||||
+++ b/include/pybind11/iostream.h
|
|
||||||
@@ -16,6 +16,9 @@
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
#include <iostream>
|
|
||||||
+#include <cstring>
|
|
||||||
+#include <iterator>
|
|
||||||
+#include <algorithm>
|
|
||||||
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
||||||
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
||||||
@@ -38,25 +41,73 @@ class pythonbuf : public std::streambuf {
|
|
||||||
return sync() == 0 ? traits_type::not_eof(c) : traits_type::eof();
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Computes how many bytes at the end of the buffer are part of an
|
|
||||||
+ // incomplete sequence of UTF-8 bytes.
|
|
||||||
+ // Precondition: pbase() < pptr()
|
|
||||||
+ size_t utf8_remainder() const {
|
|
||||||
+ const auto rbase = std::reverse_iterator<char *>(pbase());
|
|
||||||
+ const auto rpptr = std::reverse_iterator<char *>(pptr());
|
|
||||||
+ auto is_ascii = [](char c) {
|
|
||||||
+ return (static_cast<unsigned char>(c) & 0x80) == 0x00;
|
|
||||||
+ };
|
|
||||||
+ auto is_leading = [](char c) {
|
|
||||||
+ return (static_cast<unsigned char>(c) & 0xC0) == 0xC0;
|
|
||||||
+ };
|
|
||||||
+ auto is_leading_2b = [](char c) {
|
|
||||||
+ return static_cast<unsigned char>(c) <= 0xDF;
|
|
||||||
+ };
|
|
||||||
+ auto is_leading_3b = [](char c) {
|
|
||||||
+ return static_cast<unsigned char>(c) <= 0xEF;
|
|
||||||
+ };
|
|
||||||
+ // If the last character is ASCII, there are no incomplete code points
|
|
||||||
+ if (is_ascii(*rpptr))
|
|
||||||
+ return 0;
|
|
||||||
+ // Otherwise, work back from the end of the buffer and find the first
|
|
||||||
+ // UTF-8 leading byte
|
|
||||||
+ const auto rpend = rbase - rpptr >= 3 ? rpptr + 3 : rbase;
|
|
||||||
+ const auto leading = std::find_if(rpptr, rpend, is_leading);
|
|
||||||
+ if (leading == rbase)
|
|
||||||
+ return 0;
|
|
||||||
+ const auto dist = static_cast<size_t>(leading - rpptr);
|
|
||||||
+ size_t remainder = 0;
|
|
||||||
+
|
|
||||||
+ if (dist == 0)
|
|
||||||
+ remainder = 1; // 1-byte code point is impossible
|
|
||||||
+ else if (dist == 1)
|
|
||||||
+ remainder = is_leading_2b(*leading) ? 0 : dist + 1;
|
|
||||||
+ else if (dist == 2)
|
|
||||||
+ remainder = is_leading_3b(*leading) ? 0 : dist + 1;
|
|
||||||
+ // else if (dist >= 3), at least 4 bytes before encountering an UTF-8
|
|
||||||
+ // leading byte, either no remainder or invalid UTF-8.
|
|
||||||
+ // Invalid UTF-8 will cause an exception later when converting
|
|
||||||
+ // to a Python string, so that's not handled here.
|
|
||||||
+ return remainder;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
// This function must be non-virtual to be called in a destructor. If the
|
|
||||||
// rare MSVC test failure shows up with this version, then this should be
|
|
||||||
// simplified to a fully qualified call.
|
|
||||||
int _sync() {
|
|
||||||
- if (pbase() != pptr()) {
|
|
||||||
-
|
|
||||||
- {
|
|
||||||
- gil_scoped_acquire tmp;
|
|
||||||
-
|
|
||||||
+ if (pbase() != pptr()) { // If buffer is not empty
|
|
||||||
+ gil_scoped_acquire tmp;
|
|
||||||
+ // Placed inside gil_scoped_acquire as a mutex to avoid a race.
|
|
||||||
+ if (pbase() != pptr()) { // Check again under the lock
|
|
||||||
// This subtraction cannot be negative, so dropping the sign.
|
|
||||||
- str line(pbase(), static_cast<size_t>(pptr() - pbase()));
|
|
||||||
-
|
|
||||||
- pywrite(line);
|
|
||||||
- pyflush();
|
|
||||||
-
|
|
||||||
- // Placed inside gil_scoped_aquire as a mutex to avoid a race
|
|
||||||
+ auto size = static_cast<size_t>(pptr() - pbase());
|
|
||||||
+ size_t remainder = utf8_remainder();
|
|
||||||
+
|
|
||||||
+ if (size > remainder) {
|
|
||||||
+ str line(pbase(), size - remainder);
|
|
||||||
+ pywrite(line);
|
|
||||||
+ pyflush();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Copy the remainder at the end of the buffer to the beginning:
|
|
||||||
+ if (remainder > 0)
|
|
||||||
+ std::memmove(pbase(), pptr() - remainder, remainder);
|
|
||||||
setp(pbase(), epptr());
|
|
||||||
+ pbump(static_cast<int>(remainder));
|
|
||||||
}
|
|
||||||
-
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
diff --git a/tests/test_iostream.py b/tests/test_iostream.py
|
|
||||||
index 6d493beda3..e2b74d01cb 100644
|
|
||||||
--- a/tests/test_iostream.py
|
|
||||||
+++ b/tests/test_iostream.py
|
|
||||||
@@ -69,6 +69,96 @@ def test_captured_large_string(capsys):
|
|
||||||
assert stderr == ""
|
|
||||||
|
|
||||||
|
|
||||||
+def test_captured_utf8_2byte_offset0(capsys):
|
|
||||||
+ msg = "\u07FF"
|
|
||||||
+ msg = "" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_2byte_offset1(capsys):
|
|
||||||
+ msg = "\u07FF"
|
|
||||||
+ msg = "1" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_3byte_offset0(capsys):
|
|
||||||
+ msg = "\uFFFF"
|
|
||||||
+ msg = "" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_3byte_offset1(capsys):
|
|
||||||
+ msg = "\uFFFF"
|
|
||||||
+ msg = "1" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_3byte_offset2(capsys):
|
|
||||||
+ msg = "\uFFFF"
|
|
||||||
+ msg = "12" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_4byte_offset0(capsys):
|
|
||||||
+ msg = "\U0010FFFF"
|
|
||||||
+ msg = "" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_4byte_offset1(capsys):
|
|
||||||
+ msg = "\U0010FFFF"
|
|
||||||
+ msg = "1" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_4byte_offset2(capsys):
|
|
||||||
+ msg = "\U0010FFFF"
|
|
||||||
+ msg = "12" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_captured_utf8_4byte_offset3(capsys):
|
|
||||||
+ msg = "\U0010FFFF"
|
|
||||||
+ msg = "123" + msg * (1024 // len(msg) + 1)
|
|
||||||
+
|
|
||||||
+ m.captured_output_default(msg)
|
|
||||||
+ stdout, stderr = capsys.readouterr()
|
|
||||||
+ assert stdout == msg
|
|
||||||
+ assert stderr == ""
|
|
||||||
+
|
|
||||||
+
|
|
||||||
def test_guard_capture(capsys):
|
|
||||||
msg = "I've been redirected to Python, I hope!"
|
|
||||||
m.guard_output(msg)
|
|
Reference in New Issue
Block a user