GithubHelp home page GithubHelp logo

pallets / markupsafe Goto Github PK

View Code? Open in Web Editor NEW
598.0 598.0 147.0 705 KB

Safely add untrusted strings to HTML/XML markup.

Home Page: https://markupsafe.palletsprojects.com

License: BSD 3-Clause "New" or "Revised" License

Python 79.29% C 20.71%
html html-escape jinja markupsafe pallets python template-engine

markupsafe's People

Contributors

2-5 avatar adamchainz avatar ademan avatar amcgregor avatar cclauss avatar cito avatar dairiki avatar daverball avatar davidism avatar dawranliou avatar dependabot-preview[bot] avatar dependabot[bot] avatar dougthor42 avatar esadek avatar greyli avatar gtback avatar hugovk avatar janaknat avatar jaraco avatar jdufresne avatar lepture avatar methane avatar mitsuhiko avatar mthuurne avatar northernsage avatar pelme avatar pre-commit-ci[bot] avatar quobit avatar the-compiler avatar thiefmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markupsafe's Issues

`TypeError: 'NoneType' object is not iterable` when installing MarkupSafe v0.23 on MSYS2

I'm using MSYS2 (fork of Cygwin), Python 2.7.10, pip 7.1.2, msys2's gcc 4.9.2, on Windows 8.1 x64.

$ pip install sphinx
Collecting sphinx
  Using cached Sphinx-1.3.1-py2.py3-none-any.whl
Collecting sphinx-rtd-theme<0.2,>=0.1 (from sphinx)
  Using cached sphinx_rtd_theme-0.1.9-py2-none-any.whl
Collecting snowballstemmer>=1.1 (from sphinx)
Collecting six>=1.4 (from sphinx)
  Using cached six-1.9.0-py2.py3-none-any.whl
Collecting Pygments>=2.0 (from sphinx)
  Using cached Pygments-2.0.2-py2-none-any.whl
Collecting docutils>=0.11 (from sphinx)
Collecting babel>=1.3 (from sphinx)
Collecting Jinja2>=2.3 (from sphinx)
  Using cached Jinja2-2.8-py2.py3-none-any.whl
Collecting alabaster<0.8,>=0.7 (from sphinx)
  Using cached alabaster-0.7.6-py2-none-any.whl
Collecting pytz>=0a (from babel>=1.3->sphinx)
  Using cached pytz-2015.6-py2.py3-none-any.whl
Collecting MarkupSafe (from Jinja2>=2.3->sphinx)
  Using cached MarkupSafe-0.23.tar.gz
Building wheels for collected packages: MarkupSafe
  Running setup.py bdist_wheel for MarkupSafe
  Complete output from command /home/Ed/.virtualenvs/bugsy2/bin/python -c "import setuptools;__file__='/tmp/pip-build-wb1swt/MarkupSafe/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmp1FkDLRpip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.mingw32_nt-6.3-2.3.0(0.290
  creating build/lib.mingw32_nt-6.3-2.3.0(0.290/5
  creating build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7
  creating build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  copying markupsafe/tests.py -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  copying markupsafe/_compat.py -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  copying markupsafe/_constants.py -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  copying markupsafe/_native.py -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  copying markupsafe/__init__.py -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  running egg_info
  writing MarkupSafe.egg-info/PKG-INFO
  writing top-level names to MarkupSafe.egg-info/top_level.txt
  writing dependency_links to MarkupSafe.egg-info/dependency_links.txt
  warning: manifest_maker: standard file '-c' not found

  reading manifest file 'MarkupSafe.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'MarkupSafe.egg-info/SOURCES.txt'
  copying markupsafe/_speedups.c -> build/lib.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  running build_ext
  building 'markupsafe._speedups' extension
  creating build/temp.mingw32_nt-6.3-2.3.0(0.290
  creating build/temp.mingw32_nt-6.3-2.3.0(0.290/5
  creating build/temp.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7
  creating build/temp.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe
  gcc -mdll -O -Wall -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe/_speedups.o
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 120, in <module>
      try_building_extension()
    File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 99, in try_building_extension
      run_setup(True)
    File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 93, in run_setup
      ext_modules=ext_modules,
    File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/home/Ed/.virtualenvs/bugsy2/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 175, in run
      self.run_command('build')
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/usr/lib/python2.7/distutils/command/build.py", line 127, in run
      self.run_command(cmd_name)
    File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 41, in run
      build_ext.run(self)
    File "/usr/lib/python2.7/distutils/command/build_ext.py", line 337, in run
      self.build_extensions()
    File "/usr/lib/python2.7/distutils/command/build_ext.py", line 446, in build_extensions
      self.build_extension(ext)
    File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 47, in build_extension
      build_ext.build_extension(self, ext)
    File "/usr/lib/python2.7/distutils/command/build_ext.py", line 528, in build_extension
      target_lang=language)
    File "/usr/lib/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
      extra_preargs, extra_postargs, build_temp, target_lang)
    File "/usr/lib/python2.7/distutils/cygwinccompiler.py", line 189, in link
      libraries.extend(self.dll_libraries)
  TypeError: 'NoneType' object is not iterable

  ----------------------------------------
  Failed building wheel for MarkupSafe
Failed to build MarkupSafe
Installing collected packages: sphinx-rtd-theme, snowballstemmer, six, Pygments, docutils, pytz, babel, MarkupSafe, Jinja2, alabaster, sphinx
  Running setup.py install for MarkupSafe
    Complete output from command /home/Ed/.virtualenvs/bugsy2/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-wb1swt/MarkupSafe/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wPGgLg-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/Ed/.virtualenvs/bugsy2/include/site/python2.7/MarkupSafe:
    running install
    running build
    running build_py
    running egg_info
    writing MarkupSafe.egg-info/PKG-INFO
    writing top-level names to MarkupSafe.egg-info/top_level.txt
    writing dependency_links to MarkupSafe.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'MarkupSafe.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'MarkupSafe.egg-info/SOURCES.txt'
    running build_ext
    building 'markupsafe._speedups' extension
    gcc -mdll -O -Wall -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.mingw32_nt-6.3-2.3.0(0.290/5/3)-x86_64-2.7/markupsafe/_speedups.o
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 120, in <module>
        try_building_extension()
      File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 99, in try_building_extension
        run_setup(True)
      File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 93, in run_setup
        ext_modules=ext_modules,
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/home/Ed/.virtualenvs/bugsy2/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 41, in run
        build_ext.run(self)
      File "/usr/lib/python2.7/distutils/command/build_ext.py", line 337, in run
        self.build_extensions()
      File "/usr/lib/python2.7/distutils/command/build_ext.py", line 446, in build_extensions
        self.build_extension(ext)
      File "/tmp/pip-build-wb1swt/MarkupSafe/setup.py", line 47, in build_extension
        build_ext.build_extension(self, ext)
      File "/usr/lib/python2.7/distutils/command/build_ext.py", line 528, in build_extension
        target_lang=language)
      File "/usr/lib/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
        extra_preargs, extra_postargs, build_temp, target_lang)
      File "/usr/lib/python2.7/distutils/cygwinccompiler.py", line 189, in link
        libraries.extend(self.dll_libraries)
    TypeError: 'NoneType' object is not iterable

    ----------------------------------------
