Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add _winapi.GetACP and enable test_unicode on windows #5547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions 2 .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ env:
# test_os: many failing tests
# test_pathlib: support.rmtree() failing
# test_posixpath: OSError: (22, 'The filename, directory name, or volume label syntax is incorrect. (os error 123)')
# test_unicode: AttributeError: module '_winapi' has no attribute 'GetACP'
# test_venv: couple of failing tests
WINDOWS_SKIPS: >-
test_argparse
Expand All @@ -33,7 +32,6 @@ env:
test_rlcompleter
test_pathlib
test_posixpath
test_unicode
test_venv
# configparser: https://github.com/RustPython/RustPython/issues/4995#issuecomment-1582397417
# socketserver: seems related to configparser crash.
Expand Down
3 changes: 0 additions & 3 deletions 3 Lib/test/test_charmapcodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def codec_search_function(encoding):
codecname = 'testcodec'

class CharmapCodecTest(unittest.TestCase):
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_constructorx(self):
self.assertEqual(str(b'abc', codecname), 'abc')
self.assertEqual(str(b'xdef', codecname), 'abcdef')
Expand All @@ -43,14 +42,12 @@ def test_encodex(self):
self.assertEqual('dxf'.encode(codecname), b'dabcf')
self.assertEqual('dxfx'.encode(codecname), b'dabcfabc')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_constructory(self):
self.assertEqual(str(b'ydef', codecname), 'def')
self.assertEqual(str(b'defy', codecname), 'def')
self.assertEqual(str(b'dyf', codecname), 'df')
self.assertEqual(str(b'dyfy', codecname), 'df')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_maptoundefined(self):
self.assertRaises(UnicodeError, str, b'abc\001', codecname)

Expand Down
11 changes: 0 additions & 11 deletions 11 Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,6 @@ def test_decode(self):
self.assertEqual(codecs.decode(b'[\xff]', 'ascii', errors='ignore'),
'[]')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_encode(self):
self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'),
b'\xe4\xf6\xfc')
Expand All @@ -1846,7 +1845,6 @@ def test_register(self):
self.assertRaises(TypeError, codecs.register)
self.assertRaises(TypeError, codecs.register, 42)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AttributeError: module '_winapi' has no attribute 'GetACP'")
def test_unregister(self):
name = "nonexistent_codec_name"
search_function = mock.Mock()
Expand All @@ -1859,28 +1857,23 @@ def test_unregister(self):
self.assertRaises(LookupError, codecs.lookup, name)
search_function.assert_not_called()

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_lookup(self):
self.assertRaises(TypeError, codecs.lookup)
self.assertRaises(LookupError, codecs.lookup, "__spam__")
self.assertRaises(LookupError, codecs.lookup, " ")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getencoder(self):
self.assertRaises(TypeError, codecs.getencoder)
self.assertRaises(LookupError, codecs.getencoder, "__spam__")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getdecoder(self):
self.assertRaises(TypeError, codecs.getdecoder)
self.assertRaises(LookupError, codecs.getdecoder, "__spam__")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getreader(self):
self.assertRaises(TypeError, codecs.getreader)
self.assertRaises(LookupError, codecs.getreader, "__spam__")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getwriter(self):
self.assertRaises(TypeError, codecs.getwriter)
self.assertRaises(LookupError, codecs.getwriter, "__spam__")
Expand Down Expand Up @@ -1939,7 +1932,6 @@ def test_undefined(self):
self.assertRaises(UnicodeError,
codecs.decode, b'abc', 'undefined', errors)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_file_closes_if_lookup_error_raised(self):
mock_open = mock.mock_open()
with mock.patch('builtins.open', mock_open) as file:
Expand Down Expand Up @@ -3287,7 +3279,6 @@ def test_multiple_args(self):
self.check_note(RuntimeError('a', 'b', 'c'), msg_re)

# http://bugs.python.org/issue19609
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_codec_lookup_failure(self):
msg = "^unknown encoding: {}$".format(self.codec_name)
with self.assertRaisesRegex(LookupError, msg):
Expand Down Expand Up @@ -3523,8 +3514,6 @@ def test_incremental(self):
False)
self.assertEqual(decoded, ('abc', 3))

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_mbcs_alias(self):
# Check that looking up our 'default' codepage will return
# mbcs when we don't have a more specific one available
Expand Down
2 changes: 0 additions & 2 deletions 2 Lib/test/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,6 @@ def test_utf8_normalization(self):
found, consumed_lines = detect_encoding(rl)
self.assertEqual(found, "utf-8")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_short_files(self):
readline = self.get_readline((b'print(something)\n',))
encoding, consumed_lines = detect_encoding(readline)
Expand Down Expand Up @@ -1316,7 +1315,6 @@ def readline(self):
ins = Bunk(lines, path)
detect_encoding(ins.readline)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_open_error(self):
# Issue #23840: open() must close the binary file on error
m = BytesIO(b'#coding:xxx')
Expand Down
1 change: 1 addition & 0 deletions 1 vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ features = [
workspace = true
features = [
"Win32_Foundation",
"Win32_Globalization",
"Win32_Networking_WinSock",
"Win32_Security",
"Win32_Storage_FileSystem",
Expand Down
5 changes: 5 additions & 0 deletions 5 vm/src/stdlib/winapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ mod _winapi {
Ok(HANDLE(target))
}

#[pyfunction]
fn GetACP() -> u32 {
unsafe { windows_sys::Win32::Globalization::GetACP() }
}

#[pyfunction]
fn GetCurrentProcess() -> HANDLE {
unsafe { windows::Win32::System::Threading::GetCurrentProcess() }
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.