Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:11:13+00:00 2026-05-31T14:11:13+00:00

I am trying to get python-gnupg to work in Jython under PyDev under Eclipse.

  • 0

I am trying to get python-gnupg to work in Jython under PyDev under Eclipse. There is a problem which seems to be caused by the sys.stdin.encoding, which is tested by python-gnupg at it’s initialisation.

I found that the following script

import sys
print sys.stdin.encoding

outptus cp850 when I run it from Python standalone in a console and from Jython standalone in a console. When I run it in Python under PyDev, it outputs Cp1252, and when I run it in Jython under PyDev, I get None.

Looking at python-gnupg, both encodings cp850 and Cp1252 seem to be ok, but if it’s None, it raises an exception:

File "C:\Python27\lib\site-packages\gnupg.py", line 487, in __init__
  self._collect_output(p, result, stdin=p.stdin)
File "C:\Python27\lib\site-packages\gnupg.py", line 561, in _collect_output
  stderr = codecs.getreader(self.encoding)(process.stderr)
File "C:\jython2.5.2\Lib\codecs.py", line 920, in getreader
  return lookup(encoding).streamreader
at org.python.core.codecs.normalizestring(codecs.java:101)
at org.python.core.codecs.lookup(codecs.java:75)
at org.python.modules._codecs.lookup(_codecs.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.NullPointerException: java.lang.NullPointerException

Looks like there are differences between PyDev and standalone encodings, as well as no (?) encoding for PyDev/Jython? I’d really like to use the convenient PyDev development environment, but how can I get the sys.stdin.encoding to be something sensible when developing a Jython program?

Update 1

Maybe the problem is related to one of the following Jython bug reports:

  • http://bugs.jython.org/issue1839
  • http://bugs.jython.org/issue1807 (see msg6717)

But then again, these seem to be independent from PyDev/Eclipse..?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:11:14+00:00Added an answer on May 31, 2026 at 2:11 pm

    It’s actually a Jython issue:

    In PySystemState.java, when setting up the encodings, Jython will skip setting any encoding if it’s not a tty console:

    private void initEncoding() {
        String encoding = registry.getProperty(PYTHON_CONSOLE_ENCODING);
        if (encoding == null) {
            return;
        }
    
        for (PyFile stdStream : new PyFile[] {(PyFile)this.stdin, (PyFile)this.stdout,
                                              (PyFile)this.stderr}) {
            if (stdStream.isatty()) {
                stdStream.encoding = encoding;
            }
        }
    }
    

    So, a workaround could be creating a java module to set that (as encoding is a public field of PyFile, but does not have a setter from the Jython side — or you could use java reflection to set it)…

    Maybe you could ask the Jython guys why this is made in the first place (I think the encoding could be set even if it was not a tty device, but I’m not sure which implications could it have and why it’s done that way).

    EDIT to summarise the results of the many comments below, between the developers of Jython and PyDev as well as the author of the original question (Philip Jenvey, Fabio Zadrozny and Christian Gelinek, resp.):

    During the progress, a couple of test scripts were discussed and developed:

    • A Python unit test written by Philip to test different encodings set by minimal custom created sitecusomize.py scripts. Fabio thinks that the reason for it not actually setting the encoding is because sys.stdin.encoding is inherited from the parent process instead configured by the unit test script.
    • A Java test program written by Christian which sets up custom I/O streams for creating a Python subprocess, which was found by Fabio to be more similar to how PyDev sets up the subprocess.

    As this didn’t work as expected by Fabio, he remembered that PyDev also uses the PYTHONIOENCODING environment variable.

    As was pointed out by Philip, the current (2.5) version of Jython doesn’t support the PYTHONIOENCODING environment variable, which is used by PyDev (in combination with sitecusomize.py) to set the encoding:

    You can log a bug for it, although PYTHONIOENCODING was only added in CPython 2.6, so Jython probably wouldn’t support it until 2.7 (Jython’s skipping 2.6).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm trying to get gtksourceview python bindings work under windows (I'm developing a
I've got a problem trying to get python to accept an import 'globally' In
I am trying to get the Xdebug vim plugin to work which depends on
I'm trying to get Python twisted to work on my Ubuntu 11.04 box. I
I am just trying to get into python, but I've found it very difficult
I'm a long time C++/Java developer trying to get into Python and am looking
I am trying to get up to speed with Python, trying to replace some
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I'm trying to get started with unit testing in Python and I was wondering
I am trying to get started with scons . I have Python 3.0.1 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.