Command "/home/Ed/.virtualenvs/bugsy2/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-wb1swt/MarkupSafe/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-wPGgLg-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/Ed/.virtualenvs/bugsy2/include/site/python2.7/MarkupSafe" failed with error code 1 in /tmp/pip-build-wb1swt/MarkupSafe

TypeError: object.__new__(Markup) is not safe, use unicode.__new__() in specific cases

Hi,

I am currently struggling with a pretty weird bug. It only appears in specific situations.

When I run a test via sniffer on a sadly not-that-small example, I get the following error every time except the first run. (Re-run can be triggered by touching e.g the application.py file)
TypeError: object.__new__(Markup) is not safe, use unicode.__new__()

I filed an issue over at flask's, but I was hoping you guys could take a look, too.
It's at pallets/flask#1700 and I'd suggest discussing it over there for now.

Error while installing in Windows 7

I'm getting this error while installing the package in Windows 7. Maybe has something to do with my windows username, which has a non-ASCII character.

>> python setup.py install
running install
running bdist_egg
running egg_info
writing MarkupSafe.egg-info\PKG-INFO
writing top-level names to MarkupSafe.egg-info\top_level.txt
writing dependency_links to MarkupSafe.egg-info\dependency_links.txt
reading manifest file 'MarkupSafe.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MarkupSafe.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
running build_ext
building 'markupsafe._speedups' extension
Traceback (most recent call last):
  File "setup.py", line 120, in <module>
    try_building_extension()
  File "setup.py", line 99, in try_building_extension
    run_setup(True)
  File "setup.py", line 93, in run_setup
    ext_modules=ext_modules,
  File "C:\python27\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "build\bdist.win32\egg\setuptools\command\install.py", line 67, in run
  File "build\bdist.win32\egg\setuptools\command\install.py", line 109, in do_egg_install
  File "C:\python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "build\bdist.win32\egg\setuptools\command\bdist_egg.py", line 160, in run
  File "build\bdist.win32\egg\setuptools\command\bdist_egg.py", line 146, in call_command
  File "C:\python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "build\bdist.win32\egg\setuptools\command\install_lib.py", line 10, in run
  File "C:\python27\lib\distutils\command\install_lib.py", line 111, in build
    self.run_command('build_ext')
  File "C:\python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 41, in run
    build_ext.run(self)
  File "C:\python27\lib\distutils\command\build_ext.py", line 337, in run
    self.build_extensions()
  File "C:\python27\lib\distutils\command\build_ext.py", line 446, in build_extensions
    self.build_extension(ext)
  File "setup.py", line 47, in build_extension
    build_ext.build_extension(self, ext)
  File "C:\python27\lib\distutils\command\build_ext.py", line 496, in build_extension
    depends=ext.depends)
  File "C:\python27\lib\distutils\msvc9compiler.py", line 473, in compile
    self.initialize()
  File "C:\python27\lib\distutils\msvc9compiler.py", line 383, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "build\bdist.win32\egg\setuptools\msvc9_support.py", line 52, in query_vcvarsall
  File "C:\python27\lib\distutils\msvc9compiler.py", line 275, in query_vcvarsall
    stderr=subprocess.PIPE)
  File "C:\python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 15:
 ordinal not in range(128)

Failed installation on Mint/Ubuntu for python3

This error is shown:

error: Setup script exited with error: in 'ext_modules' option (extension 'markupsafe._speedups'), 'sources' must be present and must be a list of source filenames

This is what I tried:

  • Installing in jinja2 (whuch is what I need);
  • Installing using pip3;
  • Installing by python3 setup.py (using newest source release).

Below is the log of setup.py installation.

sudo python3 setup.py install
running install
Checking .pth file support in /usr/local/lib/python3.3/dist-packages/
/usr/bin/python3 -E -c pass
TEST PASSED: /usr/local/lib/python3.3/dist-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing MarkupSafe.egg-info/PKG-INFO
writing dependency_links to MarkupSafe.egg-info/dependency_links.txt
writing top-level names to MarkupSafe.egg-info/top_level.txt
reading manifest file 'MarkupSafe.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MarkupSafe.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
running build_ext
error: in 'ext_modules' option (extension 'markupsafe._speedups'), 'sources' must be present and must be a list of source filenames

Building error

pip install MarkupSafe

Issue: Successfully installed even though something Failed
How to reproduce: pip install MarkupSafe

Python version: 3.5.1

 running install_egg_info
  Copying MarkupSafe.egg-info to build/bdist.macosx-10.11-x86_64/wheel/MarkupSafe-0.23-py3.5.egg-info
 running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/s_/8qs7_w993rvbqpr1x580j8_40000gn/T/pip-build-q6aenb1b/MarkupSafe/setup.py", line 120, in <module>
      try_building_extension()
    File "/private/var/folders/s_/8qs7_w993rvbqpr1x580j8_40000gn/T/pip-build-q6aenb1b/MarkupSafe/setup.py", line 99, in try_building_extension
      run_setup(True)
    File "/private/var/folders/s_/8qs7_w993rvbqpr1x580j8_40000gn/T/pip-build-q6aenb1b/MarkupSafe/setup.py", line 93, in run_setup
      ext_modules=ext_modules,
    File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/Users/martin/Projects/xplainbox-wrapper-hdfs/.venv/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 213, in run
      archive_basename = self.get_archive_basename()
    File "/Users/martin/Projects/xplainbox-wrapper-hdfs/.venv/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 161, in get_archive_basename
      impl_tag, abi_tag, plat_tag = self.get_tag()
    File "/Users/martin/Projects/xplainbox-wrapper-hdfs/.venv/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 155, in get_tag
      assert tag == supported_tags[0]
  AssertionError
  ----------------------------------------
  Failed building wheel for MarkupSafe
  Running setup.py clean for MarkupSafe
Failed to build MarkupSafe
Installing collected packages: MarkupSafe
  Running setup.py install for MarkupSafe ... done
Successfully installed MarkupSafe-0.23

improved docs about this project's provenance

It would be nice if the README and github config noted this is now the "official" repo for markupsafe.

It took me an absurd amount of time to realize this wasn't a fork of pocoo or Armin Ronacher's repo... but actually the same official repo under a new name.

There's still a lot of Search Engine equity on the pocoo pages (e.g http://www.pocoo.org/projects/markupsafe ) and mitsuhiko repo ( http://github.com/mitsuhiko/markupsafe ), and that all makes it seem like pallets is some scammy forked repo.

New version

Hello! Is project alive?
I see so much commits after 0.23 release in 2014, but there are no any new releases in PyPi.

Can you release next version?

Build without speedups

I've been building MarkupSafe using the --without-speedups option, because I have a requirement to distribute this module across various OSes in my network. All, of a sudden, I now see that this option is no longer available for setup.py. How can I build a pure-python setup without building the C extension, for distribution, as I previously did?

Broken on OS X 10.10 Yosemite: ImportError: No module named _compat

git clone https://github.com/mitsuhiko/markupsafe.git
cd markupsafe
python setup.py build
cd build/lib.macosx-10.10-x86_64-2.7/markupsafe
python tests.py
Traceback (most recent call last):
  File "tests.py", line 5, in <module>
    from markupsafe import Markup, escape, escape_silent
  File "/Library/Python/2.7/site-packages/markupsafe/__init__.py", line 14, in <module>
    from markupsafe._compat import text_type, string_types, int_types, \
ImportError: No module named _compat

C extension build fails on osx with: unknown argument: '-mno-fused-madd'

Running pip install markupsafe with python 2.7.5 on OSX 10.9.2 fails with the output below. The install does succeed without the C extension despite this, but I thought I'd file this issue to see if this can be resolved.

Downloading/unpacking markupsafe
  Downloading MarkupSafe-0.19.tar.gz
  Running setup.py egg_info for package markupsafe

Installing collected packages: markupsafe
  Running setup.py install for markupsafe

    building 'markupsafe._speedups' extension
    cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c markupsafe/_speedups.c -o build/temp.macosx-10.9-intel-2.7/markupsafe/_speedups.o
    clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
    clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.


    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python installation succeeded.
    ==========================================================================
Successfully installed markupsafe
Cleaning up...

Cannot import markupsafe in Python 3.1 or 3.2 due to explicit unicode literals

I cannot import markupsafe in Python 3.1 or 3.2. This is because it uses explicit unicode literals in a few places, which were absent in Python 3.1 and 3.2 but restored in Python 3.3.

$ python3.2
Python 3.2.5 (default, Nov 18 2013, 15:24:38) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import markupsafe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/markupsafe/__init__.py", line 70
    def __new__(cls, base=u'', encoding=None, errors='strict'):
                            ^
SyntaxError: invalid syntax

Could this be either fixed, or else the limitation to Python <= 2.7 or >= 3.3 documented in the README file and the PyPI classifiers?

Features are deprecated - MarkupSafe fails to install with setuptools 3.0

See this ticket for details behind the deprecation and subsequent removal of the feature. Setuptools 3.0 is in beta now and if released will raise an ImportError if MarkupSafe relies on the feature.

My understanding was the Feature feature was not widely used, so I was surprised to see it used in MarkupSafe.

Would someone explore the impact of removing the Feature from MarkupSafe?

version info not available at runtime

There doesn't seem to be any way to get information about the version of markupsafe (e.g. version number) at runtime.
Usually the version number of modules is available via a 'version' attribute on the module object but such does not appear to exist.

I need this version info so that my superinstaller can determine if the user already has the latest version of markupsafe.

Fails to install on Debian 9 docker images

Steps to reproduce:

  1. have a Debian 9 docker image
  2. make sure that python-pip is installed from apt-get
  3. run pip install -U pip to get a working pip version
  4. run pip install sphinx

What happens:
During installing dependencies of sphinx, pip tries to install MarkupSafe. This step fails:

Collecting MarkupSafe>=0.23 (from Jinja2>=2.3->sphinx)
  Downloading MarkupSafe-1.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-CzgXau/MarkupSafe/

What should happen:
Install fine.

Additional info:
I think your package is missing a dependency on setuptools so that pip knows to install it before MarkupSafe.
You might also have a look at this docker log: https://travis-ci.org/exaile/exaile-testimg/builds/298234174?utm_source=github_status&utm_medium=notification

unable to install to windows 7

Dear all,

I'm not able to install markupSafe in windows7. I ran the script: pip install markupsafe and i had the following output:

image

It looks like it can not find the path or some the files.

Could you please support me?

Best,
Paolo

AssertionError while building wheel on 3.5

Installing markupsafe 0.23 on Python 3.5 results in AssertionError when building wheel. 3.4 is fine.

$ python -c 'import sys; print(sys.version_info)'
sys.version_info(major=3, minor=5, micro=1, releaselevel='final', serial=0)
$ pip install markupsafe
Collecting markupsafe
  Using cached MarkupSafe-0.23.tar.gz
Building wheels for collected packages: markupsafe
  Running setup.py bdist_wheel for markupsafe
  Complete output from command /home/dominik/.virtualenvs/markupsafe/bin/python3.5 -c "import setuptools;__file__='/tmp/pip-build-dsnw5xme/markupsafe/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpujl60qh6pip-wheel-:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/markupsafe
  copying markupsafe/tests.py -> build/lib.linux-x86_64-3.5/markupsafe
  copying markupsafe/_compat.py -> build/lib.linux-x86_64-3.5/markupsafe
  copying markupsafe/_native.py -> build/lib.linux-x86_64-3.5/markupsafe
  copying markupsafe/__init__.py -> build/lib.linux-x86_64-3.5/markupsafe
  copying markupsafe/_constants.py -> build/lib.linux-x86_64-3.5/markupsafe
  running egg_info
  writing MarkupSafe.egg-info/PKG-INFO
  writing top-level names to MarkupSafe.egg-info/top_level.txt
  writing dependency_links to MarkupSafe.egg-info/dependency_links.txt
  warning: manifest_maker: standard file '-c' not found

  reading manifest file 'MarkupSafe.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'MarkupSafe.egg-info/SOURCES.txt'
  copying markupsafe/_speedups.c -> build/lib.linux-x86_64-3.5/markupsafe
  running build_ext
  building 'markupsafe._speedups' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/markupsafe
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/home/dominik/.virtualenvs/markupsafe/include/python3.5m -c markupsafe/_speedups.c -o build/temp.linux-x86_64-3.5/markupsafe/_speedups.o
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/markupsafe/_speedups.o -o build/lib.linux-x86_64-3.5/markupsafe/_speedups.cpython-35m-x86_64-linux-gnu.so
  installing to build/bdist.linux-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.linux-x86_64
  creating build/bdist.linux-x86_64/wheel
  creating build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/tests.py -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/_compat.py -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/_native.py -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/__init__.py -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/_speedups.c -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/_constants.py -> build/bdist.linux-x86_64/wheel/markupsafe
  copying build/lib.linux-x86_64-3.5/markupsafe/_speedups.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/wheel/markupsafe
  running install_egg_info
  Copying MarkupSafe.egg-info to build/bdist.linux-x86_64/wheel/MarkupSafe-0.23-py3.5.egg-info
  running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-dsnw5xme/markupsafe/setup.py", line 120, in <module>
      try_building_extension()
    File "/tmp/pip-build-dsnw5xme/markupsafe/setup.py", line 99, in try_building_extension
      run_setup(True)
    File "/tmp/pip-build-dsnw5xme/markupsafe/setup.py", line 93, in run_setup
      ext_modules=ext_modules,
    File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/dominik/.virtualenvs/markupsafe/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 213, in run
      archive_basename = self.get_archive_basename()
    File "/home/dominik/.virtualenvs/markupsafe/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 161, in get_archive_basename
      impl_tag, abi_tag, plat_tag = self.get_tag()
    File "/home/dominik/.virtualenvs/markupsafe/lib/python3.5/site-packages/wheel/bdist_wheel.py", line 155, in get_tag
      assert tag == supported_tags[0]
  AssertionError

  ----------------------------------------
  Failed building wheel for markupsafe
Failed to build markupsafe
Installing collected packages: markupsafe
  Running setup.py install for markupsafe
Successfully installed markupsafe-0.23

markupsafe/_speedups.c:214: fatal error: error writing to -: Broken pipe

% pip install MarkupSafe 
Downloading/unpacking MarkupSafe
  Downloading MarkupSafe-0.15.tar.gz
  Running setup.py egg_info for package MarkupSafe
Installing collected packages: MarkupSafe
  Running setup.py install for MarkupSafe
    building 'markupsafe._speedups' extension
    gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c markupsafe/_speedups.c -o build/temp.macosx-10.6-universal-2.6/markupsafe/_speedups.o
    /usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
    Installed assemblers are:
    /usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
    /usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
    markupsafe/_speedups.c:214: fatal error: error writing to -: Broken pipe
    compilation terminated.
    lipo: can't open input file: /var/folders/MT/MTdESo89GBCaGM7Hevp5+E+++TI/-Tmp-//ccGEE6po.out (No such file or directory)
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.

    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python installation succeeded.
    ==========================================================================
Successfully installed MarkupSafe
Cleaning up...

markupsafe.tests.MarkupTestCase.test_dict_interpol() fails with Python 3

$ python3.3 setup.py test
...
======================================================================
ERROR: test_dict_interpol (markupsafe.tests.MarkupTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/MarkupSafe-0.17/markupsafe/tests.py", line 57, in test_dict_interpol
    self.assertEqual(unicode(Markup('<em>%(foo)s:%(bar)s</em>') % {
NameError: global name 'unicode' is not defined

----------------------------------------------------------------------
Ran 10 tests in 0.390s

FAILED (errors=1)

Syntax error

python version : 3.2.3
system : debian 7

Hi,

I have installed Jinja2 (for dependancy requirement of Ipython) from the debian repository which install markupsafe. When i try to use Ipython notebook or import jinja2 in python3 or markupsafe an exception is raised :

import jinja2
File "/usr/local/lib/python3.2/dist-packages/MarkupSafe-0.21-py3.2-linux-x86_64.egg/markupsafe/init.py", line 69
def new(cls, base=u'', encoding=None, errors='strict'):
^
SyntaxError: invalid syntax

How can i deal with it?

set zip_safe=True in setup.py

Based on some limited testing, setting zip_safe=True and running python setup.py bdist_egg produces a working egg on OS X 10.7 with Python 2.7. To speed up our builds, I'd like to stick some eggs onto our internal PyPI server.

Won't install on Windows

Python 3.6 (x86-64)
pip == 9.0.1
setuptools == 34.3.2

(no36) D:\Git\project>pip install --force --upgrade markupsafe
Collecting markupsafe
  Using cached MarkupSafe-1.0.tar.gz
Building wheels for collected packages: markupsafe
  Running setup.py bdist_wheel for markupsafe ... error
  Failed building wheel for markupsafe
  Running setup.py clean for markupsafe
Failed to build markupsafe
Installing collected packages: markupsafe
  Found existing installation: markupsafe 1.0
    Uninstalling markupsafe-1.0:
      Successfully uninstalled markupsafe-1.0
  Running setup.py install for markupsafe ... error
  Rolling back uninstall of markupsafe
Exception:
Traceback (most recent call last):
  File "d:\python\no36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 66: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python\no36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "d:\python\no36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "d:\python\no36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "d:\python\no36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "d:\python\no36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "d:\python\no36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 66: invalid continuation byte

Markup.replace shouldn't escape its arguments

Markup.replace incorrectly escapes its arguments:

>>> m = Markup('The cow says "Moo".')
>>> print m
The cow says "Moo".
>>> print m.replace('"Moo"', 'nothing at all') # does nothing
The cow says "Moo".
>>> print m.replace('Moo', 'I don\'t know') # over-escapes
The cow says "I don&#39;t know".

The first replace fails because instead of searching for '"Moo"' it escapes the quotes and searches for '"Moo"'.

The second replace escapes the apostrophe.

proposal: escape backspace ascii control character

When inputting the backspace ascii control character sequence \b, it will remain a control character (\x08) when run through escape. I propose escaping \x08 to the string sequence \b.

The current behavior can allow for malicious users to create carefully crafted HTML strings in certain contexts. as \x08 is a non-printing character in most GUI browsers, but will still copy to the system clipboard as part of selected text.

For example, a markupsafe-escaped string on a sample of code entered into a bugtracking application might be import y\bose\bm\bi\bt\be\b , which renders as import yosemite in HTML; if copied/pasted into a Python (or Ruby, or several other language's) interpreter - the backspace will be interpreted and the executed line will become import os.

I understand this is beyond HTML as it involves the secondary usage of content generated by markupsafe -- and not the initial rendering. This may not be the most appropriate place to address this usage case, but I was surprised to find raw ASCII control characters in a "HTML" string.

Pip install TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

This works fine with 2.7.6. I have setuptools installed with this 2.7.2, so it's probably that.

$ /software/Python/272/bin/pip install MarkupSafe
Downloading/unpacking MarkupSafe
  Downloading MarkupSafe-0.23.tar.gz
  Running setup.py (path:/tmp/pip_build_joe.borg/MarkupSafe/setup.py) egg_info for package MarkupSafe

Installing collected packages: MarkupSafe
  Running setup.py install for MarkupSafe

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 120, in <module>
        try_building_extension()
      File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 99, in try_building_extension
        run_setup(True)
      File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 93, in run_setup
        ext_modules=ext_modules,
      File "/software/Python/272/lib/python2.7/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/software/Python/272/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/software/Python/272/lib/python2.7/site-packages/setuptools/command/install.py", line 59, in run
        return orig.install.run(self)
      File "/software/Python/272/lib/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/software/Python/272/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/software/Python/272/lib/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/software/Python/272/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 41, in run
        build_ext.run(self)
      File "/software/Python/272/lib/python2.7/distutils/command/build_ext.py", line 310, in run
        customize_compiler(self.compiler)
      File "/software/Python/272/lib/python2.7/distutils/sysconfig.py", line 165, in customize_compiler
        cpp = cc + " -E"           # not always
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    Complete output from command /software/Python/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_joe.borg/MarkupSafe/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-nIB1r6-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/markupsafe

copying markupsafe/_native.py -> build/lib.linux-x86_64-2.7/markupsafe

copying markupsafe/__init__.py -> build/lib.linux-x86_64-2.7/markupsafe

copying markupsafe/_compat.py -> build/lib.linux-x86_64-2.7/markupsafe

copying markupsafe/tests.py -> build/lib.linux-x86_64-2.7/markupsafe

copying markupsafe/_constants.py -> build/lib.linux-x86_64-2.7/markupsafe

running egg_info

writing MarkupSafe.egg-info/PKG-INFO

writing top-level names to MarkupSafe.egg-info/top_level.txt

writing dependency_links to MarkupSafe.egg-info/dependency_links.txt

warning: manifest_maker: standard file '-c' not found



reading manifest file 'MarkupSafe.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

writing manifest file 'MarkupSafe.egg-info/SOURCES.txt'

copying markupsafe/_speedups.c -> build/lib.linux-x86_64-2.7/markupsafe

running build_ext

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 120, in <module>

    try_building_extension()

  File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 99, in try_building_extension

    run_setup(True)

  File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 93, in run_setup

    ext_modules=ext_modules,

  File "/software/Python/272/lib/python2.7/distutils/core.py", line 152, in setup

    dist.run_commands()

  File "/software/Python/272/lib/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/software/Python/272/lib/python2.7/site-packages/setuptools/command/install.py", line 59, in run

    return orig.install.run(self)

  File "/software/Python/272/lib/python2.7/distutils/command/install.py", line 563, in run

    self.run_command('build')

  File "/software/Python/272/lib/python2.7/distutils/cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/software/Python/272/lib/python2.7/distutils/command/build.py", line 127, in run

    self.run_command(cmd_name)

  File "/software/Python/272/lib/python2.7/distutils/cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "/software/Python/272/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/tmp/pip_build_joe.borg/MarkupSafe/setup.py", line 41, in run

    build_ext.run(self)

  File "/software/Python/272/lib/python2.7/distutils/command/build_ext.py", line 310, in run

    customize_compiler(self.compiler)

  File "/software/Python/272/lib/python2.7/distutils/sysconfig.py", line 165, in customize_compiler

    cpp = cc + " -E"           # not always

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

setuptools>=24.0.0 breaks pip install markupsafe on Windows

λ pip install --no-cache-dir markupsafe==0.23
Collecting markupsafe==0.23
  Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: markupsafe
  Running setup.py install for markupsafe ... error
    Complete output from command x:\markupsafe\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\****\\appdata\\local\\temp\\pip-build-fkfjcg\\markupsafe\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\****\appdata\local\temp\pip-oxjuvx-record\install-record.txt --single-version-externally-managed --compile --install-headers x:\markupsafe\include\site\python2.7\markupsafe:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-2.7
    creating build\lib.win32-2.7\markupsafe
    copying markupsafe\tests.py -> build\lib.win32-2.7\markupsafe
    copying markupsafe\_compat.py -> build\lib.win32-2.7\markupsafe
    copying markupsafe\_constants.py -> build\lib.win32-2.7\markupsafe
    copying markupsafe\_native.py -> build\lib.win32-2.7\markupsafe
    copying markupsafe\__init__.py -> build\lib.win32-2.7\markupsafe
    running egg_info
    writing MarkupSafe.egg-info\PKG-INFO
    writing top-level names to MarkupSafe.egg-info\top_level.txt
    writing dependency_links to MarkupSafe.egg-info\dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'MarkupSafe.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'MarkupSafe.egg-info\SOURCES.txt'
    copying markupsafe\_speedups.c -> build\lib.win32-2.7\markupsafe
    running build_ext
    building 'markupsafe._speedups' extension
    error: [Error 2] The system cannot find the file specified

    ----------------------------------------
Command "x:\markupsafe\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\****\\appdata\\local\\temp\\pip-build-fkfjcg\\markupsafe\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\****\appdata\local\temp\pip-oxjuvx-record\install-record.txt --single-version-externally-managed --compile --install-headers x:\markupsafe\include\site\python2.7\markupsafe" failed with error code 1 in c:\users\****\appdata\local\temp\pip-build-fkfjcg\markupsafe

If I downgrade it works fine:

λ pip install setuptools==23.2.1
Collecting setuptools==23.2.1
  Using cached setuptools-23.2.1-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 24.1.0
    Uninstalling setuptools-24.1.0:
      Successfully uninstalled setuptools-24.1.0
Successfully installed setuptools-23.2.1

(markupsafe) X:\
λ pip install --no-cache-dir markupsafe==0.23
Collecting markupsafe==0.23
  Downloading MarkupSafe-0.23.tar.gz
Installing collected packages: markupsafe
  Running setup.py install for markupsafe ... done
Successfully installed markupsafe-0.23

From the comments in the setup.py I assume this isn't surprising. Should I just wait till setuptools is updated again?

Markup.partition is broken

>>> Markup('abc__def').partition('__')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable

Enable stack cookies for C speedups

Hi,

I was running a vulnerability scan for one of the EC2 Instance in AWS and during the scan there was one reported against markupsafe. The detail is as below

Rules package
Runtime Behavior Analysis-1.0

Finding
The following executable files on instance do not support stack cookies: /lib/python2.7/site-packages/markupsafe/_speedups.so.

Severity Medium

Description
This rule detects the presence of third-party software that is compiled without support for stack cookies. Stack cookies increase system security by defending against stack-based buffer overflow and other memory corruption attacks.

Recommendation
It is recommended that you uninstall this software from your assessment target if you are not using it, or contact the vendor to get an updated version of this software with stack cookies enabled.

FYI It s a Django 1.10 stack using Jinja2 which has markupsafe as required package. The version installed of MarkupSafe is 0.23.

Flask-restful installation stuck at markupsafe

I am trying to install Flash-restful on a 10.10.2 Yosemite with Python 2.7.6. The installation is paused after this line:

Installing collected packages: markupsafe, itsdangerous, Jinja2, Werkzeug, aniso8601, Flask, flask-restful
  Running setup.py install for markupsafe

Here is the full log:

Amirs-MacBook:etc amir$ pip install flask-restful
Collecting flask-restful
  Using cached Flask_RESTful-0.3.2-py2.py3-none-any.whl
Collecting Flask>=0.8 (from flask-restful)
  Using cached Flask-0.10.1.tar.gz
    Not SVN Repository
Collecting aniso8601>=0.82 (from flask-restful)
  Using cached aniso8601-0.92.tar.gz
    Not SVN Repository
Requirement already satisfied (use --upgrade to upgrade): pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from flask-restful)
Requirement already satisfied (use --upgrade to upgrade): six>=1.3.0 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from flask-restful)
Collecting Werkzeug>=0.7 (from Flask>=0.8->flask-restful)
  Using cached Werkzeug-0.10.1.tar.gz
    Not SVN Repository
Collecting Jinja2>=2.4 (from Flask>=0.8->flask-restful)
  Using cached Jinja2-2.7.3.tar.gz
    Not SVN Repository
Collecting itsdangerous>=0.21 (from Flask>=0.8->flask-restful)
  Using cached itsdangerous-0.24.tar.gz
    Not SVN Repository
Collecting markupsafe (from Jinja2>=2.4->Flask>=0.8->flask-restful)
  Using cached MarkupSafe-0.23.tar.gz
    Not SVN Repository
Installing collected packages: markupsafe, itsdangerous, Jinja2, Werkzeug, aniso8601, Flask, flask-restful
  Running setup.py install for markupsafe

ImportError: cannot import name Feature

I have a problem that Feature does not exist in python-setuptools
Setuptools 22.0 on Ubuntu 16.04

Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    from distutils.core import setup, Extension, Feature
ImportError: cannot import name Feature

Any idea how to fix it?

escape function does not return Markup class for instances implementing __html__ method

The escape function does not wrap a return value of __html__ method as Markup.

Expected behaviour documented in README.rst:

>>> class Foo(object):
...  def __html__(self):
...   return '<strong>Nice</strong>'
...
>>> escape(Foo())
Markup(u'<strong>Nice</strong>')

Actual behaviour:

>>> from markupsafe import escape
>>> class Foo(object):
...  def __html__(self):
...   return '<strong>Nice</strong>'
...
>>> escape(Foo())
'<strong>Nice</strong>'

I am using the 1.0 version I get same result for both native and speedups implementations.

>>> import markupsafe
>>> markupsafe.__version__
'1.0'
>>> from markupsafe._speedups import escape
>>> escape(Foo())
'<strong>Nice</strong>'
>>> from markupsafe._native import escape
>>> escape(Foo())
'<strong>Nice</strong>'

Recent v0.16 changes are causing invalid use of imap().

The mod function when passed with a tuple is breaking and represents invalid Python syntax:

  File "/usr/local/lib/python2.7/dist-packages/markupsafe/__init__.py", line 95, in __mod__
    arg = tuple(imap(_MarkupEscapeHelper, arg, self.escape))
TypeError: 'instancemethod' object is not iterable

This is the current code (changed by https://github.com/mitsuhiko/markupsafe/blob/7415f6f8816e8eae1e34db76504062e98e5e6ab0/markupsafe/__init__.py)

  if isinstance(arg, tuple):
 95  ->             arg = tuple(imap(_MarkupEscapeHelper, arg, self.escape))
 96             else:
 97                 arg = _MarkupEscapeHelper(arg, self.escape)

The previous code was treating MarkupEscapeHelper as a function and treating each tuple element as a parameter for that function. The recent change attempts to pass in self.escape as an extra parameter but will not work correctly with imap().

     if isinstance(arg, tuple):
            arg = tuple(imap(_MarkupEscapeHelper, arg))

PRs failing due to AppVeyor

PRs (like #75) are being marked as failed because the AppVeyor build failed.

image

The failure is:

Build started
git clone -q https://github.com/pallets/markupsafe.git C:\projects\markupsafe
git fetch -q origin +refs/pull/75/merge:
git checkout -qf FETCH_HEAD
Specify a project or solution file. The directory does not contain a project or solution file.

https://ci.appveyor.com/project/davidism/markupsafe/build/1.0.18

This is because AppVeyor has been enabled for this repo, but there's no appveyor.yml config file yet to tell it how to build and test. I see there's an open PR for this at #65.

In the meantime, I recommend popping over to https://ci.appveyor.com/project/pallets/markupsafe/settings and checking "Skip branches without appveyor.yml":

image

I believe that will stop the "failure" noise on PRs which are otherwise fine. Thank you!

Markup.format doesn't support "{}" notation

Standard python 2.7:

>>> s = u'test: {}'
>>> s.format(u'ok!')
u'test: ok!'

markupsafe 0.21:

>>> from markupsafe import Markup
>>> Markup(s).format(u'ok!')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bmathieu/projets/systematic/local/lib/python2.7/site-packages/markupsafe/__init__.py", line 198, in format
    return self.__class__(formatter.format(self, *args, **kwargs))
  File "/usr/lib/python2.7/string.py", line 545, in format
    return self.vformat(format_string, args, kwargs)
  File "/usr/lib/python2.7/string.py", line 549, in vformat
    result = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/usr/lib/python2.7/string.py", line 571, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "/usr/lib/python2.7/string.py", line 632, in get_field
    obj = self.get_value(first, args, kwargs)
  File "/usr/lib/python2.7/string.py", line 591, in get_value
    return kwargs[key]
KeyError: u''

Just to prove it works with an index value:

>>> Markup(u'test: {0}').format(u'ok!')
Markup(u'test: ok!')

Unexpected return type of markupsafe.Markup.{split,rsplit,splitlines}() with Python 3

$ python2.7 -c 'import markupsafe; print(markupsafe.Markup("a b").split())'
[Markup(u'a'), Markup(u'b')]
$ python3.3 -c 'import markupsafe; print(markupsafe.Markup("a b").split())'
<map object at 0x7f62f1378d90>
$ python2.7 -c 'import markupsafe; print(markupsafe.Markup("a b").rsplit())'
[Markup(u'a'), Markup(u'b')]
$ python3.3 -c 'import markupsafe; print(markupsafe.Markup("a b").rsplit())'
<map object at 0x7fe322c3ab90>
$ python2.7 -c 'import markupsafe; print(markupsafe.Markup("a\nb").splitlines())'
[Markup(u'a'), Markup(u'b')]
$ python3.3 -c 'import markupsafe; print(markupsafe.Markup("a\nb").splitlines())'
<map object at 0x7fef0fbcdd90>

markupsafe.Markup.__mul__() incompatible with Python 3

$ python3.3 -c 'import markupsafe; markupsafe.Markup() * 1'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "./markupsafe/__init__.py", line 88, in __mul__
    if isinstance(num, (int, long)):
NameError: global name 'long' is not defined

Segmentation fault if installed without --no-use-wheel

$ uname -srmo
Linux 4.4.5-1-ARCH x86_64 GNU/Linux
$ python --version
Python 2.7.10
$ pip freeze | grep MarkupSafe
MarkupSafe==0.23
$ dmesg | grep speedups
[175322.987206] python[793]: segfault at 7f34348b8240 ip 00007f34336b6d59 sp 00007f34299e1230 error 4 in _speedups.so[7f34336b6000+2000]
[175417.738383] python[924]: segfault at 7ff104a45d80 ip 00007fef49281d59 sp 00007fef3f5acf20 error 4 in _speedups.so[7fef49281000+2000]

escape doesn't appear to handle unicode quotes correctly

I've recently had some issues in Jinja2 with strings containing unicode quotes. Having tested directly in markupsafe, I can see the same issue:

>>> escape(u"Denny’s Uniforms")
Markup(u'Denny\u2019s Uniforms')
>>> escape(u"Denny‘s “Uniforms”")
Markup(u'Denny\u2018s \u201cUniforms\u201d')
>>> escape(u"Try something else—an em-dash")
Markup(u'Try something else\u2014an em-dash')

I was expecting this:

>>> escape(u"Denny’s Uniforms")
Markup(u'Denny&rsquo;s Uniforms')
>>> escape(u"Denny‘s “Uniforms”")
Markup(u'Denny&rsquo;s &ldquo;Uniforms&rdquo;')
>>> escape(u"Try something else—an em-dash")
Markup(u'Try something else&mdash;an em-dash')

Alternatively (potentially for better compatibility), even the numeric alternatives:

>>> escape(u"Denny’s Uniforms")
Markup(u'Denny&#8217;s Uniforms')
>>> escape(u"Denny‘s “Uniforms”")
Markup(u'Denny&#8217;s &#8220;Uniforms&#8221;')
>>> escape(u"Try something else—an em-dash")
Markup(u'Try something else&#8212;an em-dash')

In my Jinja2 template (which I'm using to generate basic XML), I'm using this to trigger the escaping:

<some_xml_tag>{{ supplier.name|e }}</some_xml_tag>

Not entirely sure if this is an issue or a misuse on my part, so any help is greatly appreciated. Thanks in advance!

Unable to install markupsafe in amazon ec2 redhat virtual env

I am unable to install the markupsafe in the virtual env on amazon ec2
Linux 4.9.51-10.52.amzn1.x86_64 #1 SMP Fri Sep 29 01:16:19 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I am using python 2.7.12 and virtualenv 15.1.0 and pip 9.0.1 . I first install Flask using "pip install Flask"
which says
Successfully installed Flask-0.12.2 Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 itsdangerous-0.24
pip freeze shows

click==6.7
Flask==0.12.2
itsdangerous==0.24
Jinja2==2.10
Werkzeug==0.12.2

But it does not show the MarkupSafe. I tried install separately, but same fate.
please help.

Markup.__new__ not safe, use unicode.__new__() in templates

I am running tests using flask-testing, and I intermittently get the following stack:

======================================================================
ERROR: tests.TestBooksInPage.test_displays_books
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/ben/repos/github.com/vfq-application/tests.py", line 17, in test_displays_books
    resp = self.app.get('/')
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/werkzeug/test.py", line 761, in get
    return self.open(*args, **kw)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/testing.py", line 108, in open
    follow_redirects=follow_redirects)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/werkzeug/test.py", line 735, in open
    response = self.run_wsgi_app(environ, buffered=buffered)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/werkzeug/test.py", line 658, in run_wsgi_app
    rv = run_wsgi_app(self.application, environ, buffered=buffered)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/werkzeug/test.py", line 854, in run_wsgi_app
    app_iter = app(environ, start_response)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask_debugtoolbar/__init__.py", line 104, in dispatch_request
    return view_func(**req.view_args)
  File "/Users/ben/repos/github.com/vfq-application/views.py", line 15, in home
    login_user_form=LoginForm())
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/templating.py", line 128, in render_template
    context, ctx.app)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/flask/templating.py", line 110, in _render
    rv = template.render(context)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/ben/repos/github.com/vfq-application/templates/book_list.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/Users/ben/repos/github.com/vfq-application/templates/base.html", line 32, in top-level template code
    <li><a href="{{ url_for_security('register') }}">Sign Up</a><br/></li>
  File "/Users/ben/.pyenv/versions/vfq-application/lib/python2.7/site-packages/markupsafe/__init__.py", line 72, in __new__
    return text_type.__new__(cls, base)
TypeError: object.__new__(Markup) is not safe, use unicode.__new__()
-------------------- >> begin captured logging << --------------------
passlib.utils.compat: DEBUG: loaded lazy attr 'SafeConfigParser': <class ConfigParser.SafeConfigParser at 0x10ce0f8d8>
passlib.utils.compat: DEBUG: loaded lazy attr 'NativeStringIO': <built-in function StringIO>
passlib.utils.compat: DEBUG: loaded lazy attr 'BytesIO': <built-in function StringIO>
passlib.registry: DEBUG: registered 'bcrypt' handler: <class 'passlib.handlers.bcrypt.bcrypt'>
passlib.registry: DEBUG: registered 'des_crypt' handler: <class 'passlib.handlers.des_crypt.des_crypt'>
passlib.registry: DEBUG: registered 'pbkdf2_sha256' handler: <class 'passlib.handlers.pbkdf2.pbkdf2_sha256'>
passlib.registry: DEBUG: registered 'pbkdf2_sha512' handler: <class 'passlib.handlers.pbkdf2.pbkdf2_sha512'>
passlib.registry: DEBUG: registered 'sha256_crypt' handler: <class 'passlib.handlers.sha2_crypt.sha256_crypt'>
passlib.registry: DEBUG: registered 'sha512_crypt' handler: <class 'passlib.handlers.sha2_crypt.sha512_crypt'>
passlib.registry: DEBUG: registered 'plaintext' handler: <class 'passlib.handlers.misc.plaintext'>
factory.generate: DEBUG: BaseFactory: Preparing factories.BookFactory(extra={})
factory.generate: DEBUG: <class 'factories.BookFactory'>: Setting up next sequence (0)
factory.containers: DEBUG: LazyStub: Computing values for factories.BookFactory(image_url=<OrderedDeclarationWrapper for <factory.fuzzy.FuzzyChoice object at 0x10ac5fed0>>, slug=<OrderedDeclarationWrapper for <factory.fuzzy.FuzzyChoice object at 0x10ac5ff50>>, name=<OrderedDeclarationWrapper for <factory.fuzzy.FuzzyChoice object at 0x10ac5ff10>>, description='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.')
factory.containers: DEBUG: LazyStub: Computed values, got factories.BookFactory(description='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', image_url='/static/img/flowcover.png', slug='optimising-flow', name='Kanban')
factory.generate: DEBUG: BaseFactory: Generating factories.BookFactory(slug='optimising-flow', image_url='/static/img/flowcover.png', description='Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', name='Kanban')
werkzeug: DEBUG: Initializing Flask-DebugToolbar log handler
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 1 test in 0.297s

FAILED (errors=1)
Failed - Back to work!

If I take the offending line out, and put it back in again, the test passes once, and then fails again. I've blown away venv's, rolled back python versions etc.

When run through the browser the page renders normally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.